Bug #2026

RedHat service provider ignores stop

Added by Peter Meier over 1 year ago. Updated over 1 year ago.

Status:Closed Start:02/25/2009
Priority:Normal Due date:
Assignee:Puppet Community % Done:

0%

Category:service
Target version:0.24.8
Affected version:0.24.7 Branch:
Keywords:service, redhat, stop
Votes: 0

Description

A discussion [1] on the mailinglist let me test the problem. And I can confirm the dicussed problem and would say that the redhat service provider is ignoring any supplied stop command:

This is a run with latest head:

# cat foo.pp 

service{'httpd':
        stop => '/bin/false',
        ensure => stopped,
}
# puppet --debug foo.pp
info: Loading fact virtual
debug: Puppet::Type::Service::ProviderRunit: file /usr/bin/sv does not exist
debug: Puppet::Type::Service::ProviderDaemontools: file /usr/bin/svc does not exist
debug: Puppet::Type::Service::ProviderGentoo: file /sbin/rc-update does not exist
debug: Puppet::Type::Service::ProviderDebian: file /usr/sbin/update-rc.d does not exist
debug: Puppet::Type::Service::ProviderLaunchd: file /bin/launchctl does not exist
debug: Creating default schedules
debug: Service[httpd](provider=redhat): Executing 'ps -ef'
debug: Service[httpd](provider=redhat): PID is 9148
debug: //Service[httpd]: Changing ensure
debug: //Service[httpd]: 1 change(s)
debug: Puppet::Type::Service::ProviderRedhat: Executing '/sbin/service httpd stop'
notice: //Service[httpd]/ensure: ensure changed 'running' to 'stopped'
debug: Finishing transaction 23924404000140 with 1 changes

[1] http://groups.google.com/group/puppet-users/browse_thread/thread/e21a9b1e4621b58


Related issues

related to Puppet - Feature #2481: Override commands in redhat service provider Closed 08/02/2009

Associated revisions

Revision 67fc394d9ffaed89328c00678559f57418a1511d
Added by James Turnbull over 1 year ago

Fixed #2026 – Red Hat ignoring stop method

History

Updated by James Turnbull over 1 year ago

  • Status changed from Unreviewed to Needs more information
  • Assignee set to Luke Kanies

Luke – confused – if its specified stop should that override the def stop in the redhat provider with the def stop in the base provider?

Updated by Luke Kanies over 1 year ago

  • Status changed from Needs more information to Accepted
  • Assignee changed from Luke Kanies to Puppet Community

jamtur01 wrote:'

Luke – confused – if its specified stop should that override the def stop in the redhat provider with the def stop in the base provider?

Yeah, any specified ‘start’, ‘stop’, ‘status’, or ‘restart’ commands should override the defaults.

Updated by Trevor Vaughan over 1 year ago

I’ve confirmed this on 0.24.6 as well.

My current workaround is to specify the ‘base’ provider and then specify all relevant information. This is usually as simple as just specifying the commands for ‘service stop/start/etc…’.

Updated by Luke Kanies over 1 year ago

The problem here is that the redhat provider implements the ‘stop’ method instead of the ‘stopcmd’ method, thus overriding the base class’s method that uses the ‘stop’ parameter.

The short term solution is this patch:

diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb
index 031db46..f31903e 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -73,12 +73,12 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do
         end
     end
 
-    def start
-        service(@resource[:name], "start")
+    def startcmd
+        [command(:service), @resource[:name], "start"]
     end
 
-    def stop
-        service(@resource[:name], "stop")
+    def stopcmd
+        [command(:service), @resource[:name], "stop"]
     end
 
 end

The long-term solution is to change the provider/type interface so that this development is cleaner – the current method is confusing, and the mistake made in the redhat provider is both natural for the developer and for the code reviewer, which makes it hard to catch.

Can you test this patch? If it works, I’ll write up some tests for it. Please test with and without the ‘stop’ parameter specified.

Updated by James Turnbull over 1 year ago

This fixes it for me for Red Hat – pushed in commit:“67fc394d9ffaed89328c00678559f57418a1511d” in branch 0.24.x

Updated by James Turnbull over 1 year ago

  • Status changed from Accepted to Closed

Also available in: Atom PDF