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

Fix for Archived Openstack instances #5410

Merged
merged 4 commits into from Mar 21, 2016

Conversation

romanblanco
Copy link
Member

@romanblanco romanblanco changed the title [WIP] Fix for Archived Openstack instances Fix for Archived Openstack instances Nov 16, 2015
@romanblanco romanblanco force-pushed the BZ1254636 branch 2 times, most recently from 554c165 to 69fa030 Compare November 21, 2015 16:59
@miq-bot miq-bot removed the wip label Nov 26, 2015
@@ -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? }
Copy link
Member

Choose a reason for hiding this comment

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

@matthewd @Fryguy something looks off here (making the same SQL query twice on one line). Suggestions?

Copy link
Member Author

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?.

Any better suggestions? @matthewd @Fryguy

@chessbyte
Copy link
Member

@dclarizio please review

@dclarizio
Copy link

@Ladas could you verify this fix please?
@gtanzillo please review the model changes and specs.
Thx, Dan

@dclarizio
Copy link

@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?) }
Copy link
Member

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.

Copy link
Contributor

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?

@romanblanco romanblanco force-pushed the BZ1254636 branch 5 times, most recently from 61c530d to 83b498d Compare January 27, 2016 10:10
@romanblanco
Copy link
Member Author

@gtanzillo @Ladas PR updated, can you review if it's OK now? 😊

@gtanzillo
Copy link
Member

👍 This looks good to me now. @Ladas can you please review as well when you can?

@miq-bot
Copy link
Member

miq-bot commented Feb 3, 2016

Checked commits romanblanco/manageiq@69113a1~...c41c431 with ruby 2.2.3, rubocop 0.34.2, and haml-lint 0.13.0
4 files checked, 0 offenses detected
Everything looks good. 🍪

@Ladas
Copy link
Contributor

Ladas commented Feb 3, 2016

I will try to get to it on Monday, I am a bit swamped now :-)

@Ladas
Copy link
Contributor

Ladas commented Feb 10, 2016

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

@chessbyte
Copy link
Member

@romanblanco please review the comments from @Ladas

@romanblanco
Copy link
Member Author

@Ladas I've tried to reproduce what you have described, but it seems that there is some bug in retire_now method. I'm getting this error in evm.log:

[----] I, [2016-02-22T13:33:29.050136 #19788:2b05fa5bd968]  INFO -- : Raising Retirement Event for [cloudformation-spec]
[----] I, [2016-02-22T13:33:29.054524 #19788:2b05fa5bd968]  INFO -- : <AutomationEngine> MiqAeEvent.build_evm_event >> event=<"request_orchestration_stack_retire"> inputs=<{:retirement_initiator=>"system", :orchestration_stack=>#<ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack id: 10000000000010, name: "cloudformation-spec", type: "ManageIQ::Providers::Amazon::CloudManager::Orchest...", description: "AWS CloudFormation Sample Template vpc_single_inst...", status: "CREATE_FAILED", ems_ref: "arn:aws:cloudformation:us-east-1:200278856672:stac...", ancestry: nil, ems_id: 10000000000009, orchestration_template_id: 10000000000001, created_at: "2015-10-22 09:12:49", updated_at: "2015-10-30 13:14:31", retired: false, retires_on: "2015-11-01", retirement_warn: 7, retirement_last_warn: "2015-10-30 13:14:31", retirement_state: nil, retirement_requester: nil, status_reason: "The following resource(s) failed to create: [WebSe...", cloud_tenant_id: nil, resource_group: nil>, :type=>"ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack", "MiqEvent::miq_event"=>10000000285949, :miq_event_id=>10000000285949, "EventStream::event_stream"=>10000000285949, :event_stream_id=>10000000285949}>
[----] E, [2016-02-22T13:33:29.055063 #19788:2b05fa5bd968] ERROR -- : [NoMethodError]: undefined method `tenant_identity' for #<ManageIQ::Providers::Amazon::CloudManager::OrchestrationStack:0x00560bfaab3360>  Method:[rescue in retire_now]
[----] E, [2016-02-22T13:33:29.055241 #19788:2b05fa5bd968] ERROR -- : /home/rblanco/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activemodel-5.0.0.beta2/lib/active_model/attribute_methods.rb:433:in `method_missing'
/home/rblanco/devel/manageiq/lib/miq_automation_engine/engine/miq_ae_event.rb:114:in `call_automate'
/home/rblanco/devel/manageiq/lib/miq_automation_engine/engine/miq_ae_event.rb:41:in `raise_evm_event'
/home/rblanco/devel/manageiq/app/models/miq_event.rb:43:in `raise_evm_event'
/home/rblanco/devel/manageiq/app/models/mixins/retirement_mixin.rb:168:in `raise_retirement_event'
/home/rblanco/devel/manageiq/app/models/mixins/retirement_mixin.rb:115:in `retire_now'
/home/rblanco/devel/manageiq/app/models/mixins/retirement_mixin.rb:103:in `retirement_check'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-5.0.0.beta2/lib/active_record/relation/delegation.rb:39:in `each'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/activerecord-5.0.0.beta2/lib/active_record/relation/delegation.rb:39:in `each'
/home/rblanco/devel/manageiq/app/models/orchestration_stack/retirement_management.rb:13:in `retirement_check'
/home/rblanco/devel/manageiq/app/models/miq_queue.rb:335:in `block in deliver'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/2.2.0/timeout.rb:89:in `block in timeout'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/2.2.0/timeout.rb:34:in `block in catch'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/2.2.0/timeout.rb:34:in `catch'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/2.2.0/timeout.rb:34:in `catch'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/2.2.0/timeout.rb:104:in `timeout'
/home/rblanco/devel/manageiq/app/models/miq_queue.rb:331:in `deliver'
/home/rblanco/devel/manageiq/app/models/miq_queue_worker_base/runner.rb:106:in `deliver_queue_message'
/home/rblanco/devel/manageiq/app/models/miq_queue_worker_base/runner.rb:134:in `deliver_message'
/home/rblanco/devel/manageiq/app/models/miq_queue_worker_base/runner.rb:151:in `block in do_work'
/home/rblanco/devel/manageiq/app/models/miq_queue_worker_base/runner.rb:145:in `loop'
/home/rblanco/devel/manageiq/app/models/miq_queue_worker_base/runner.rb:145:in `do_work'
/home/rblanco/devel/manageiq/app/models/miq_worker/runner.rb:327:in `block in do_work_loop'
/home/rblanco/devel/manageiq/app/models/miq_worker/runner.rb:324:in `loop'
/home/rblanco/devel/manageiq/app/models/miq_worker/runner.rb:324:in `do_work_loop'
/home/rblanco/devel/manageiq/app/models/miq_worker/runner.rb:146:in `run'
/home/rblanco/devel/manageiq/app/models/miq_worker/runner.rb:121:in `start'
/home/rblanco/devel/manageiq/app/models/miq_worker/runner.rb:21:in `start_worker'
/home/rblanco/devel/manageiq/app/models/miq_worker.rb:346:in `block in start'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb:24:in `fork'
/home/rblanco/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb:24:in `fork'
/home/rblanco/devel/manageiq/app/models/miq_worker.rb:344:in `start'
/home/rblanco/devel/manageiq/app/models/miq_worker.rb:274:in `start_worker'
/home/rblanco/devel/manageiq/app/models/miq_worker.rb:154:in `block in sync_workers'
/home/rblanco/devel/manageiq/app/models/miq_worker.rb:154:in `times'
/home/rblanco/devel/manageiq/app/models/miq_worker.rb:154:in `sync_workers'
/home/rblanco/devel/manageiq/app/models/miq_server/worker_management/monitor.rb:49:in `block in sync_workers'
/home/rblanco/devel/manageiq/app/models/miq_server/worker_management/monitor.rb:47:in `each'
/home/rblanco/devel/manageiq/app/models/miq_server/worker_management/monitor.rb:47:in `sync_workers'
/home/rblanco/devel/manageiq/app/models/miq_server.rb:186:in `start'
/home/rblanco/devel/manageiq/app/models/miq_server.rb:273:in `start'
/home/rblanco/devel/manageiq/lib/workers/evm_server.rb:60:in `start'
/home/rblanco/devel/manageiq/lib/workers/evm_server.rb:79:in `start'
/home/rblanco/devel/manageiq/lib/workers/bin/evm_server.rb:4:in `<main>'

@Ladas
Copy link
Contributor

Ladas commented Feb 22, 2016

@romanblanco ah, please fill an issue for that and mention @blomquisg

@martinpovolny
Copy link

@romanblanco , @Ladas : can we merge this one?

@Ladas
Copy link
Contributor

Ladas commented Mar 9, 2016

@martinpovolny I think @romanblanco is still working on this one

@dclarizio
Copy link

@romanblanco Is there more to do on this?

@romanblanco
Copy link
Member Author

@dclarizio yes, i think it's still not working properly

@dclarizio dclarizio added the wip label Mar 17, 2016
@dclarizio dclarizio changed the title Fix for Archived Openstack instances [WIP] Fix for Archived Openstack instances Mar 17, 2016
@romanblanco
Copy link
Member Author

@dclarizio @Ladas checked again, seems to work.

@martinpovolny
Copy link

If we are done, then remove the WIP and let's merge it!

@romanblanco romanblanco changed the title [WIP] Fix for Archived Openstack instances Fix for Archived Openstack instances Mar 21, 2016
@miq-bot miq-bot removed the wip label Mar 21, 2016
@martinpovolny martinpovolny added this to the Sprint 38 Ending Mar 28, 2016 milestone Mar 21, 2016
martinpovolny pushed a commit that referenced this pull request Mar 21, 2016
Fix for Archived Openstack instances
@martinpovolny martinpovolny merged commit 22cf82a into ManageIQ:master Mar 21, 2016
@romanblanco romanblanco deleted the BZ1254636 branch March 21, 2016 19:08
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

8 participants