Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an exception when remote CCR fails #44

Merged
merged 1 commit into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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