Skip to content

Commit

Permalink
Raise an exception when remote CCR fails
Browse files Browse the repository at this point in the history
This will help be ensuring the location of log files
that we refer to in the task failure message is quickly
available when a remote CCR fails.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
  • Loading branch information
marcparadise committed Apr 2, 2018
1 parent a602d5f commit 4d6479b
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 4d6479b

Please sign in to comment.