summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-04-17 20:22:34 -0700
committerTim Smith <tsmith@chef.io>2019-04-17 21:07:02 -0700
commitc3c6938d632a6435a387273671be029103cbd8c8 (patch)
tree53ef13734264b524549523f91d084b0650411864
parentbea342daed755aff8b31d7cc3a6f3ad9e438ec92 (diff)
downloadchef-c3c6938d632a6435a387273671be029103cbd8c8.tar.gz
Allow unforked interval runs on Windows in solounforked_intervals
This matches the behavior of chef-client. I also updated the messaging since no one cares that we allowed it in Chef 11. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/application/client.rb2
-rw-r--r--lib/chef/application/solo.rb6
-rw-r--r--spec/unit/application/client_spec.rb2
-rw-r--r--spec/unit/application/solo_spec.rb24
4 files changed, 22 insertions, 12 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 789b938213..1fd87ff7ec 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -503,7 +503,7 @@ class Chef::Application::Client < Chef::Application
end
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked chef-client interval runs are only supported on Windows." +
"\nConfiguration settings:" +
("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
"\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index ee2509e821..3a2ca5c403 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -265,7 +265,9 @@ class Chef::Application::Solo < Chef::Application
Chef::Config[:client_fork] = !!Chef::Config[:interval]
end
- Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
+ if !Chef::Config[:client_fork] && Chef::Config[:interval] && !Chef::Platform.windows?
+ Chef::Application.fatal!(unforked_interval_error_message)
+ end
if Chef::Config[:recipe_url]
cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| Pathname.new(e).cleanpath.to_s =~ /\/cookbooks\/*$/ }
@@ -365,7 +367,7 @@ class Chef::Application::Solo < Chef::Application
end
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked chef-client interval runs are only supported on Windows" +
"\nConfiguration settings:" +
("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
"\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index f971848c5b..628d21f58d 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -326,7 +326,7 @@ describe Chef::Application::Client, "reconfigure" do
Chef::Config[:interval] = 600
allow(ChefConfig).to receive(:windows?).and_return(false)
expect(Chef::Application).to receive(:fatal!).with(
- "Unforked chef-client interval runs are disabled in Chef 12.
+ "Unforked chef-client interval runs are only supported on Windows..
Configuration settings:
interval = 600 seconds
Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 939300b7e4..ec49f668b4 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -57,18 +57,26 @@ describe Chef::Application::Solo do
Chef::Config[:splay] = nil
end
- context "when interval is given" do
+ it "should terminal with message when interval is given" do
+ Chef::Config[:interval] = 600
+ allow(ChefConfig).to receive(:windows?).and_return(false)
+ expect(Chef::Application).to receive(:fatal!).with(
+ "Unforked chef-client interval runs are only supported on Windows.
+Configuration settings:
+ interval = 600 seconds
+Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ )
+ app.reconfigure
+ end
+
+ context "when interval is given on windows" do
before do
Chef::Config[:interval] = 600
+ allow(ChefConfig).to receive(:windows?).and_return(true)
end
- it "should terminate with message" do
- expect(Chef::Application).to receive(:fatal!).with(
- "Unforked chef-client interval runs are disabled in Chef 12.
-Configuration settings:
- interval = 600 seconds
-Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
- )
+ it "should not terminate" do
+ expect(Chef::Application).not_to receive(:fatal!)
app.reconfigure
end
end