summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-12-09 00:10:22 -0800
committerSerdar Sutay <serdar@opscode.com>2014-12-09 00:10:22 -0800
commit5bd1fc9ff743effbd20c76dcd279d936b1a24332 (patch)
tree79fef28b4040a97e93b4393e5e17d4c8b288d088
parenta5a032186b2c1ba360f82f2c71ef013e80a67b99 (diff)
parenta8fe2914910c47177b4d2125ea181be1fd52d139 (diff)
downloadchef-5bd1fc9ff743effbd20c76dcd279d936b1a24332.tar.gz
Merge pull request #2576 from opscode/sersut/backport-12.0.1
Backport bug fixes for 12.0.1.
-rw-r--r--CHANGELOG.md4
-rw-r--r--lib/chef/application/client.rb4
-rw-r--r--lib/chef/event_loggers/windows_eventlog.rb8
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb2
-rw-r--r--lib/chef/resource/execute.rb11
-rw-r--r--spec/support/shared/unit/execute_resource.rb6
-rw-r--r--spec/unit/application/client_spec.rb12
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb4
8 files changed, 46 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 721a992f5d..9b2451361b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
## 12.0.1
* [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.
+* [Issue 2560](https://github.com/opscode/chef/issues/2560) Fix `uninitialized constant Windows::Constants` in `windows_eventlog`.
## 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/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb
index 6d45d4fab4..6f5ef627fb 100644
--- a/lib/chef/event_loggers/windows_eventlog.rb
+++ b/lib/chef/event_loggers/windows_eventlog.rb
@@ -20,9 +20,11 @@ require 'chef/event_loggers/base'
require 'chef/platform/query_helpers'
if Chef::Platform::windows? and not Chef::Platform::windows_server_2003?
- [:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
- # These are redefined in 'win32/eventlog'
- Windows::Constants.send(:remove_const, c)
+ if defined? Windows::Constants
+ [:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c|
+ # These are redefined in 'win32/eventlog'
+ Windows::Constants.send(:remove_const, c) if Windows::Constants.const_defined? c
+ end
end
require 'win32/eventlog'
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index e681d7a49b..3833182c70 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -30,7 +30,7 @@ class Chef
#
class BootstrapContext
- def initialize(config, run_list, chef_config, secret)
+ def initialize(config, run_list, chef_config, secret = nil)
@config = config
@run_list = run_list
@chef_config = chef_config
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 980035b079..4fbaaf93ab 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -36,6 +36,7 @@ class Chef
@cwd = nil
@environment = nil
@group = nil
+ @path = nil
@returns = 0
@timeout = nil
@user = nil
@@ -94,6 +95,16 @@ class Chef
)
end
+ def path(arg=nil)
+ Chef::Log.warn "'path' attribute of 'execute' is not used by any provider in Chef 11 and Chef 12. Use 'environment' attribute to configure 'PATH'. This attribute will be removed in Chef 13."
+
+ set_or_return(
+ :path,
+ arg,
+ :kind_of => [ Array ]
+ )
+ end
+
def returns(arg=nil)
set_or_return(
:returns,
diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb
index 298e0c5baf..104aa7694e 100644
--- a/spec/support/shared/unit/execute_resource.rb
+++ b/spec/support/shared/unit/execute_resource.rb
@@ -76,6 +76,12 @@ shared_examples_for "an execute resource" do
@resource.group.should eql(1)
end
+ it "should accept an array for the execution path in Chef-12 and log deprecation message" do
+ expect(Chef::Log).to receive(:warn).at_least(:once)
+ @resource.path ["woot"]
+ expect(@resource.path).to eql(["woot"])
+ end
+
it "should accept an integer for the return code" do
@resource.returns 1
@resource.returns.should eql(1)
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
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index cd53088419..6f7adfcf57 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -34,6 +34,10 @@ describe Chef::Knife::Core::BootstrapContext do
subject(:bootstrap_context) { described_class.new(config, run_list, chef_config, secret) }
+ it "initializes with Chef 11 parameters" do
+ expect{described_class.new(config, run_list, chef_config)}.not_to raise_error
+ end
+
it "runs chef with the first-boot.json in the _default environment" do
bootstrap_context.start_chef.should eq "chef-client -j /etc/chef/first-boot.json -E _default"
end