summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc A. Paradise <marcparadise@users.noreply.github.com>2022-08-09 19:17:36 +0000
committerGitHub <noreply@github.com>2022-08-09 19:17:36 +0000
commitf42d86026505c058a9bcc1c46ad13ce2710ca825 (patch)
treef0bc5f74940a658148e7b1af5911065e9e8f27f2
parent042a25badeca5e4a87f157b6bdbd6a32499d1c7b (diff)
parentc370e12b76d92ad48a6f751ec5e95a574c344ba6 (diff)
downloadchef-f42d86026505c058a9bcc1c46ad13ce2710ca825.tar.gz
Merge pull request #13095 from Stromweld/patch-1
fix chef_client_scheduled_task splay to accept 0
-rw-r--r--lib/chef/resource/chef_client_cron.rb2
-rw-r--r--lib/chef/resource/chef_client_launchd.rb2
-rw-r--r--lib/chef/resource/chef_client_scheduled_task.rb2
-rw-r--r--lib/chef/run_context.rb2
-rw-r--r--spec/unit/resource/chef_client_cron_spec.rb5
-rw-r--r--spec/unit/resource/chef_client_launchd_spec.rb5
-rw-r--r--spec/unit/resource/chef_client_scheduled_task_spec.rb5
-rw-r--r--spec/unit/resource/chef_client_systemd_timer_spec.rb2
8 files changed, 20 insertions, 5 deletions
diff --git a/lib/chef/resource/chef_client_cron.rb b/lib/chef/resource/chef_client_cron.rb
index 26894c5ae3..b5014a368d 100644
--- a/lib/chef/resource/chef_client_cron.rb
+++ b/lib/chef/resource/chef_client_cron.rb
@@ -98,7 +98,7 @@ class Chef
property :splay, [Integer, String],
default: 300,
coerce: proc { |x| Integer(x) },
- callbacks: { "should be a positive number" => proc { |v| v > 0 } },
+ callbacks: { "should be a positive number" => proc { |v| v >= 0 } },
description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time."
property :mailto, String,
diff --git a/lib/chef/resource/chef_client_launchd.rb b/lib/chef/resource/chef_client_launchd.rb
index 1016ea4d49..035f2353b7 100644
--- a/lib/chef/resource/chef_client_launchd.rb
+++ b/lib/chef/resource/chef_client_launchd.rb
@@ -60,7 +60,7 @@ class Chef
property :splay, [Integer, String],
default: 300,
coerce: proc { |x| Integer(x) },
- callbacks: { "should be a positive number" => proc { |v| v > 0 } },
+ callbacks: { "should be a positive number" => proc { |v| v >= 0 } },
description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time."
property :accept_chef_license, [true, false],
diff --git a/lib/chef/resource/chef_client_scheduled_task.rb b/lib/chef/resource/chef_client_scheduled_task.rb
index 422881deb8..f04598cdc6 100644
--- a/lib/chef/resource/chef_client_scheduled_task.rb
+++ b/lib/chef/resource/chef_client_scheduled_task.rb
@@ -107,7 +107,7 @@ class Chef
property :splay, [Integer, String],
coerce: proc { |x| Integer(x) },
- callbacks: { "should be a positive number" => proc { |v| v > 0 } },
+ callbacks: { "should be a positive number" => proc { |v| v >= 0 } },
description: "A random number of seconds between 0 and X to add to interval so that all #{ChefUtils::Dist::Infra::CLIENT} commands don't execute at the same time.",
default: 300
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index be7b787fcc..11bfc6e3c6 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -414,7 +414,7 @@ class Chef
MissingCookbookDependency:
Recipe `#{recipe_name}` is not in the run_list, and cookbook '#{cookbook_name}'
is not a dependency of any cookbook in the run_list. To load this recipe,
- first add a dependency of the cookbook '#{cookbook_name}' into the metadata
+ first add a dependency of the cookbook '#{cookbook_name}' into the metadata
of the cookbook which depends on '#{cookbook_name}'.
ERROR_MESSAGE
end
diff --git a/spec/unit/resource/chef_client_cron_spec.rb b/spec/unit/resource/chef_client_cron_spec.rb
index b738a20a3a..cc72c38a39 100644
--- a/spec/unit/resource/chef_client_cron_spec.rb
+++ b/spec/unit/resource/chef_client_cron_spec.rb
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientCron do
expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
+ it "set splay to 0" do
+ resource.splay "0"
+ expect(resource.splay).to eql(0)
+ end
+
it "builds a default value for chef_binary_path dist values" do
expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client")
end
diff --git a/spec/unit/resource/chef_client_launchd_spec.rb b/spec/unit/resource/chef_client_launchd_spec.rb
index 1d0015cb0d..93d56a784e 100644
--- a/spec/unit/resource/chef_client_launchd_spec.rb
+++ b/spec/unit/resource/chef_client_launchd_spec.rb
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientLaunchd do
expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
+ it "set splay to 0" do
+ resource.splay "0"
+ expect(resource.splay).to eql(0)
+ end
+
it "builds a default value for chef_binary_path dist values" do
expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client")
end
diff --git a/spec/unit/resource/chef_client_scheduled_task_spec.rb b/spec/unit/resource/chef_client_scheduled_task_spec.rb
index bf165d4b70..45ed8c0602 100644
--- a/spec/unit/resource/chef_client_scheduled_task_spec.rb
+++ b/spec/unit/resource/chef_client_scheduled_task_spec.rb
@@ -43,6 +43,11 @@ describe Chef::Resource::ChefClientScheduledTask do
expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed)
end
+ it "set splay to 0" do
+ resource.splay "0"
+ expect(resource.splay).to eql(0)
+ end
+
it "coerces frequency_modifier to an Integer" do
resource.frequency_modifier "10"
expect(resource.frequency_modifier).to eql(10)
diff --git a/spec/unit/resource/chef_client_systemd_timer_spec.rb b/spec/unit/resource/chef_client_systemd_timer_spec.rb
index dfe01973fb..5fe4e80146 100644
--- a/spec/unit/resource/chef_client_systemd_timer_spec.rb
+++ b/spec/unit/resource/chef_client_systemd_timer_spec.rb
@@ -105,4 +105,4 @@ describe Chef::Resource::ChefClientSystemdTimer do
expect(provider.service_content["Service"]["CPUQuota"]).to eq(50)
end
end
-end \ No newline at end of file
+end