Git Product home page Git Product logo

Comments (21)

alefebvre-ls avatar alefebvre-ls commented on July 17, 2024 1

@priestjim Yes this did fix the issue for me. If you could modify the cookbook to get this working without us having to create a modified version of that ohai plugin, that would be great 👍

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

There's a node.set that prevents that from happening:

not_if do
  openresty_force_recompile == false &&
    node.automatic_attrs['nginx'] &&
    node.automatic_attrs['nginx']['version'] == node['openresty']['source']['version'] &&
    node['openresty']['persisted_configure_flags'] &&
    node['openresty']['persisted_configure_flags'] == configure_flags.sort.uniq
end

from chef-openresty.

heffergm avatar heffergm commented on July 17, 2024

So what might the issue be in my case? It's definitely recompiling on every run, so the attribute doesn't appear to be taking effect.

Grant

On May 28, 2014, at 8:57 PM, Panagiotis PJ Papadomitsos [email protected] wrote:

There's a node.set that prevents that from happening:

not_if do
openresty_force_recompile == false &&
node.automatic_attrs['nginx'] &&
node.automatic_attrs['nginx']['version'] == node['openresty']['source']['version'] &&
node['openresty']['persisted_configure_flags'] &&
node['openresty']['persisted_configure_flags'] == configure_flags.sort.uniq
end

Reply to this email directly or view it on GitHub.

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

Are you running chef-solo or chef-client? Have you tried with the latest version available from this repo?

from chef-openresty.

heffergm avatar heffergm commented on July 17, 2024

It's chef solo, 11.10, however I'm using AWS opsworks, so it's likely that they've done something that's causing this in terms of chef modifications.

I'm happy to help debug.

Grant

On May 29, 2014, at 12:50 AM, Panagiotis PJ Papadomitsos [email protected] wrote:

Are you running chef-solo or chef-client?


Reply to this email directly or view it on GitHub.

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024
  1. run ohai -d /etc/chef/plugins/ohai and check if the NGINX version is being detected correctly by the plugin. This should check if skipping recompilation fails on

    node.automatic_attrs['nginx'] &&
    node.automatic_attrs['nginx']['version'] == node['openresty']['source']['version'] &&
    
  2. Check if the file /var/chef/cache/openresty.configure-opts exists and its contents. It should be automatically created after every recompilation and contain all configuration flags.

  3. Make sure OpsWorks does not disable custom OHAI plugins, because if this is the case, then node.automatic_attrs['nginx'] will always be nil!

from chef-openresty.

heffergm avatar heffergm commented on July 17, 2024

So there’s definitely an issue with the plugin being registered correctly. The plugin path as defaults is incorrect, but it’s unclear at the moment if using ohai to register plugins in the fashion the cookbook is doing will work at all. I’ll follow up with AWS to see what I can come up with.

Grant Heffernan

On Friday, May 30, 2014 at 3:40 AM, Panagiotis PJ Papadomitsos wrote:

run ohai -d /etc/chef/plugins/ohai and check if the NGINX version is being detected correctly by the plugin. This should check if skipping recompilation fails on
node.automatic_attrs['nginx'] && node.automatic_attrs['nginx']['version'] == node['openresty']['source']['version'] &&

Check if the file /var/chef/cache/openresty.configure-opts exists and its contents. It should be automatically created after every recompilation and contain all configuration flags.

Make sure OpsWorks does not disable custom OHAI plugins, because if this is the case, then node.automatic_attrs['nginx'] will always be nil!


Reply to this email directly or view it on GitHub (#15 (comment)).

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

Closed as stale.

from chef-openresty.

dorongutman avatar dorongutman commented on July 17, 2024

@heffergm did you ever find out how to fix this ? I'm stuck with this as well

from chef-openresty.

alefebvre-ls avatar alefebvre-ls commented on July 17, 2024

I'm also having having this issue when running tests with test-kitchen, which is using Chef-Zero. Could this be re-opened?

from chef-openresty.

alefebvre-ls avatar alefebvre-ls commented on July 17, 2024

@dorongutman I think I may have found the issue. Prior to version to the ohai gem version 8.14.0, the shell_out command only accepted one parameter. Only as of the ohai gem version 8.14.0 does shell_out accept more than one parameter. I'm using chef 12.7.2, which unfortunately has an older version of the Ohai gem (7.4.1) bundled with it.

To fix this, i've simply created my own local version of the 'nginx.rb.erb' oahi plugin file and then added this code just after i've included the openresty cookbook:

r = resources('ohai_plugin[nginx]')
r.cookbook "#{cookbook_name}"

The nginx.rb.erb plugin file changes the following line:
so = shell_out("<%= @nginx_bin -%> -V", cwd: "<%= @nginx_prefix -%>")

to this:
so = shell_out("<%= @nginx_bin -%> -V")

I'm not a chef expert, so if I'm totally off or there's a better way to fix this, without upgrading chef, I'd appreciate it if someone could let me know.

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

@alefebvre-ls have you verified that this fixes the issue? I can add a case to detect failure like this and support both ohai gem versions.

from chef-openresty.

dorongutman avatar dorongutman commented on July 17, 2024

@priestjim the commit you made (as part of 0.5.4) doesn't work for me, and I still get recompilation of openresty everytime. was I supposed to change something in my config ?

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

@dorongutman have you tried executing the steps I mentioned earlier in this issue?

from chef-openresty.

dorongutman avatar dorongutman commented on July 17, 2024

@priestjim if you're referring to this, I got the following:

  1. Running ohai -d ohai -d /var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins returns a json in which the nginx version appeared correctly.
  2. I couldn't find a file named openresty.configure-opts at all
  3. How can check if OpsWorks disables custom OHAI plugins ?

I see the following log lines (with warnings) in the chef log around the openresty stuff:

[2017-06-29T06:09:07+00:00] WARN: The Ohai cookbook default recipe has no content as of the 4.0 release. See the readme for instructions on using the custom resources.
[2017-06-29T06:09:07+00:00] INFO: Processing ohai_plugin[nginx] action create (openresty::ohai_plugin line 25)
[2017-06-29T06:09:07+00:00] WARN: The Ohai plugin_path does not include /var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins. Ohai will reload on each chef-client run in order to add this directory to the path unless you modify your client.rb configuration to add this directory to plugin_path. The plugin_path can be set via the chef-client::config recipe. See 'Ohai Settings' at https://docs.chef.io/config_rb_client.html#ohai-settings for more details.
[2017-06-29T06:09:07+00:00] WARN: Adding /var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins to the Ohai plugin path for this chef-client run only
[2017-06-29T06:09:07+00:00] INFO: Processing directory[/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins] action create (/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/local-mode-cache/cache/cookbooks/ohai/resources/plugin.rb line 12)
[2017-06-29T06:09:07+00:00] INFO: directory[/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins] created directory /var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins
[2017-06-29T06:09:07+00:00] INFO: Processing template[/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins/nginx.rb] action create (/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/local-mode-cache/cache/cookbooks/ohai/resources/plugin.rb line 25)
[2017-06-29T06:09:07+00:00] INFO: template[/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins/nginx.rb] created file /var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins/nginx.rb
[2017-06-29T06:09:07+00:00] INFO: template[/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins/nginx.rb] updated file contents /var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins/nginx.rb
[2017-06-29T06:09:07+00:00] INFO: template[/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins/nginx.rb] sending reload action to ohai[nginx] (immediate)
[2017-06-29T06:09:07+00:00] INFO: Processing ohai[nginx] action reload (/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/local-mode-cache/cache/cookbooks/ohai/resources/plugin.rb line 42)
[2017-06-29T06:09:08+00:00] INFO: ohai[nginx] reloaded
[2017-06-29T06:09:08+00:00] INFO: Processing ohai[nginx] action reload (/var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/local-mode-cache/cache/cookbooks/ohai/resources/plugin.rb line 42)
[2017-06-29T06:09:09+00:00] INFO: ohai[nginx] reloaded

@heffergm did you manage to get an answer about ohai in opsworks ?

from chef-openresty.

dorongutman avatar dorongutman commented on July 17, 2024

@priestjim did you see the above ?

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

@dorongutman it looks like it's loading the plugin properly. Can you do 2 consecutive runs and see if the path prefix (var/chef/runs/b2aef0d7-f370-4d0e-a71a-8642906d6e8a/ohai/plugins) stays the same? If it doesn't, that's the problem! Chef has a different OHAI plugin path every time OpsWorks runs it and so it can't detect the plugin installed on the previous run.

In any case, try the c61f59c branch, I tried a small workaround in case Chef can't detect solo/opsworks runs properly.

from chef-openresty.

dorongutman avatar dorongutman commented on July 17, 2024

@priestjim indeed every time I run a setup or deploy on the machine, it generates a new run id for that so 2 consecutive runs will not have the same one.

edit - I tried the branch you provided, but it still recompiles on every run (tried twice - the first to install the new version of openresty, the second to see if it recompiles or not).

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

That is the problem then. The cookbook cannot detect your currently installed nginx version since the plugin doesn't load and recompiles OR every time. You can try providing an alternative path to your plugin path (ohai.plugin_path or Ohai::Config[:plugin_path]) and see if that makes it work.

from chef-openresty.

dorongutman avatar dorongutman commented on July 17, 2024

hey @priestjim here's OpsWorks team response to an issue I opened a few months ago:
Thank you for bringing this to our attention. We have looked into your issue and identified that for every Chef run, AWS OpsWorks Stacks generates a new run_id. This is by design and is not likely to change. If you have any other feedback for our service, we'd be interested in hearing your experience.

Is there anything else I can do ?

from chef-openresty.

priestjim avatar priestjim commented on July 17, 2024

@dorongutman @alefebvre-ls @heffergm I added code to detect OpsWorks and change the OHAI plugin path to a static one that get's reloaded properly every time so it doesn't trigger a recompilation (which also helped find a bug in Chef Zero detection that also got fixed). Please try it and let me know if you're still facing issues.

from chef-openresty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.