On Tue, Dec 17, 2013 at 7:42 AM, DEGREMONT Aurelien <
[email protected]> wrote:

> Hello
>
> Working on upgrading from 0.25 to 3.x, I faced a regression regarding
> Service ensure behavior.
>
> In 0.25, this code, on a RedHat system:
>
> service { 'ntpd':
>     enable => false,
>     hasstatus => true;
> }
>
> would trigger:
>
> /sbin/chkconfig ntpd
>
> and NO:
>
> service ntpd status
>
> Starting from 2.6 and up to 3.x, both commands are run, the service status
> is checked (service ntpd status is run), even if ensure is not set (or set
> to "undef").
> On some systems, we have up to 50 services checked, and this is a huge
> performance impact on our Puppet runs to launch this command when we do not
> care.
> (some services could be quite long to be checked).
>
>
Hmmm. That is unfortunate.


> I tracked down this behavior change up to this (old) patch:
>
>
> commit 3f6c9481ce9ac59fb3a84ab6792543d039ee403f
> Author: Luke Kanies <[email protected]>
> Date:   Tue Jan 19 18:24:15 2010 -0800
>
>     Changing Transaction to use the new ResourceHarness
>
>     This is a much messier commit than I would like,
>     mostly because of how 'file' works.  I had to
>     fix multiple special cases, and I had to move others.
>
>     The whole system appears to now work, though, and we're
>     ready to change reports to receive resource status
>     instances rather than events.
>
>     Signed-off-by: Luke Kanies <[email protected]>
>
>
Thanks for tracking it down. I looked over the patch, but as the comment
says it is pretty large and I couldn't clearly find the change the caused
the different behavior.


>
> And I quickly workaround this using this oneliner patch:
>
> diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
> index 1933097..bf09fdb 100644
> --- a/lib/puppet/type.rb
> +++ b/lib/puppet/type.rb
> @@ -681,7 +681,7 @@ class Type
>      # Provide the name, so we know we'll always refer to a real thing
>      result[:name] = self[:name] unless self[:name] == title
>
> -    if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure)
> and ensure_prop = newattr(:ensure))
> +    if ensure_prop = property(:ensure) or (self.class.validattr?(:ensure)
> and ensure_prop = newattr(:ensure)) and ensure_prop.should
>        result[:ensure] = ensure_state = ensure_prop.retrieve
>      else
>        ensure_state = nil
>
>
> What do you think of this?
>
>
I tried it out. After unfortunately it changes the behavior of how puppet
detects the current state of a resource on the system. You can see this
pretty clearly when you use the "puppet resource" command to inspect
something:

Without patch:

[root@localhost puppet]# puppet resource service rsyslogd
service { 'rsyslogd':
  ensure => 'stopped',
  enable => 'false',
}

With patch:

[root@localhost puppet]# puppet resource service rsyslogd
service { 'rsyslogd':
  enable => 'false',
}

I think you might be on the right track. I haven't looked into this enough
to be able to give you any pointers right now about where to make a correct
change.


>
> Aurélien
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-dev/52B070D5.9040303%40cea.fr.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Andrew Parker
[email protected]
Freenode: zaphod42
Twitter: @aparker42
Software Developer

*Join us at PuppetConf 2014, September 23-24 in San Francisco*

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CANhgQXuuY1-3Ak%2BH6agj24jn6FMFtTzW19QJBTo6%2BFiQtHB5Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to