summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-08-28 12:20:13 -0700
committerGitHub <noreply@github.com>2019-08-28 12:20:13 -0700
commit632a4163d723ca4a7382a0701a3982479dff882b (patch)
tree0b6a54c7f66436c8fa59220a5b7c45ae40830783
parentdd0009d7e77f192cadb1632f2159a6dbc880980f (diff)
parentd3017b5d83c75cb7eb4de45e37f391c0c171305d (diff)
downloadchef-632a4163d723ca4a7382a0701a3982479dff882b.tar.gz
Merge pull request #6777 from chef/revert-6776-revert-6766-lcg/windows-interval
Fail on interval runs on windows as interval runs on Windows don't entirely work
-rw-r--r--lib/chef/application/base.rb7
-rw-r--r--lib/chef/application/client.rb8
-rw-r--r--lib/chef/application/solo.rb8
-rw-r--r--spec/unit/application/client_spec.rb11
-rw-r--r--spec/unit/application/solo_spec.rb11
-rw-r--r--spec/unit/application_spec.rb2
6 files changed, 29 insertions, 18 deletions
diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb
index fea3d844ce..c5bff9874e 100644
--- a/lib/chef/application/base.rb
+++ b/lib/chef/application/base.rb
@@ -340,6 +340,13 @@ class Chef::Application::Base < Chef::Application
private
+ def windows_interval_error_message
+ "Windows #{Chef::Dist::PRODUCT} interval runs are not supported in #{Chef::Dist::PRODUCT} 15 and later." +
+ "\nConfiguration settings:" +
+ ("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
+ "\nPlease manage #{Chef::Dist::PRODUCT} as a scheduled task instead."
+ end
+
def unforked_interval_error_message
"Unforked #{Chef::Dist::PRODUCT} interval runs are disabled by default." +
"\nConfiguration settings:" +
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 0fc5ca7711..890ecbd385 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -128,8 +128,12 @@ class Chef::Application::Client < Chef::Application::Base
Chef::Config[:client_fork] = !!Chef::Config[:interval]
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]
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index bce95c2841..da9ec7f566 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -102,7 +102,13 @@ class Chef::Application::Solo < Chef::Application::Base
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[: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 =~ %r{/cookbooks/*$} }
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 0773fc70fd..d4ed403197 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-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,7 +85,6 @@ describe Chef::Application::Client, "reconfigure" do
allow(app).to receive(:trap)
allow(app).to receive(:configure_logging).and_return(true)
- Chef::Config[:interval] = 10
Chef::Config[:once] = false
@@ -162,7 +161,7 @@ describe Chef::Application::Client, "reconfigure" do
it_behaves_like "sets the configuration", "--no-fork", client_fork: false
end
- context "with an interval" do
+ context "with an interval", :unix_only do
it_behaves_like "sets the configuration", "--interval 1800", client_fork: true
end
@@ -322,7 +321,7 @@ describe Chef::Application::Client, "reconfigure" do
Chef::Config[:splay] = nil
end
- it "should terminal with message when interval is given" do
+ it "should terminate 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(
@@ -340,8 +339,8 @@ Enable .* interval runs by setting `:client_fork = true` in your config file or
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 3f540d24e2..b70f959ab5 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
-# Copyright:: Copyright 2008-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -64,18 +64,13 @@ describe Chef::Application::Solo do
end
it "should terminate with message" do
- expect(Chef::Application).to receive(:fatal!).with(
- /Unforked .* interval runs are disabled by default\.
-Configuration settings:
- interval = 600 seconds
-Enable .* interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options\./
- )
+ expect(Chef::Application).to receive(:fatal!).with(/interval runs are (disabled|not supported)/)
app.reconfigure
end
end
end
- describe "when in daemonized mode and no interval has been set" do
+ describe "when in daemonized mode and no interval has been set", :unix_only do
before do
Chef::Config[:daemonize] = true
end
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index e94f9b74ae..7a787d1f3f 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
# Author:: Mark Mzyk (mmzyk@chef.io)
-# Copyright:: Copyright 2008-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");