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

job_finished_message should indicate overall playbook status #745

Merged
merged 1 commit into from
Jun 12, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def task_status(host_task, host_name)

def report_job_progress(invocation_status)
generator = InsightsCloud::Generators::PlaybookProgressGenerator.new(correlation_id)
all_hosts_success = true

invocation_status.each do |host_name, status|
# skip host if the host already reported that it's finished
Expand All @@ -151,9 +152,10 @@ def report_job_progress(invocation_status)
if status['state'] == 'stopped'
generator.host_finished_message(host_name, status['exit_status'])
status['report_done'] = true
all_hosts_success &&= status['exit_status'] == 0
end
end
generator.job_finished_message if done?(invocation_status)
generator.job_finished_message(all_hosts_success) if done?(invocation_status)

send_report(generator.generate)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/insights_cloud/generators/playbook_progress_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def host_finished_message(host_name, exit_code)
}
end

def job_finished_message
def job_finished_message(success)
@messages << {
"type": "playbook_run_completed",
"version": 3,
"correlation_id": correlation_id,
"status": "success",
"status": success ? 'success' : 'failure',
}
end

Expand Down
2 changes: 1 addition & 1 deletion test/unit/playbook_progress_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PlaybookProgressGeneratorTest < ActiveSupport::TestCase
end

test 'Outputs job finished message' do
@generator.job_finished_message
@generator.job_finished_message(true)

actual = @generator.generate
actual_message = JSON.parse(actual)
Expand Down