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

Fix weightedupdatestatus for cancellation #377

Conversation

ghost
Copy link

@ghost ghost commented Jul 27, 2018

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

@ghost
Copy link
Author

ghost commented Jul 27, 2018

@miq-bot add-label transformation
@miq-bot add-label bug
@miq-bot add-label gaprindashvili/yes
@miq-bot add-label blocker

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?
Copy link
Member

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?

Copy link
Author

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?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ;)

@miq-bot
Copy link
Member

miq-bot commented Jul 28, 2018

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
1 file checked, 0 offenses detected
Everything looks fine. 👍

@gmcculloug gmcculloug self-assigned this Jul 29, 2018
@gmcculloug gmcculloug requested a review from mkanoor July 29, 2018 12:19
@@ -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']
Copy link
Member

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

Copy link
Author

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.

[1] https://github.com/fdupont-redhat/manageiq-content/blob/865897e21452a423c6769d869af3eb256ef4774d/content/automate/ManageIQ/Transformation/StateMachines/VMTransformation.class/__class__.yaml#L14-L33

Copy link
Contributor

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.

Copy link
Author

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.

@gmcculloug gmcculloug merged commit 100d045 into ManageIQ:master Jul 30, 2018
@gmcculloug gmcculloug added this to the Sprint 91 Ending Jul 30, 2018 milestone Jul 30, 2018
@ghost ghost deleted the v2v_fix_weightedupdate_status_for_cancellation branch July 31, 2018 07:09
simaishi pushed a commit that referenced this pull request Aug 1, 2018
…atus_for_cancellation

Fix weightedupdatestatus for cancellation
(cherry picked from commit 100d045)

https://bugzilla.redhat.com/show_bug.cgi?id=1608758
@simaishi
Copy link
Contributor

simaishi commented Aug 1, 2018

Gaprindashvili backport details:

$ git log -1
commit 3a98ce68ea95d6d5e4a6468c9fa1fbd04babbcf1
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Mon Jul 30 16:50:31 2018 -0400

    Merge pull request #377 from fdupont-redhat/v2v_fix_weightedupdate_status_for_cancellation
    
    Fix weightedupdatestatus for cancellation
    (cherry picked from commit 100d045042d67455fe5e89893863b3c1f199beec)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1608758

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants