1
votes

I was always was under impression that delayed as follows

notifies :restart, 'service[nexus]', :delayed

would delay the restart of the service to the end of the run. Now I noticed that doesn't seem to be the case. As the log below shows, the restart is send delayed and executed immediately. Each time.

The log is very strange btw because it seems that the recipe is run multiple times. I only have one ruby_block for security-configuration.xml but it appears many many times in the log.

What is the purpose of :delayed? What is delayed?

How is it possible that a resource is shown in the log multiple times? Should it not run once?

==> default: [2016-08-18T13:24:31+00:00] INFO: ruby_block[/opt/nexus/sonatype-work/conf/security-configuration.xml] sending restart action to service[nexus] (delayed)
==> default: [2016-08-18T13:24:55+00:00] INFO: service[nexus] restarted
==> default: [2016-08-18T13:24:55+00:00] INFO: ruby_block[/opt/nexus/sonatype-work/conf/security-configuration.xml] sending restart action to service[nexus] (delayed)
==> default: [2016-08-18T13:25:13+00:00] INFO: service[nexus] restarted
==> default: [2016-08-18T13:25:13+00:00] INFO: ruby_block[/opt/nexus/sonatype-work/conf/security-configuration.xml] sending restart action to service[nexus] (delayed)
==> default: [2016-08-18T13:25:36+00:00] INFO: service[nexus] restarted
==> default: [2016-08-18T13:25:36+00:00] INFO: ruby_block[/opt/nexus/sonatype-work/conf/security-configuration.xml] sending restart action to service[nexus] (delayed)
==> default: [2016-08-18T13:25:59+00:00] INFO: service[nexus] restarted
==> default: [2016-08-18T13:25:59+00:00] INFO: ruby_block[/opt/nexus/sonatype-work/conf/security-configuration.xml] sending restart action to service[nexus] (delayed)

I am using Chef client 12.4.1.

Update

So my understanding of delayed was correct. The question now is why delayed is no longer working. This btw this behavior is also present for other services for example jenkins

==> default: [2016-08-19T06:51:56+00:00] INFO: template[/var/lib/jenkins/config.xml] sending restart action to service[jenkins] (delayed)
==> default: [2016-08-19T06:51:58+00:00] INFO: service[jenkins] restarted 

Services that are notified for restart delayed are restarting immediately and as a consequence multiple times during a run. This is now also causing the run to fail with messages that restart is done to often.

==> default: STDERR: Job for jenkins.service failed because start of the service was attempted too often. See "systemctl status jenkins.service" and "journalctl -xe" for details.

This ability to restart services delayed is rather crucial. Why is it not working properly?

1
Which Chef-client version are you using? - Mrigesh Priyadarshi
Would you mind updating your version, as I can recall this version had some issues. I am using "12.13.37" and it works just fine. - Mrigesh Priyadarshi

1 Answers

1
votes

It delays converging that resource until the end of the client run. Also, if the resource is 'notified' multiple times with a delay, it will only execute once. This is hugely beneficial for speeding up the chef-client run time.

From Chef's docs:

Specifies that a notification should be queued up, and then executed at the very end of the chef-client run.