summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/application/client.rb17
-rw-r--r--lib/chef/application/solo.rb21
-rw-r--r--spec/unit/application/client_spec.rb6
-rw-r--r--spec/unit/application/solo_spec.rb4
4 files changed, 36 insertions, 12 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 32530925d5..f839ef25df 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -2,7 +2,7 @@
# Author:: AJ Christensen (<aj@chef.io)
# Author:: Christopher Brown (<cb@chef.io>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -360,8 +360,12 @@ class Chef::Application::Client < Chef::Application
Chef::Config[:splay] = nil
end
- if !Chef::Config[:client_fork] && Chef::Config[:interval] && !Chef::Platform.windows?
- Chef::Application.fatal!(unforked_interval_error_message)
+ if Chef::Config[:interval]
+ if Chef::Platform.windows?
+ Chef::Application.fatal!(windows_interval_error_message)
+ elsif !Chef::Config[:client_fork]
+ Chef::Application.fatal!(unforked_interval_error_message)
+ end
end
if Chef::Config[:json_attribs]
@@ -508,6 +512,13 @@ class Chef::Application::Client < Chef::Application
end
end
+ def windows_interval_error_message
+ "Windows chef-client interval runs are disabled in Chef 14." +
+ "\nConfiguration settings:" +
+ "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ "\nPlease install chef-client as a Windows service or scheduled task instead."
+ end
+
def unforked_interval_error_message
"Unforked chef-client interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 6b4aef42b4..b255951e3f 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@chef.io>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2018, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -261,7 +261,13 @@ class Chef::Application::Solo < Chef::Application
Chef::Config[:interval] ||= 1800
end
- Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
+ if Chef::Config[:interval]
+ if Chef::Platform.windows?
+ Chef::Application.fatal!(windows_interval_error_message)
+ elsif !Chef::Config[:client_fork]
+ Chef::Application.fatal!(unforked_interval_error_message)
+ end
+ end
if Chef::Config[:recipe_url]
cookbooks_path = Array(Chef::Config[:cookbook_path]).detect { |e| Pathname.new(e).cleanpath.to_s =~ /\/cookbooks\/*$/ }
@@ -363,10 +369,17 @@ EOH
end
end
+ def windows_interval_error_message
+ "Windows chef-solo interval runs are disabled in Chef 14." +
+ "\nConfiguration settings:" +
+ "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ "\nPlease install chef-solo as a Windows service or scheduled task instead."
+ end
+
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked chef-solo interval runs are disabled in Chef 12." +
"\nConfiguration settings:" +
"#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nEnable chef-solo interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
end
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 825a4e7aac..4f1558267e 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -209,8 +209,8 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
allow(ChefConfig).to receive(:windows?).and_return(true)
end
- it "should not terminate" do
- expect(Chef::Application).not_to receive(:fatal!)
+ it "should terminate" do
+ expect(Chef::Application).to receive(:fatal!)
app.reconfigure
end
end
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 5b9dbeaafd..f613cd956d 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -69,10 +69,10 @@ describe Chef::Application::Solo do
it "should terminate with message" do
expect(Chef::Application).to receive(:fatal!).with(
- "Unforked chef-client interval runs are disabled in Chef 12.
+ "Unforked chef-solo 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."
+Enable chef-solo interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
)
app.reconfigure
end