From 9e5179261e250900a28d0eaffcc51681bc92b649 Mon Sep 17 00:00:00 2001 From: Serdar Sutay Date: Mon, 8 Dec 2014 18:49:23 -0800 Subject: Merge pull request #2572 from opscode/sersut/win-fork-interval Fix windows service when :interval is set Conflicts: CHANGELOG.md --- CHANGELOG.md | 1 + lib/chef/application/client.rb | 4 +++- spec/unit/application/client_spec.rb | 12 ++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b2f9c7ff..2f7840332a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * [Issue 2552](https://github.com/opscode/chef/issues/2552) Create constant for LWRP before calling `provides` * [Issue 2545](https://github.com/opscode/chef/issues/2545) `path` attribute of `execute` resource is restored to provide backwards compatibility with Chef 11. * [Issue 2565](https://github.com/opscode/chef/issues/2565) Fix `Chef::Knife::Core::BootstrapContext` constructor for knife-windows compat. +* [Issue 2566](https://github.com/opscode/chef/issues/2566) 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 ee91e67256..a91209cfee 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 -- cgit v1.2.1