Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent notifies issue with plugin provider #141

Closed
caryp opened this issue Sep 17, 2014 · 1 comment

Comments

Projects
None yet
1 participant
@caryp
Copy link

commented Sep 17, 2014

tl;dr;

The plugin provider actions send notifications before the plugins are actually enabled/disabled. This is due to new_resource.updated_by_last_action(true) being executed within the execute resource block.

See https://github.com/kennonkwok/rabbitmq/blob/master/providers/plugin.rb#L42

details

This problem occurs when trying to download rabbitmqadmin utility from the management plugin. To download this util, one must:

  1. enable plugin
  2. restart rabbitmq-server
  3. download the utility from the management plugin webserver on port 15672

Here is my code:

rabbitmq_plugin "rabbitmq_management" do
  action :enable
  notifies :restart, "service[#{node['rabbitmq']['service_name']}]", :immediately # must restart before we can download
end

remote_file "/usr/local/bin/rabbitmqadmin" do
  source "http://localhost:15672/cli/rabbitmqadmin"
  mode "0755"
  retries 10  # extremely large non-deterministic wait/retry for rabbitmq_management to start serving pages
  action :create
end

This code is intermittently failing, with the remote_file giving up after 10 retries. The problem is that the service restart action is occurring before the execute run action. Here is the chef-client output showing the restart happening first:

Recipe: wrapper_cookbook::rabbitmq
  * rabbitmq_plugin[rabbitmq_management] action enable

Recipe: rabbitmq::default
  * service[rabbitmq-server] action restart
    - restart service service[rabbitmq-server]

Recipe: <Dynamically Defined Resource>
  * execute[rabbitmq-plugins enable rabbitmq_management] action runThe following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.

    - execute rabbitmq-plugins enable rabbitmq_management

Recipe: wrapper_cookbook::rabbitmq
  * remote_file[/usr/local/bin/rabbitmqadmin] action create
    - create new file /usr/local/bin/rabbitmqadmin
================================================================================
Error executing action `create` on resource 'remote_file[/usr/local/bin/rabbitmqadmin]'
================================================================================


Errno::ECONNREFUSED
-------------------
Connection refused - Connection refused connecting to http://localhost:15672/cli/rabbitmqadmin, giving up


Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/wrapper_cookbook/recipes/rabbitmq.rb

 44: remote_file "/usr/local/bin/rabbitmqadmin" do
 45:   source "http://localhost:15672/cli/rabbitmqadmin"
 46:   mode "0755"
 47:   retries 10  # extremely large non-deterministic wait/retry for rabbitmq_management to start serving pages
 48:   action :create
 49: end

caryp pushed a commit to caryp-contrib/rabbitmq that referenced this issue Sep 17, 2014

@caryp

This comment has been minimized.

Copy link
Author

commented Sep 17, 2014

Turns out that use_inline_resources in provider fixes this issue. See LWRP docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.