Skip to content

Commit

Permalink
Merge pull request #44 from chef/mp/raise-error-on-converge-fail
Browse files Browse the repository at this point in the history
Raise an exception when remote CCR fails
  • Loading branch information
marcparadise authored Apr 2, 2018
2 parents a602d5f + 4d6479b commit 4ddfa46
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/chef-workstation/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ GIT
PATH
remote: .
specs:
chef-workstation (0.1.19)
chef-workstation (0.1.21)
mixlib-cli
mixlib-config
mixlib-install
Expand Down
6 changes: 6 additions & 0 deletions components/chef-workstation/i18n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ errors:
Please verify the host name or address is correct and that the host is
reachable before trying again.
# Remote chef client run failure start here.
CHEFCCR001: |
The converge of the remote host failed.
Please examine the log file below for a detailed cause of failure.
footer:
both: |
If you are not able to resolve this issue, please contact Chef support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def perform_action
ChefWorkstation::Log.error("stdout: #{c.stdout}")
ChefWorkstation::Log.error("stderr: #{c.stderr}")
end
raise RemoteChefClientRunFailed.new
end
end

Expand All @@ -57,5 +58,8 @@ def create_apply_args
apply_args += "\""
end

class RemoteChefClientRunFailed < ChefWorkstation::Error
def initialize(); super("CHEFCCR001"); end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@
let(:result) { double("command result", exit_status: 1) }
let(:stacktrace_result) { double("stacktrace scrape result", exit_status: 0, stdout: "") }

it "scrapes the remote log" do
it "scrapes the remote log and raises" do
expect(reporter).to receive(:error).with(/converge/)
expect(connection).to receive(:run_command).with(/chef-stacktrace/).and_return(stacktrace_result)
expect(connection).to receive(:run_command).with(/del/).and_return(stacktrace_result)
action.perform_action
expect { action.perform_action }.to raise_error ChefWorkstation::Action::ConvergeTarget::RemoteChefClientRunFailed
end

context "when remote log cannot be retrieved" do
let(:stacktrace_result) { double("stacktrace scrape result", exit_status: 1, stdout: "", stderr: "") }
it "logs results from the attempt" do
it "logs results from the attempt and raises" do
expect(reporter).to receive(:error).with(/converge/)
expect(connection).to receive(:run_command).with(/chef-stacktrace/).and_return(stacktrace_result)
action.perform_action
expect { action.perform_action }.to raise_error ChefWorkstation::Action::ConvergeTarget::RemoteChefClientRunFailed
end
end
end
Expand Down

0 comments on commit 4ddfa46

Please sign in to comment.