-
Notifications
You must be signed in to change notification settings - Fork 120
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
Added log_and_exit utility method #414
Conversation
@bdunne |
# | ||
def self.log_and_exit(msg, exit_code, handle = $evm) | ||
handle.log('info', "Script ending #{msg} code : #{exit_code}") | ||
exit(exit_code) |
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.
@billfitzgerald0120 @mkanoor Is the goal of this method to replace call in our existing model, like:
ManageIQ/AutomationManagement/AnsibleTower/Operations/StateMachines/Job/wait_for_completion.rb#L48
and
ManageIQ/Cloud/VM/Provisioning/StateMachines/VMProvision_VM/update_provision_status.rb#L9
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.
@gmcculloug we recently fixed a bug in how MIQ_STOP can be used to a state machine which requires us to use the exit system call. Till now we have refrained from using exits in the newer methods because that causes the spec to exit. This is more a way to ensure we can test methods with exit in them.
@mkanoor It looks like you have a "Fix rubocop" commit, can you squash that? |
Checked commit mkanoor@a3a7d61 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 spec/content/automate/ManageIQ/System/CommonMethods/Utils.class/methods/log_object_spec.rb
|
I forget why we need to call |
@bdunne These are external customer written scripts that call the exit at many different points in their code, the exit(rc) naturally flows back thru the exit status exit is a normal way for customers to end their scripts |
Okay, well the post script will re-raise SystemExit, so I don't see any problems |
This utility method allows a user to log and exit with a single method call.
It also tests the exit call from a spec