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

[WIP] [V2V] Add state machine support for collapse snapshots #19139

Closed
wants to merge 19 commits into from
Closed

[WIP] [V2V] Add state machine support for collapse snapshots #19139

wants to merge 19 commits into from

Conversation

djberg96
Copy link
Contributor

@djberg96 djberg96 commented Aug 12, 2019

For IMS 1.3 we're moving state machine handling from automate into core. For ease of writing and review, we're breaking this down into (hopefully) easily digestible bits, one state at a time. Each PR will ultimately have a corresponding PR in manageiq-content that deletes the relevant bit of code from automate.

Original automate code: https://github.com/ManageIQ/manageiq-content/blob/master/content/automate/ManageIQ/Transformation/Infrastructure/VM/Common.class/__methods__/collapsesnapshots.rb

Since this is the first thing that needs to happen, we're starting with snapshot collapse, i.e. deletion.

WIP for now until I get specs added and task information updated for the sake of the UI team.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1740881
Depends on: https://bugzilla.redhat.com/show_bug.cgi?id=1741179

Will also need #19149

@miq-bot miq-bot added the wip label Aug 12, 2019
@djberg96
Copy link
Contributor Author

djberg96 commented Aug 13, 2019

@fdupont-redhat How's this look? I wasn't sure what the difference was between update_attribute and the update_migration_task method you proposed in your original PR.

It looks to me like the update_attribute method updates the underlying MiqRequestTask object. Isn't that what we want?

@djberg96
Copy link
Contributor Author

@miq-bot add_reviewer @fdupont-redhat

@miq-bot
Copy link
Member

miq-bot commented Aug 14, 2019

@djberg96 'fdupont-redhat' is an invalid reviewer, ignoring...

@ghost
Copy link

ghost commented Aug 14, 2019

@djberg96 could you please make it async now that #19150 is merge. The transitions should be updated to allow transitioning from collapsing_snapshots to collapsing_snapshots. I think that a timeout of 4 hours should be enough.

@djberg96
Copy link
Contributor Author

@fdupont-redhat Updated. Wasn't sure about the userid, so I went went the userid of the migration task. Let me know if that (or anything else) needs changing.

end

handover_to_automate
queue_signal(:poll_conversion)
Copy link

Choose a reason for hiding this comment

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

I would expect it to queue_signal(:collapse_snapshots) if the task isn't finished. You probably need to store the task id in the job context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I need to understand why this shouldn't be a blocking method, since we can't proceed unless the snapshots have been deleted, can we?

Copy link

Choose a reason for hiding this comment

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

I personally prefer non blocking methods, because you release some time for other jobs. But I confess that it's an habit from Automate development, rather than factual :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fdupont-redhat Ok, took an initial stab at it. Not sure if that's the right approach or not.

Copy link

Choose a reason for hiding this comment

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

Doesn't it start a new task on each iteration? Maybe you should store the task id in context and check for its existence. Also, if the task fails, we should abort because snapshots removal is a prerequisite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I'm understanding how you want this written, so I'll let you update it when you're back on Monday. :)

Copy link

Choose a reason for hiding this comment

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

A proposal is here: https://github.com/fdupont-redhat/manageiq/blob/v2v_state_machine_collapse_snapshots/app/models/infra_conversion_job.rb.

It uses the fact that we have an async task to stay in the 'collapsing_snapshot' state and retry later. We need to store the task id in the job context, so that when we retry we can retrieve the task status and decide what to do: 1. retry if it's not finished, 2. abort if it failed, 3. call next state if it succeeded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fdupont-redhat Looks like you deleted it. :(

@miq-bot
Copy link
Member

miq-bot commented Aug 16, 2019

Checked commits https://github.com/djberg96/manageiq/compare/c1b613e618e957297578a8a0e62261d2cc88f32b~...2e2658ba3fd620ad40308b75c0fd9cdccf92c859 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

@miq-bot
Copy link
Member

miq-bot commented Aug 19, 2019

This pull request is not mergeable. Please rebase and repush.

@djberg96
Copy link
Contributor Author

Closing in favor of #19177

@djberg96 djberg96 closed this Aug 21, 2019
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.

2 participants