-
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
Fix weightedupdatestatus for cancellation #377
Fix weightedupdatestatus for cancellation #377
Conversation
…il? instead of .absent?
sm_uri = @handle.object['cleanup_state_machine'] | ||
if sm_uri.present? && task.get_option(:cleanup_request_id).absent? | ||
sm_uri = @handle.root['cleanup_state_machine'] | ||
if sm_uri.present? && task.get_option(:cleanup_request_id).nil? |
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 would suggest using .blank?
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.
Followed your suggestion.
@@ -137,7 +137,7 @@ def main | |||
if @handle.root['ae_state_step'] == 'on_error' | |||
task.message = 'Failed' | |||
create_cleanup_request(task) | |||
elsif task.get_option('cancel_requested') && task.get_option(:cleanup_request_id).absent? | |||
elsif task.get_option('cancel_requested') && task.get_option(:cleanup_request_id).nil? |
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.
Same
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.
Same ;)
Checked commits fabiendupont/manageiq-content@6298418~...d98f9c4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@@ -30,8 +30,8 @@ def reconcile_states_percent(path, states) | |||
end | |||
|
|||
def create_cleanup_request(task) | |||
sm_uri = @handle.object['cleanup_state_machine'] | |||
if sm_uri.present? && task.get_option(:cleanup_request_id).absent? | |||
sm_uri = @handle.root['cleanup_state_machine'] |
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.
@fdupont-redhat Can you describe this change in more detail? How is 'cleanup_state_machine' being resolved into the automate workspace?
cc @mkanoor
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.
cleanup_state_machine
is an attribute of the main state machine /Transformation/StateMachines/VMTransformation/Transformation
[1]. At first, I thought it would be an attribute of $evm.object
, but dumping both $evm.object
and $evm.root
showed it was only available as an attribute of $evm.root
. I also saw that it persists in the embedded state machines, which is good.
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.
@fdupont-redhat
The cleanup_state_machine is in the first state machine that starts which might be the root object. Then you go into nested state machines and each of the state machines ends up calling the same weightedupdatestatus method, if you are in the lower level state machines that cleanup_state_machine will not percolate down into the individual state machines, they would have their own $evm.object which would be the child state machine. You would have to check the $evm.root for this attribute or check if the weighted_status is being called from the correct state machine.
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.
Indeed cleanup_state_machine is available at the lowest level state machine, which creates the cleanup request. The parent state machines will also fail, but won't create additional requests because we check if a request already exists.
…atus_for_cancellation Fix weightedupdatestatus for cancellation (cherry picked from commit 100d045) https://bugzilla.redhat.com/show_bug.cgi?id=1608758
Gaprindashvili backport details:
|
Apparently and contrary to my tests, the attributes in a state machine are available in $evm.root and not in $evm.object. To work correctly, I grab the cleanup state machine path from $evm.root.
Also, I realized that
nil.absent?
generates an exception. Fixing that.Associated RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1599997