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

Add VmOrTemplate.remove_all_snapshots_queue #19150

Merged
merged 3 commits into from
Aug 14, 2019

Conversation

ghost
Copy link

@ghost ghost commented Aug 14, 2019

In existing implementation, it's possible to queue a single snapshot removal via VmOrTemplate.remove_snapshot_queue. However, this is not possible to queue the removal of all snapshots, while it's probably going to take longer.

This PR introduces VmOrTemplate.remove_all_snapshots_queue.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1741326

@ghost
Copy link
Author

ghost commented Aug 14, 2019

@miq-bot add-label enhancement, ivanchuk/yes

@@ -150,6 +150,18 @@ def remove_all_snapshots
raw_remove_all_snapshots
end

def remove_all_snapshots_queue(task_id = nil)
MiqQueue.put_unless_exists(
Copy link
Member

Choose a reason for hiding this comment

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

We're trying to get away from put_unless_exists plus I don't think you want/need this in this case

Copy link
Author

Choose a reason for hiding this comment

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

What would you use instead ? put_or_update ?

Copy link
Member

Choose a reason for hiding this comment

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

Just .put or even better MiqTask.generic_action_with_callback handles this for you

:args => [],
:role => "ems_operations",
:zone => my_zone,
:task_id => task_id
Copy link
Member

Choose a reason for hiding this comment

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

Instead of passing a task_id in I think you want to just do MiqTask.generic_action_with_callback which will create the task and when the miq_queue method finishes it updates the task.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see you're following the pattern of the rest of the remove_snapshot_queue methods, I'm not sure that the task will be updated when the queue item finishes

Copy link
Member

@agrare agrare Aug 14, 2019

Choose a reason for hiding this comment

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

So I don't think this task_id is what you're thinking it is, https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_action.rb#L635-L640
The task_id for those is task_id = "action_#{action.id}_vm_#{rec.id}"

@ghost
Copy link
Author

ghost commented Aug 14, 2019

@agrare I updated with the pattern found in CloudVolume.detach_volume_queue

@miq-bot
Copy link
Member

miq-bot commented Aug 14, 2019

Checked commits fabiendupont/manageiq@6e8f23b~...fa38dfe with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. ⭐

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

👍 tested, lgtm

@simaishi
Copy link
Contributor

Ivanchuk backport details:

$ git log -1
commit 5b40a978c62522b0d88a4f7d2862068a1b02003c
Author: Adam Grare <agrare@redhat.com>
Date:   Wed Aug 14 16:15:38 2019 -0400

    Merge pull request #19150 from fdupont-redhat/add_remove_all_snapshots_queue
    
    Add VmOrTemplate.remove_all_snapshots_queue
    
    (cherry picked from commit bdf430d162618a5dbd243a12a1fcf2fe4cfb4d36)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1767550

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.

4 participants