Issue #20865 has been updated by Christian Flamm.

> It is also starting to look like this problem is specific to Ruby 1.8.x. 
> Which operating system and ruby version are you using?

    # uname -a
     Linux <some agent> 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 
2012 x86_64 x86_64 x86_64 GNU/Linux
    
    # cat /etc/redhat-release 
     CentOS release 6.3 (Final)

    # rpm -qa | egrep -i "puppet|ruby"
     ruby-augeas-0.4.1-1.el6.x86_64
     puppetlabs-release-6-6.noarch
     ruby-1.8.7.352-10.el6_4.x86_64
     ruby-irb-1.8.7.352-10.el6_4.x86_64
     rubygems-1.3.7-1.el6.noarch
     ruby-shadow-1.4.1-13.el6.x86_64
     puppet-3.2.1-1.el6.noarch
     libselinux-ruby-2.0.94-5.3.el6_4.1.x86_64
     ruby-libs-1.8.7.352-10.el6_4.x86_64
     ruby-rgen-0.6.2-1.el6.noarch
     ruby-rdoc-1.8.7.352-10.el6_4.x86_64
     rubygem-json-1.5.5-1.el6.x86_64


----------------------------------------
Bug #20865: Random behavior when notifying exec ressources having "onlyif" 
parameter set
https://projects.puppetlabs.com/issues/20865#change-92106

* Author: Christian Flamm
* Status: Investigating
* Priority: Normal
* Assignee: Charlie Sharpsteen
* Category: 
* Target version: 
* Affected Puppet version: 3.1.1
* Keywords: exec onlyif notify
* Branch: 
----------------------------------------
Please have a look at this simplified example.

    class runtimevariation {
      # dummy file ressources that should represent
      # some real software deployment
      file { '/tmp/software-v1': ensure => present, }
    
      file { '/tmp/software-v2': ensure => present, }
    
      file { '/tmp/software-v3': ensure => present, }
    
      # indicating current version in use
      file { '/tmp/current':
        ensure  => link,
        target  => '/tmp/software-v2',
        require => File['/tmp/software-v2'],
        notify  => Exec['software.restart'],
      }
    
      # whenever link target changes I want to run this - but
      # only if the file exists and is executable
      exec { 'software.restart':
        refreshonly => true,
        command     => '/tmp/restart/software',
        onlyif      => '/usr/bin/[ -x /tmp/restart/software ]'
      }
    }

On the configured machine:

    # ll /tmp/
    total 0
    lrwxrwxrwx 1 root root 16 May 23 08:41 current -> /tmp/software-v2
    -rw-r--r-- 1 root root  0 May 23 08:40 software-v1
    -rw-r--r-- 1 root root  0 May 23 08:41 software-v2
    -rw-r--r-- 1 root root  0 May 23 08:41 software-v3

There are a couple of different '/tmp/software-v*' file resources. There's a 
'/tmp/current' link pointing to either one of them. Whenever something about 
the link file resource (e.g. target) changes I want to notify the 
'software.restart' exec resource to run a command but only if a matching 
executable exists.

**My assumption was**: if nothing about the whole catalog/class changes 
(particularly the '/tmp/current' link) then the exec resource would never get 
notified and so neither the onlyif check nor the command would be run.

**But: the onlyif check does sometimes get run**. I just don't understand when 
and why. During the following puppet agent runs nothing about the node's 
catalog (only containing class runtimevariation) changes.

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     Debug: Exec[software.restart](provider=posix): Executing check '/usr/bin/[ 
-x /tmp/restart/software ]'
     Debug: Executing '/usr/bin/[ -x /tmp/restart/software ]'

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     nothing!

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     Debug: Exec[software.restart](provider=posix): Executing check '/usr/bin/[ 
-x /tmp/restart/software ]'
     Debug: Executing '/usr/bin/[ -x /tmp/restart/software ]'

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     nothing!

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     nothing!

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     Debug: Exec[software.restart](provider=posix): Executing check '/usr/bin/[ 
-x /tmp/restart/software ]'
     Debug: Executing '/usr/bin/[ -x /tmp/restart/software ]'

    # puppet agent --no-daemonize --debug --onetime | grep "/usr/bin/\[ -x "
     nothing!

Sometimes the onlyif check does get executed... sometimes not.

This becomes more interessting if you have a bunch of such exec ressources with 
(more) expensive onlyif checks. In our setup this makes a difference of 15-20s 
vs. 30-35s per catalog run.




-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to