summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-12-08 18:49:23 -0800
committerSerdar Sutay <serdar@opscode.com>2014-12-08 18:49:23 -0800
commit870febcea33c655842234ceec55b02d4306bbed7 (patch)
treebe91663e35261b8cea59080bcb6f1a512fcc7de4
parentb45a80c61a9d89ddf0d0167c74ecea0abd5fda96 (diff)
parent61e4c8ac0952577c4a449bd8e590c32ff471b9f8 (diff)
downloadchef-870febcea33c655842234ceec55b02d4306bbed7.tar.gz
Merge pull request #2572 from opscode/sersut/win-fork-interval
Fix windows service when :interval is set
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/chef/application/client.rb4
-rw-r--r--spec/unit/application/client_spec.rb12
3 files changed, 16 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 053edee359..f3048de547 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,7 @@
* Added deprecation warnings around the use of command attribute in script resources
* `path` attribute of `execute` resource is restored to provide backwards compatibility with Chef 11.
* Fix `Chef::Knife::Core::BootstrapContext` constructor for knife-windows compat.
+* Make sure Client doesn't raise error when interval is set on Windows.
## 12.0.0
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 5463f504bc..295dc2470e 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -272,7 +272,9 @@ class Chef::Application::Client < Chef::Application
Chef::Config[:splay] = nil
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[:json_attribs]
config_fetcher = Chef::ConfigFetcher.new(Chef::Config[:json_attribs])
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index 38e051e269..4e33565d9e 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -63,6 +63,18 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config
end
end
+ context "when interval is given on windows" do
+ before do
+ Chef::Config[:interval] = 600
+ allow(Chef::Platform).to receive(:windows?).and_return(true)
+ end
+
+ it "should not terminate" do
+ expect(Chef::Application).not_to receive(:fatal!)
+ @app.reconfigure
+ end
+ end
+
context "when configured to run once" do
before do
Chef::Config[:once] = true