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

Do not delete children snapshots as part of parent #17462

Merged

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented May 22, 2018

Do not delete children snapshots as part of parent. The default
relation :children, added by acts_as_tree, has :dependent => :destroy.

So deleting parent, will delete all it's children. This is not behavior
we want in refresh. In old refresh, we were bypassing this by:
https://github.com/ManageIQ/manageiq/blob/master/app/models/ems_refresh/save_inventory.rb#L366

So first, we deleted the tree relations, then we did create/update/delete
of the nodes, then we updated the tree connections again. All of that should
not be needed, if we will just use :dependent => :nullify

Partially fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1571291

PR with spec is here:
ManageIQ/manageiq-providers-ovirt#241

Do not delete children snapshots as part of parent. The default
relation :children, added by acts_as_tree, has :dependent => :destroy.

So deleting parent, will delete all it's children. This is not behavior
we want in refresh. In old refresh, we were bypassing this by:
https://github.com/ManageIQ/manageiq/blob/master/app/models/ems_refresh/save_inventory.rb#L366

So first, we deleted the tree relations, then we did create/update/delete
of the nodes, then we updated the tree connections again. All of that should
not be needed, if we will just use :dependent => :nullify

Partially fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1571291
@Ladas
Copy link
Contributor Author

Ladas commented May 22, 2018

@miq-bot add_label bug
@miq-bot assign @agrare

cc @borod108

@miq-bot
Copy link
Member

miq-bot commented May 22, 2018

Checked commit Ladas@ff840c9 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. 👍

@agrare
Copy link
Member

agrare commented May 22, 2018

@Ladas I was thinking about this after we talked and I think the problem here is that it will leave orphaned child snaps if you destroy the vm.
What about a custom disconnect block which nullifies the parent_id of any children first?

@agrare
Copy link
Member

agrare commented May 22, 2018

@Ladas pointed out in gitter that we already dependent destroy snapshots related to a VM so the tree delete is redundant.

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.

👍 LGTM

@agrare agrare merged commit 2903440 into ManageIQ:master May 22, 2018
@jrafanie jrafanie modified the milestone: Sprint 86 Ending May 21, 2018 May 22, 2018
simaishi pushed a commit that referenced this pull request May 22, 2018
…with_parent

Do not delete children snapshots as part of parent
(cherry picked from commit 2903440)

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

Gaprindashvili backport details:

$ git log -1
commit cdde57eb3836288533a9ee2ccc366f7cd492f8a7
Author: Adam Grare <agrare@redhat.com>
Date:   Tue May 22 08:33:05 2018 -0400

    Merge pull request #17462 from Ladas/do_not_delete_snapshot_children_with_parent
    
    Do not delete children snapshots as part of parent
    (cherry picked from commit 2903440a061372c76f0e949dcd35a93f7b9d0e65)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1581287

@agrare agrare added this to the Sprint 87 Ending Jun 4, 2018 milestone May 22, 2018
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