[PUP-5044] launchd enable/disable on OS X 10.10 Created: 2015/08/17  Updated: 2017/05/15  Resolved: 2015/08/27

Status: Closed
Project: Puppet
Component/s: Types and Providers
Affects Version/s: PUP 3.8.2
Fix Version/s: PUP 3.8.3, PUP 4.2.2

Type: Bug Priority: Critical
Reporter: Samuel Keeley Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by PUP-4738 launchd enable/disable on OS X 10.11 Closed
Relates
relates to PUP-4639 Refreshing a LaunchDaemon leaves it d... Closed
relates to PUP-7346 Create acceptance test for PUP-5044 Closed
Template:
Story Points: 2
Sprint: Client 2015-09-02
Release Notes: Bug Fix
Release Notes Summary: On OS X 10.10 enable / disable of services did not work due to a change in the location of the overrides plist. This updates the logic to use the new location used by 10.10+.
QA Contact: Eric Thompson

 Description   

Similar to PUP-4738, the proper overrides plist is not used on 10.10. This prevents services from being properly enabled or disabled on 10.10.



 Comments   
Comment by Samuel Keeley [ 2015/08/17 ]

PR https://github.com/puppetlabs/puppet/pull/4167

Comment by Michael Smith [ 2015/08/19 ]

Some more detail, as I've also observed this problem with Puppet 4.2.1:

o7b3mmswjixt1h2:~ root# /opt/puppetlabs/bin/puppet apply -e 'notify {"hello": notify => Service["com.apple.telnetd"]}; service { "com.apple.telnetd": ensure => running, enable => true, hasrestart => true }' --verbose
Notice: Compiled catalog for o7b3mmswjixt1h2.delivery.puppetlabs.net in environment production in 0.50 seconds
Info: Applying configuration version '1440033385'
Notice: hello
Notice: /Stage[main]/Main/Notify[hello]/message: defined 'message' as 'hello'
Info: /Stage[main]/Main/Notify[hello]: Scheduling refresh of Service[com.apple.telnetd]
Warning: Cannot read file /var/db/launchd.db/com.apple.launchd/overrides.plist; Puppet is skipping it.
Details: Execution of '/usr/bin/plutil -convert xml1 -o /dev/stdout /var/db/launchd.db/com.apple.launchd/overrides.plist' returned 1: /var/db/launchd.db/com.apple.launchd/overrides.plist: file does not exist or is not readable or is not a regular file (Error Domain=NSCocoaErrorDomain Code=260 "The file “overrides.plist” couldn’t be opened because there is no such file." UserInfo=0x7fa2bac13f40 {NSFilePath=/var/db/launchd.db/com.apple.launchd/overrides.plist, NSUnderlyingError=0x7fa2bac13cb0 "The operation couldn’t be completed. No such file or directory"})
Error: Could not set 'true' on enable: undefined method `[]=' for nil:NilClass at 1:
Error: Could not set 'true' on enable: undefined method `[]=' for nil:NilClass at 1:
Wrapped exception:
undefined method `[]=' for nil:NilClass
Error: /Stage[main]/Main/Service[com.apple.telnetd]/ensure: change from stopped to running failed: Could not set 'true' on enable: undefined method `[]=' for nil:NilClass at 1:
Notice: /Stage[main]/Main/Service[com.apple.telnetd]: Triggered 'refresh' from 1 events
Info: Class[Main]: Unscheduling all events on Class[Main]
Notice: Applied catalog in 12.02 seconds
o7b3mmswjixt1h2:~ root# /opt/puppetlabs/bin/puppet apply -e 'notify {"hello": notify => Service["com.apple.telnetd"]}; service { "com.apple.telnetd": ensure => running, enable => true, hasrestart => true }' --verbose
Notice: Compiled catalog for o7b3mmswjixt1h2.delivery.puppetlabs.net in environment production in 0.52 seconds
Info: Applying configuration version '1440033402'
Notice: hello
Notice: /Stage[main]/Main/Notify[hello]/message: defined 'message' as 'hello'
Info: /Stage[main]/Main/Notify[hello]: Scheduling refresh of Service[com.apple.telnetd]
Warning: Cannot read file /var/db/launchd.db/com.apple.launchd/overrides.plist; Puppet is skipping it.
Details: Execution of '/usr/bin/plutil -convert xml1 -o /dev/stdout /var/db/launchd.db/com.apple.launchd/overrides.plist' returned 1: /var/db/launchd.db/com.apple.launchd/overrides.plist: file does not exist or is not readable or is not a regular file (Error Domain=NSCocoaErrorDomain Code=260 "The file “overrides.plist” couldn’t be opened because there is no such file." UserInfo=0x7feeb2413f40 {NSFilePath=/var/db/launchd.db/com.apple.launchd/overrides.plist, NSUnderlyingError=0x7feeb2413cb0 "The operation couldn’t be completed. No such file or directory"})
Error: Could not set 'true' on enable: undefined method `[]=' for nil:NilClass at 1:
Error: Could not set 'true' on enable: undefined method `[]=' for nil:NilClass at 1:
Wrapped exception:
undefined method `[]=' for nil:NilClass
Error: /Stage[main]/Main/Service[com.apple.telnetd]/enable: change from false to true failed: Could not set 'true' on enable: undefined method `[]=' for nil:NilClass at 1:
Notice: /Stage[main]/Main/Service[com.apple.telnetd]: Triggered 'refresh' from 1 events
Info: Class[Main]: Unscheduling all events on Class[Main]
Notice: Applied catalog in 11.92 seconds

The result seems to be that

  • If the service is stopped, it will start successfully.
  • If the service is running, it will stop and probably display an error.

I performed some tests with
/opt/puppetlabs/bin/puppet apply -e 'notify {"hello":} ~> service {"mcollective": ensure => running}'
where the service stopped, but no error was displayed, so there seem to be some circumstances where it doesn't error but still behaves incorrectly.

Ah clarity, the service needs to manage `enable => true` to trigger the error message. The service silently stopping seems more like PUP-4639.

Comment by Michael Smith [ 2015/08/20 ]

I think `com.apple.launchd/overrides.plist` wasn't removed as part of an update from OS X 10.9 to OS X 10.10 (which my machine went through, but our VMs didn't) and that the old location is still supported by launchd. So the error only occurs on clean installs of OS X 10.10+.

Comment by Eric Thompson [ 2015/08/27 ]

validated on osx 10.10 at stable agent SHA: 1132758298cb9431326d0252e886be6ec1d6fffd

[root@gbg6mnenwo4i8bw ~]# puppet apply -e 'notify {"hello": notify => Service["ntpdate.service"]}; service { "ntpdate.service": ensure => running, enable => true, hasrestart => true }' --verbose
Notice: Compiled catalog for gbg6mnenwo4i8bw.delivery.puppetlabs.net in environment production in 0.47 seconds
Info: Applying configuration version '1440700384'
Notice: hello
Notice: /Stage[main]/Main/Notify[hello]/message: defined 'message' as 'hello'
Info: /Stage[main]/Main/Notify[hello]: Scheduling refresh of Service[ntpdate.service]
Notice: /Stage[main]/Main/Service[ntpdate.service]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Main/Service[ntpdate.service]: Unscheduling refresh on Service[ntpdate.service]
Notice: Applied catalog in 4.07 seconds
 
[root@gbg6mnenwo4i8bw ~]# puppet apply -e 'notify {"hello": notify => Service["ntpdate.service"]}; service { "ntpdate.service": ensure => running, enable => true, hasrestart => true }' --verbose
Notice: Compiled catalog for gbg6mnenwo4i8bw.delivery.puppetlabs.net in environment production in 0.52 seconds
Info: Applying configuration version '1440700447'
Notice: hello
Notice: /Stage[main]/Main/Notify[hello]/message: defined 'message' as 'hello'
Info: /Stage[main]/Main/Notify[hello]: Scheduling refresh of Service[ntpdate.service]
Notice: /Stage[main]/Main/Service[ntpdate.service]: Triggered 'refresh' from 1 events
Notice: Applied catalog in 2.98 seconds

Generated at Sat Dec 07 21:54:31 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.