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

Delete Container/AWS labels that no longer exist on the provider. #14388

Closed

Conversation

bronaghs
Copy link

When a label (tag) has been deleted on a resource on AWS, that label should be deleted in the MIQ database too but instead it persists.

Steps to reproduce:

  1. Execute an EMS refresh in MIQ
  2. Open an instance in MIQ and observe the contents of the Labels box in the Summary page
  3. Delete one of the tags on the instance using the AWS console
  4. Execute an EMS refresh in MIQ
  5. Observe the tag deleted in step 3) still persists.

@cben -

  1. Does this bug also apply to labels in Containers too?
  2. Will this fix break anything on the Containers side?

@bronaghs
Copy link
Author

@miq-bot add_label wip, providers, bug
@miq-bot assign @cben

@cben
Copy link
Contributor

cben commented Mar 20, 2017

Haven't tested yet but I think this will be no-op for containers, as we don't do targeted (all this if target.kind_of? boilerplate is unused), for us target is always EMS.

So Amazon refresh now also relies on save_inventory_container.rb ?
Ah, I see, https://github.com/ManageIQ/manageiq/pull/14202/files#diff-090b07f911cee85c2acff15e6bda1032R42 added :labels to child_keys in save_vms_inventory,
and despite apparent namespacing they're all mixed in to EmsRefresh.

What do you think of moving save_labels_inventory, save_custom_attribute_attribute_inventory to a place where it's clear they are shared, eg. save_inventory.rb ?

@bronaghs
Copy link
Author

@cben - yes, they need to be moved. Just not before feature freeze :-)


save_inventory_multi(entity.send(attribute_name),
hashes, deletes, [:section, :name])
hashes, :use_association, [:section, :name])
Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't want to move these functions to save_inventory.rb, please add a comment that they're also serving Amazon refresh.
(The move should be a trivial textual move, there is nothing else to refactor. Again, these modules all end up in one namespace.)

Copy link
Contributor

Choose a reason for hiding this comment

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

@cben @bronaghs +1 to move this in save_inventory.rb.

Copy link
Author

@bronaghs bronaghs Apr 4, 2017

Choose a reason for hiding this comment

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

Hi @cben, @simon3z
Agreed. In fact, there are multiple places where we are re-using the containers tagging code, we will make a separate PR that will move it all to a generic place.

Copy link
Author

Choose a reason for hiding this comment

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

@djberg96 - l heard on SU that you are working on refactoring the shared code referred to here. Can you include the code used in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bronaghs Not this particular code atm. I've got a couple PR's in to do a project-wide renaming of ContainerLabelTagMapping to ResourceLabelTagMapping, but that's it for now.

@cben
Copy link
Contributor

cben commented Mar 22, 2017

Sorry. Finally tested this.
This is not a no-op — we did have the bug, and this fixes it! Thanks 🏅 🙇‍♂️

Target was not the ems as I thought — it was nil, so deletes is []!
Our boilerplate that we believed inactive, just "preparation" in hope one day we'll do refresh with target != EMS, was actually biting us :-(
The reason is that this (and many many functions here) is called from save_child_inventory which is called from save_inventory_multi with child_keys, which never passes down the target:
https://github.com/ManageIQ/manageiq/blob/62eddfb06ef00/app/models/ems_refresh/save_inventory_helper.rb#L57

@simon3z @moolitayer @zakiva This seems bad. Many things are not getting deleted in our refresh! Also, we need refresher specs where things actually change between 2 refreshes.

LGTM for this PR, let's not block you any further, seems we'll need a big followup...

@bronaghs
Copy link
Author

@cben - glad this fixed this issue for you too.
FYI this Amazon spec tests the cleanup of deleted objects, this is probably a good example for your team to start from.

@moolitayer
Copy link

@cben so all entities that are not called on first level from save_ems_container_inventory are not being deleted when they are removed? please create a bz for this issue.

@moolitayer
Copy link

@cben so all entities that are not called on first level from save_ems_container_inventory are not being deleted when they are removed? please create a bz for this issue.

Never mind, I created https://bugzilla.redhat.com/show_bug.cgi?id=1436132

@bronaghs bronaghs force-pushed the delete_labels_that_no_longer_exist branch from bc4dc79 to 676022e Compare March 29, 2017 18:40
@miq-bot
Copy link
Member

miq-bot commented Mar 29, 2017

Checked commits bronaghs/manageiq@29cf052~...676022e with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks good. 🍰

@bronaghs bronaghs changed the title [WIP] Delete Container/AWS labels that no longer exist on the provider. Delete Container/AWS labels that no longer exist on the provider. Mar 29, 2017
@miq-bot miq-bot removed the wip label Mar 29, 2017
bronaghs pushed a commit to bronaghs/manageiq-providers-amazon that referenced this pull request Mar 29, 2017
bronaghs pushed a commit to bronaghs/manageiq-providers-amazon that referenced this pull request Mar 29, 2017
bronaghs pushed a commit to bronaghs/manageiq-providers-amazon that referenced this pull request Mar 29, 2017
bronaghs pushed a commit to bronaghs/manageiq-providers-amazon that referenced this pull request Mar 29, 2017
bronaghs pushed a commit to bronaghs/manageiq-providers-amazon that referenced this pull request Mar 29, 2017
bronaghs pushed a commit to bronaghs/manageiq-providers-amazon that referenced this pull request Mar 29, 2017
@chessbyte
Copy link
Member

@cben @bronaghs bump

@miq-bot
Copy link
Member

miq-bot commented Jul 11, 2017

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

@cben
Copy link
Contributor

cben commented Jul 11, 2017

This was covered by the finally merged #15182 (also find/backported).
Sorry, forgot that it also affects amazon provider and forgot to cc you.
Now may be a good time to revive and re-run ManageIQ/manageiq-providers-amazon#205 tests :)

@bronaghs
Copy link
Author

This was fixed by #15182 (thanks @cben )
Closing.

@bronaghs bronaghs closed this Oct 13, 2017
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.

None yet

7 participants