diff options
-rw-r--r-- | RELEASE_NOTES.md | 4 | ||||
-rw-r--r-- | lib/chef/node.rb | 7 | ||||
-rw-r--r-- | spec/unit/node_spec.rb | 54 |
3 files changed, 9 insertions, 56 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 12c3fd8a8d..72ffa0d47e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -41,3 +41,7 @@ not deterministic or easy to intuit behavior. This change is most likely to only affect internals of tooling like chefspec if it affects anything at all. +### PolicyFile failback to create non-policyfile nodes on Chef Server < 12.3 has been removed + +PolicyFile users on Chef-13 should be using Chef Server 12.3 or higher + diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 808fb1dc6e..66527a2a37 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -2,7 +2,7 @@ # Author:: Christopher Brown (<cb@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -599,11 +599,6 @@ class Chef rescue Net::HTTPServerException => e if e.response.code == "404" chef_server_rest.post("nodes", data_for_save) - # Chef Server before 12.3 rejects node JSON with 'policy_name' or - # 'policy_group' keys, but 'policy_name' will be detected first. - # Backcompat can be removed in 13.0 - elsif e.response.code == "400" && e.response.body.include?("Invalid key policy_name") - save_without_policyfile_attrs else raise end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index ac227c5479..7dc7dd2380 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1657,55 +1657,9 @@ describe Chef::Node do end - context "on Chef Client 13 and later" do - - # Though we normally attempt to provide compatibility with chef - # server one major version back, policyfiles were beta when we - # added the policyfile attributes to the node JSON, therefore - # policyfile users need to be on 12.3 minimum when upgrading Chef - # Client to 13+ - it "lets the 400 pass through", chef: ">= 13" do - expect { node.save }.to raise_error(http_exception) - end - - end - - context "when the node exists" do - - it "falls back to saving without policyfile attributes" do - expect(@rest).to receive(:put).with("nodes/example-node", node.for_json).and_raise(http_exception) - expect(@rest).to receive(:put).with("nodes/example-node", trimmed_node).and_return(@node) - expect { node.save }.to_not raise_error - end - - end - - context "when the node doesn't exist" do - - let(:response_404) do - Net::HTTPResponse.send(:response_class, "404").new("1.0", "404", "Not Found") - end - - let(:http_exception_404) do - begin - response_404.error! - rescue => e - e - end - end - - it "falls back to saving without policyfile attributes" do - expect(@rest).to receive(:put).with("nodes/example-node", node.for_json).and_raise(http_exception) - expect(@rest).to receive(:put).with("nodes/example-node", trimmed_node).and_raise(http_exception_404) - expect(@rest).to receive(:post).with("nodes", trimmed_node).and_return(@node) - node.save - end - - it "creates the node without policyfile attributes" do - expect(@rest).to receive(:post).with("nodes", node.for_json).and_raise(http_exception) - expect(@rest).to receive(:post).with("nodes", trimmed_node).and_return(@node) - node.create - end + it "lets the 400 pass through" do + expect(@rest).to receive(:put).and_raise(http_exception) + expect { node.save }.to raise_error(http_exception) end end |