-
Notifications
You must be signed in to change notification settings - Fork 97
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
Fixes #26355 - background template rendering #414
Fixes #26355 - background template rendering #414
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ezr-ondrej! I know it's WIP, but I'd rather review it ASAP, so you have something to begin with :)
See inline comments, otherwise everything looks fine. Also, there is need to upgrade our apidoc data (test/data/1.21.1 or 1.22
) for newer version of Foreman so your tests can pass (I've tried it locally and they seemed to be passing).
c1036e1
to
8c525ed
Compare
Thanks for the pushes in right direction @ofedoren I believe it is ready, as of foreman PR were merged. |
@ezr-ondrej I think you can do 1.22 from current foreman develop. If there is anything else that will slip in last minute in 1.22 and it is needed for testing in hammer we can always update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @mbacovsky and I'm sure you know how to do it, but if not here's readme: https://github.com/theforeman/hammer-cli-foreman/tree/master/test/data (if I'm not mistaken we generate data without Katello plugin, but pure Foreman).
Also, see the last notes inline :)
if option_wait? | ||
poll_for_report(data) | ||
else | ||
puts data['job_id'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Printing job id only is not very user-friendly approach to tell user what's happening now, isn't it? I mean, what do you think about doing something like print_message(_('The report has been scheduled. Job ID: %{job_id}') % { job_id: data['job_id'] })
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds much more useful 👍 thanks.
response = send_request | ||
if response.code == 204 | ||
print_message(_('The report is not ready yet.')) | ||
return HammerCLI::EX_OK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: you can lower this statement to the end of the method and remove return
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 👍
else | ||
puts response.body | ||
end | ||
return HammerCLI::EX_OK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: redundant return
.
def handle_success(response) | ||
if option_path | ||
filepath = store_response(response) | ||
print_message(_('The response has been saved to %{path}s.'), {:path => filepath}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant s
at the end of the sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 👍
adb6039
to
7dd5547
Compare
7dd5547
to
746b08d
Compare
def execute | ||
response = send_request | ||
if response.code == 204 | ||
print_message(_('The report is not ready yet.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some Exit code to suggest that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I could suggest HammerCLI::EX_RETRY
but I'm sure it will flood the terminal with that message in some cases, which is not quite good. HammerCLI::EX_OK
is good enough for it. If you meant something else, ping me on irc (ofedoren) so we can merge it today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EX_RETRY
will lead in re-executing the command again which in the end will make hammer loop here till the report is delivered. If this is not what we want I'd suggest to look at https://github.com/theforeman/hammer-cli/blob/master/lib/hammer_cli/exit_codes.rb
EX_TEMPFAIL
may be a good candidate. From certain perspective (expected result, no error) the EX_OK
is fine too if no better option is found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I have rolled out with EX_TEMPFAIL 👍 Thank you both for advises!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's ready to merge if you're ready :)
@ofedoren I believe it is ready :) |
I'm also ready :-) could this be merged please @ofedoren :-) |
@ares. sure :) @ezr-ondrej. merging then, thanks! :) |
I have added scheduling, so you can schedule report and download it once it is ready through second command.
The
schedule
command has--wait
option, which will wait for the result actively.