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 for Archived Openstack instances #5410
Conversation
33970c3
to
d21c443
Compare
554c165
to
69fa030
Compare
@@ -104,6 +104,8 @@ def paged_view_search(options = {}) | |||
|
|||
if options[:parent] | |||
targets = get_parent_targets(options) | |||
# filter out archived VMs | |||
targets = targets.select { |target| !Vm.find_by(:id => target).archived? unless Vm.find_by(:id => target).nil? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chessbyte as I'm looking on it now, I'm considering to use try
Rails method , so this line would become
targets = targets.select { |target| !Vm.find_by(:id => target).try(:archived?) }
but that would mean, I'd need to do the same with condition below, checking if target
variable is empty?
.
@dclarizio please review |
@Ladas could you verify this fix please? |
@Ladas @gtanzillo re-ping :) |
@@ -104,7 +104,9 @@ def paged_view_search(options = {}) | |||
|
|||
if options[:parent] | |||
targets = get_parent_targets(options) | |||
if targets.empty? | |||
# filter out archived VMs | |||
targets = targets.select { |target| !Vm.find_by(:id => target).try(:archived?) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change is a problem for a couple of reasons. First, paged_view_search is generically used for searching on any kind of object. Not just VMs. So, there's no guarantee that the ids in targets will be the ids of Vm objects. Second, looking up each Vm by id one at a time will create an n+1 query performance issue.
I see that you are filtering out the archived Vms here https://github.com/ManageIQ/manageiq/pull/5410/files#diff-6e332326f5467e2bd25aa3441a9cba33R36, anyway. So, maybe it's ok to just remove this change. Otherwise, additional filtering options would need to be passed down through the callers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What @gtanzillo says, you need to pass the correct sql conditions (!archived) from above, this code should not mention any specific classes. I assume that adding of that condition should depend on your position in the tree?
E.g. when you are on all VMs or archived, you should see archived. When you click on provider, you should not see them?
61c530d
to
83b498d
Compare
@gtanzillo @Ladas PR updated, can you review if it's OK now? 😊 |
👍 This looks good to me now. @Ladas can you please review as well when you can? |
83b498d
to
c41c431
Compare
Checked commits romanblanco/manageiq@69113a1~...c41c431 with ruby 2.2.3, rubocop 0.34.2, and haml-lint 0.13.0 |
I will try to get to it on Monday, I am a bit swamped now :-) |
Seems it works when you delete a provider, then the archived instance is displayed correctly. (If it shouldn't be in Orphaned state?) But when you retire the instance, it's not displayed correctly. And seems like retired instance is deleted in the provider, so it disappears entirely after refresh. But in the meantime, it's displayed among the active VMs |
@romanblanco please review the comments from @Ladas |
@Ladas I've tried to reproduce what you have described, but it seems that there is some bug in
|
@romanblanco ah, please fill an issue for that and mention @blomquisg |
@romanblanco , @Ladas : can we merge this one? |
@martinpovolny I think @romanblanco is still working on this one |
@romanblanco Is there more to do on this? |
@dclarizio yes, i think it's still not working properly |
@dclarizio @Ladas checked again, seems to work. |
If we are done, then remove the WIP and let's merge it! |
Fix for Archived Openstack instances
https://bugzilla.redhat.com/show_bug.cgi?id=1254636