summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-06-22 11:21:24 -0700
committerDaniel DeLeo <dan@opscode.com>2010-06-22 11:21:24 -0700
commit56ecdbff0830f802d89549cbdf12a5163b45d4d8 (patch)
treea80dd221699020bf294346050c6f25677aa20aaa
parent6381f5cb6f29e362743101ba72ac646035999517 (diff)
downloadchef-56ecdbff0830f802d89549cbdf12a5163b45d4d8.tar.gz
[CHEF-1365] chkconfig can return exit status 1
chkconfig returns 1 when checking a service it has never seen before. This happens when the init.d script for a service has been created, but not yet enabled with chkconfig. When the redhat provider checks if the service is running, it needs to accept 1 as a valid exit code
-rw-r--r--chef/lib/chef/provider/service/redhat.rb2
-rw-r--r--chef/spec/unit/provider/service/redhat_spec.rb14
2 files changed, 3 insertions, 13 deletions
diff --git a/chef/lib/chef/provider/service/redhat.rb b/chef/lib/chef/provider/service/redhat.rb
index 07cf0daf27..4423cb34cc 100644
--- a/chef/lib/chef/provider/service/redhat.rb
+++ b/chef/lib/chef/provider/service/redhat.rb
@@ -41,7 +41,7 @@ class Chef
super
- chkconfig = shell_out!("/sbin/chkconfig --list #{@current_resource.service_name}")
+ chkconfig = shell_out!("/sbin/chkconfig --list #{@current_resource.service_name}", :returns => [0,1])
@current_resource.enabled(!!(chkconfig.stdout =~ CHKCONFIG_ON))
@current_resource
end
diff --git a/chef/spec/unit/provider/service/redhat_spec.rb b/chef/spec/unit/provider/service/redhat_spec.rb
index 53f0e7ccc0..bfdd623f94 100644
--- a/chef/spec/unit/provider/service/redhat_spec.rb
+++ b/chef/spec/unit/provider/service/redhat_spec.rb
@@ -32,16 +32,6 @@ describe "load_current_resource" do
@provider = Chef::Provider::Service::Redhat.new(@new_resource, @run_context)
Chef::Resource::Service.stub!(:new).and_return(@current_resource)
File.stub!(:exists?).and_return(true)
-
- # @status = mock("Status", :exitstatus => 0)
- # @provider.stub!(:popen4).and_return(@status)
- # @provider.should_receive(:run_command).with(:command => "/sbin/service chef status")
- # @stdin = mock("STDIN", :null_object => true)
- # @stdout = mock("STDOUT", :null_object => true)
- # @stdout_string = "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off"
- # @stdout.stub!(:gets).and_return(@stdout_string)
- # @stderr = mock("STDERR", :null_object => true)
- # @pid = mock("PID", :null_object => true)
end
it "should raise an error if /sbin/chkconfig does not exist" do
@@ -51,14 +41,14 @@ describe "load_current_resource" do
it "sets the current enabled status to true if the service is enabled for any run level" do
chkconfig = OpenStruct.new(:stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:on 6:off")
- @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef").and_return(chkconfig)
+ @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
@provider.load_current_resource
@current_resource.enabled.should be_true
end
it "sets the current enabled status to false if the regex does not match" do
chkconfig = OpenStruct.new(:stdout => "chef 0:off 1:off 2:off 3:off 4:off 5:off 6:off")
- @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef").and_return(chkconfig)
+ @provider.should_receive(:shell_out!).with("/sbin/chkconfig --list chef", :returns => [0,1]).and_return(chkconfig)
@provider.load_current_resource.should eql(@current_resource)
@current_resource.enabled.should be_false
end