From 1c56cac24399b6e6c1e42eacea043fa0950e138a Mon Sep 17 00:00:00 2001 From: Alejandro Figueroa Date: Tue, 4 Oct 2016 14:07:42 +0100 Subject: [PATCH 1/2] Remove puppet error when ACLs cannot be retrieved Currently if consul does not come up or there is some issue electing a leader, the consul_acl will throw a hard puppet error. This causes the puppet run to immediately fail. This commit changes that puppet error to a warning. The unavailability of the consul API should not cause a puppet failure. --- lib/puppet/provider/consul_acl/default.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/consul_acl/default.rb b/lib/puppet/provider/consul_acl/default.rb index 1fca1dc4..26074d91 100644 --- a/lib/puppet/provider/consul_acl/default.rb +++ b/lib/puppet/provider/consul_acl/default.rb @@ -57,7 +57,9 @@ def self.list_resources(acl_api_token, port, hostname, protocol, tries) if res.code == '200' acls = JSON.parse(res.body) else - raise(Puppet::Error,"Cannot retrieve ACLs: invalid return code #{res.code} uri: #{path} body: #{req.body}") + Puppet.warning("Cannot retrieve ACLs: invalid return code #{res.code} uri: #{path} body: #{req.body}") + $stderr.puts "Cannot retrieve ACLs: invalid return code #{res.code} uri: #{path} body: #{req.body}" + return {} end nacls = acls.collect do |acl| From 54606e389fbca52732f07a167f675e2bd5ceb170 Mon Sep 17 00:00:00 2001 From: Alejandro Figueroa Date: Tue, 4 Oct 2016 16:49:18 +0100 Subject: [PATCH 2/2] Remove stderr debugging statement --- lib/puppet/provider/consul_acl/default.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/puppet/provider/consul_acl/default.rb b/lib/puppet/provider/consul_acl/default.rb index 26074d91..eaf1f584 100644 --- a/lib/puppet/provider/consul_acl/default.rb +++ b/lib/puppet/provider/consul_acl/default.rb @@ -58,7 +58,6 @@ def self.list_resources(acl_api_token, port, hostname, protocol, tries) acls = JSON.parse(res.body) else Puppet.warning("Cannot retrieve ACLs: invalid return code #{res.code} uri: #{path} body: #{req.body}") - $stderr.puts "Cannot retrieve ACLs: invalid return code #{res.code} uri: #{path} body: #{req.body}" return {} end