Bug #766

events don't trigger a service restart when "ensure" attribute is omitted

Added by Dane Miller almost 5 years ago. Updated over 4 years ago.

Status:Closed Start date:
Priority:Normal Due date:
Assignee:Andrew Shafer % Done:

0%

Category:-
Target version:0.24.0
Affected Puppet version:0.25.4 Branch:
Keywords:
Votes: 0

Description

Events triggered by notify/subscribe don’t restart a running service if the service definition omits the “ensure” attribute. Puppet should check whether the service is running, not whether the service should be running.

For example, the following does not restart a running myqld after my.cnf changes:

service { "mysqld": 
   name => "mysql-server",
   pattern => "mysqld",
   path => "/usr/local/etc/rc.d",
   provider => init,
}
remotefile { "/etc/my.cnf": 
   source => "apps/mysql/my.cnf,
   notify => Service[mysqld],
}

History

Updated by David Schmitt over 4 years ago

A fix for this is available in the misspiggy/fix-766 branch available from my repo at git://git.black.co.at/puppet-bugfixes

Updated by Luke Kanies over 4 years ago

I looked at this commit, and I’m not satisfied with the solution. I think a :notifiable value is unnecessary; we just need to retrieve the current state of :ensure, and then restart if the service is running. Properties work fine with no ‘should’ value.

Something like the following should work:

if (@parameters[:ensure] || newattr(:ensure)).retrieve == :running
  ...refresh...
end

I really would like unit tests for these, though. Ping me on IRC and we can walk through creating this solution and a test for it.

Updated by Luke Kanies over 4 years ago

  • Status changed from 1 to Closed
  • 7 set to fixed

Fixed in commit:dedc56a6ae583daca304c053b1be8a52bcdbd13a.

Also available in: Atom PDF