summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-02-26 16:40:31 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-28 11:19:49 -0800
commit292d177a20135d25596c31fdc005ab4a999d4501 (patch)
treee343cb337d481443d89f438c9b85c44e70c518f9
parentb6647da54fd364ecedc30f082db850e7688d7315 (diff)
downloadchef-292d177a20135d25596c31fdc005ab4a999d4501.tar.gz
remove policyfile fallback API for old Chef Servers
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--RELEASE_NOTES.md4
-rw-r--r--lib/chef/node.rb7
-rw-r--r--spec/unit/node_spec.rb54
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