Issue #23319 has been reported by Alex D.

----------------------------------------
Bug #23319: Unnecessary service restart when service is down and we set "ensure 
=> running" and subscribe the service to some file(s) in puppet-2.7
https://projects.puppetlabs.com/issues/23319

* Author: Alex D
* Status: Unreviewed
* Priority: High
* Assignee: 
* Category: 
* Target version: 
* Affected Puppet version: 
* Keywords: 
* Branch: 
----------------------------------------
Steps to reproduce:

1) create test.pp file:
<pre>
service {
        "nginx":
                ensure          => running,
                enable          => true,
                subscribe       => File["/tmp/test1"];
}
file {
        "/tmp/test1":
                ensure  => file,
                content => "kasjakjksjjks";
}
</pre>

2) Install nginx and set error_log level to "info"

3) Make sure nginx is down and  "/tmp/test1" file does not exist:
<pre>
service nginx stop
rm -f /tmp/test1
</pre>

4) Apply the test.pp file:
<pre>
puppet apply test.pp
</pre>


Result: puppet brings nginx service up and then restarts it.

Result in stdout:
<pre>
notice: /Stage[main]//File[/tmp/test1]/ensure: defined content as 
'{md5}502675e3d4e9692deb2e3b2e262450c1'
notice: /Stage[main]//Service[nginx]/ensure: ensure changed 'stopped' to 
'running'
notice: /Stage[main]//Service[nginx]: Triggered 'refresh' from 1 events
</pre>

Result in nginx log:
<pre>
2013/11/29 16:44:38 [notice] 3900#0: using the "epoll" event method
2013/11/29 16:44:38 [notice] 3900#0: nginx/1.0.15
2013/11/29 16:44:38 [notice] 3900#0: built by gcc 4.4.7 20120313 (Red Hat 
4.4.7-3) (GCC) 
2013/11/29 16:44:38 [notice] 3900#0: OS: Linux 
2.6.32-358.123.2.openstack.el6.x86_64
2013/11/29 16:44:38 [notice] 3900#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2013/11/29 16:44:38 [notice] 3901#0: start worker processes
2013/11/29 16:44:38 [notice] 3901#0: start worker process 3904
2013/11/29 16:44:38 [notice] 3901#0: signal 15 (SIGTERM) received, exiting
2013/11/29 16:44:38 [notice] 3904#0: exiting
2013/11/29 16:44:38 [notice] 3904#0: exit
2013/11/29 16:44:38 [notice] 3901#0: signal 17 (SIGCHLD) received
2013/11/29 16:44:38 [notice] 3901#0: worker process 3904 exited with code 0
2013/11/29 16:44:38 [notice] 3901#0: exit
2013/11/29 16:44:38 [notice] 3940#0: using the "epoll" event method
2013/11/29 16:44:38 [notice] 3940#0: nginx/1.0.15
2013/11/29 16:44:38 [notice] 3940#0: built by gcc 4.4.7 20120313 (Red Hat 
4.4.7-3) (GCC) 
2013/11/29 16:44:38 [notice] 3940#0: OS: Linux 
2.6.32-358.123.2.openstack.el6.x86_64
2013/11/29 16:44:38 [notice] 3940#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2013/11/29 16:44:38 [notice] 3941#0: start worker processes
2013/11/29 16:44:38 [notice] 3941#0: start worker process 3943
</pre>

Strace:
<pre>
2912  execve("/bin/env", ["env", "-i", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", 
"TERM=screen", "/etc/init.d/nginx", "status"], [/* 28 vars */]) = 0
2912  execve("/etc/init.d/nginx", ["/etc/init.d/nginx", "status"], [/* 2 vars 
*/]) = 0
2926  execve("/bin/env", ["env", "-i", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", 
"TERM=screen", "/etc/init.d/nginx", "start"], [/* 28 vars */]) = 0
2926  execve("/etc/init.d/nginx", ["/etc/init.d/nginx", "start"], [/* 2 vars 
*/]) = 0
2945  execve("/bin/env", ["env", "-i", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", 
"TERM=screen", "/etc/init.d/nginx", "status"], [/* 28 vars */]) = 0
2945  execve("/etc/init.d/nginx", ["/etc/init.d/nginx", "status"], [/* 2 vars 
*/]) = 0
2954  execve("/bin/env", ["env", "-i", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", 
"TERM=screen", "/etc/init.d/nginx", "stop"], [/* 28 vars */]) = 0
2954  execve("/etc/init.d/nginx", ["/etc/init.d/nginx", "stop"], [/* 2 vars 
*/]) = 0
2966  execve("/bin/env", ["env", "-i", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", 
"TERM=screen", "/etc/init.d/nginx", "start"], [/* 28 vars */]) = 0
2966  execve("/etc/init.d/nginx", ["/etc/init.d/nginx", "start"], [/* 2 vars 
*/]) = 0
</pre>

Such behavior may break some services deployment (cluster services that start 
to synchronize on the first start and then get stopped/started again).


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to