-
Notifications
You must be signed in to change notification settings - Fork 92
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
Implement graph refresh for the Cinder manager #194
Implement graph refresh for the Cinder manager #194
Conversation
@@ -78,7 +78,7 @@ def ensure_network_manager | |||
|
|||
def ensure_cinder_manager | |||
return false if cinder_manager | |||
build_cinder_manager(:type => 'ManageIQ::Providers::StorageManager::CinderManager') | |||
build_cinder_manager(:type => 'ManageIQ::Providers::Openstack::StorageManager::CinderManager') |
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.
hm I don't think we can easily change the STI subclass of the manager now, since we would need a migration that will change existing records. Can we keep the old one? Since we need to backport this.
We can then do upstream only patch changing this, with migration.
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 had a feeling that might be an issue. So to clarify, you'd recommend just leaving this line as build_cinder_manager(:type => 'ManageIQ::Providers::StorageManager::CinderManager')
and then changing it later along with a migration in another patch?
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.
yes. Since we can't backport the migration now, that would be only for upstream and future releases
attachment_names = {'vda' => 'Root disk', 'vdb' => 'Ephemeral disk', 'vdc' => 'Swap disk'} | ||
persister.disks.find_or_build_by( | ||
# FIXME: find works here, but lazy_find doesn't... I don't understand why | ||
:hardware => persister.hardwares.find(a["server_id"]), |
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.
can we do lazy_find ?
persister.hardwares.lazy_find(a["server_id"])
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'll change it and see if the tests agree ;) that comment was written quite a while ago and things have changed since then.
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.
hum, ok, so if that is the case, we can keep there find for now, since hardwares should be always available (for full and targeted). Otherwise the find would degrade to N+1 queries
# there's almost always a tenant id regardless of event type | ||
collect_identity_tenant_references!(target_collection, ems_event) | ||
|
||
# WIP |
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.
right, this will be for standalone block storage based entities, can we also try to extract targets as part of Vm in collector?
e.g. amazon look both in db and API:
https://github.com/Ladas/manageiq-providers-amazon/blob/52636410835d6319627afd5e489cefe199e81a01/app/models/manageiq/providers/amazon/inventory/collector/target_collection.rb#L203
And seems like I miss extracting it from the db, it may be because the query would be too inefficient
It's currently the only way how to get full targeted refresh of a Vm
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.
Yeah absolutely, volumes should be pulled as part of the full targeted vm refresh.
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.
@mansam Looks awesome, great work in a short time , we just need:
- not to change the STI of manager
- to make sure Vm refreshes with volumes (extending the Vm targeted refresh)
- parsing of the events
And it's done :-)
@mansam the CI failure is most probably caused by https://github.com/ManageIQ/manageiq/pull/16688/files#r161458751 , once this PR is ready, we can merge, that issue will be fixed separately. |
@mansam tomorrow is the last day, then it's non blocker only. Will you be able to finish until then? |
@Ladas Yeah, I will get this finished by then. |
# pull the attachments from the raw attribute to avoid Fog making an unnecessary call | ||
# to inflate the volumes before we need them | ||
vm.attributes.fetch('os-extended-volumes:volumes_attached', []).each do |attachment| | ||
add_simple_target!(:cloud_volumes, attachment["id"]) |
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.
@Ladas I'm having trouble getting the targeted collector to pick up the Cloud Volumes. They're added as simple targets here and I can see in my tests that this part works, but the collector method on line 194 never gets called, nor does the parser. I'm not sure what I've done differently that is causing these volume targets to not get parsed, so if you could take a look when you have time that would be much appreciated. I have a feeling I've just been staring at this too long and am simply missing something obvious. :)
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.
target, | ||
ManageIQ::Providers::Openstack::Inventory::Collector::StorageManager::CinderManager, | ||
ManageIQ::Providers::Openstack::Inventory::Persister::StorageManager::CinderManager, | ||
[ManageIQ::Providers::Openstack::Inventory::Parser::StorageManager::CinderManager] |
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.
@mansam for your question below, you need to ManageIQ::Providers::Openstack::Inventory::Parser::StorageManager::CinderManager
to line 30, so ManagerRefresh::TargetCollection (targeted refresh) invokes all parsers
@@ -9,6 +9,11 @@ | |||
:openstack_network: | |||
:is_admin: false | |||
:inventory_object_refresh: true | |||
:allow_targeted_refresh: true | |||
:cinder: | |||
:is_admin: false |
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.
just a quick question, the :all_tenants param doesn't work for storage and network?
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.
It does, but they're an option the defaults to being off because at some point someone told me we supported refresh with a non-admin user so I was trying to work around that.
@@ -191,6 +191,14 @@ def vms_by_id | |||
@vms_by_id ||= Hash[vms.collect { |s| [s.id, s] }] | |||
end | |||
|
|||
def cloud_volumes |
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.
@mansam we need the same for cloud_volume_backups and cloud_volume_snapshots, otherwise the targeted refresh would be deleting those (because they would not be found in in the API)
return [] if references(:cloud_volumes).blank? | ||
return @cloud_volumes if @cloud_volumes.any? | ||
@cloud_volumes = references(:cloud_volumes).collect do |volume_id| | ||
safe_get { cinder_service.volumes.get(volume_id) } |
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.
@mansam just a sanity check, cinder_service.volumes.get(volume_id)
works across differnet tenants, right?
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.
It doesn't, sadly. cinder_service.volumes.all(:id => volume_id, :all_tenants => true)
works, but that requires admin. I might have to just make a scoped request for each volume.
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.
right, so probably lets target this as perf issues for next minor release? Could you do some perf test with 200-500 tenants (and more)? That is what we see in production. Then lets talk to Loic where to target this.
Or maybe I understand it badly? How many API queries will this cause with having 500 tenants?
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.
@mansam btw. there is a quick simple spec that the targeted refresh is not deleting something out if its scope https://github.com/Ladas/manageiq-providers-amazon/blob/5372348b633b8c7f37813388013e4e38af402a72/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/targeted_refresh_scope_spec.rb#L38 Basically using existing full refresh, then targeted refresh, then full refresh asserts should pass, since the targeted refresh should just update existing data. Might be for another PR, just to give it more coverage. |
39f2ec3
to
1e06062
Compare
Two of the VCR instances have either gone down or stopped responding. I'll update the VCRs for this as soon as I can. |
@mansam so you can probably drop those VCR specs :-) I think I had reports that some of the envs were acting strange. Also, we should deploy new version, since most of the versions we test are EOL now. :-) |
Some comments on commits mansam/manageiq-providers-openstack@3ff912e~...285fa65 spec/models/manageiq/providers/openstack/storage_manager/cinder_manager/event_target_parser_spec.rb
|
Checked commits mansam/manageiq-providers-openstack@3ff912e~...285fa65 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 **
app/models/manageiq/providers/openstack/cinder_manager_mixin.rb
app/models/manageiq/providers/openstack/inventory_collection_default/storage_manager.rb
|
@mansam what is the state of this? Can we merge soon? I have a bunch of core refactorings I would like to merge after this, so you have an easier backport. :-) |
@Ladas Should be ready, let me just doublecheck |
@Ladas This should be good to go now. |
:foreign_key => :parent_ems_id, | ||
:class_name => "ManageIQ::Providers::StorageManager::CinderManager", | ||
:autosave => true, | ||
:dependent => :destroy |
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.
hm, I think we were removing the :dependent => :destroy lately https://github.com/ManageIQ/manageiq-providers-openstack/pull/208/files
We might want to drop it?
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.
Hm, though this passes the CI, so could you maybe do that as separate PR? We might need to backport both then.
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.
Looks great. 👍
Minor comment with :dependent= > :destroy, it doesn't break CI though (so the destroy should be passing). So we can solve that in a next PR and see where it has to be backported.
Looks good to me and trust @Ladas too, merging! |
@simaishi Unfortunately this always happens with PRs involving VCR updates. I'll create some backport PRs for Gaprindashvili and just have to update the VCRs on them as each one gets merged in turn. |
Backported to Gaprindashvili via #274 |
https://bugzilla.redhat.com/show_bug.cgi?id=1532796