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

Implement graph refresh for the Cinder manager #194

Merged
merged 8 commits into from
Jan 29, 2018

Conversation

mansam
Copy link
Contributor

@mansam mansam commented Jan 12, 2018

@miq-bot miq-bot added the wip label Jan 12, 2018
@@ -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')
Copy link
Contributor

@Ladas Ladas Jan 12, 2018

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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"]),
Copy link
Contributor

@Ladas Ladas Jan 12, 2018

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"])

Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor

@Ladas Ladas Jan 12, 2018

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

https://github.com/Ladas/manageiq-providers-amazon/blob/52636410835d6319627afd5e489cefe199e81a01/app/models/manageiq/providers/amazon/inventory/collector/target_collection.rb#L249

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

Copy link
Contributor Author

@mansam mansam Jan 12, 2018

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.

Copy link
Contributor

@Ladas Ladas left a 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:

  1. not to change the STI of manager
  2. to make sure Vm refreshes with volumes (extending the Vm targeted refresh)
  3. parsing of the events

And it's done :-)

@Ladas
Copy link
Contributor

Ladas commented Jan 15, 2018

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

@Ladas
Copy link
Contributor

Ladas commented Jan 15, 2018

@mansam tomorrow is the last day, then it's non blocker only. Will you be able to finish until then?

@mansam
Copy link
Contributor Author

mansam commented Jan 15, 2018

@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"])
Copy link
Contributor Author

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. :)

Copy link
Contributor

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]
Copy link
Contributor

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
Copy link
Contributor

@Ladas Ladas Jan 16, 2018

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?

Copy link
Contributor Author

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
Copy link
Contributor

@Ladas Ladas Jan 16, 2018

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) }
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

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

@aufi feel free to merge once @mansam fixes the remaining stuff and will have the tests passing.

Otherwise we would talk to Loic and turn this to blocker I suppose

@Ladas
Copy link
Contributor

Ladas commented Jan 16, 2018

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

@mansam mansam force-pushed the implement-graph-refresh-for-cinder branch from 39f2ec3 to 1e06062 Compare January 16, 2018 20:32
@mansam
Copy link
Contributor Author

mansam commented Jan 16, 2018

Two of the VCR instances have either gone down or stopped responding. I'll update the VCRs for this as soon as I can.

@Ladas
Copy link
Contributor

Ladas commented Jan 18, 2018

@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. :-)

@mansam mansam changed the title [WIP] Implement graph refresh for the Cinder manager Implement graph refresh for the Cinder manager Jan 19, 2018
@miq-bot miq-bot removed the wip label Jan 19, 2018
@miq-bot
Copy link
Member

miq-bot commented Jan 19, 2018

Some comments on commits mansam/manageiq-providers-openstack@3ff912e~...285fa65

spec/models/manageiq/providers/openstack/storage_manager/cinder_manager/event_target_parser_spec.rb

  • ⚠️ - 6 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Jan 19, 2018

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
44 files checked, 5 offenses detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

app/models/manageiq/providers/openstack/cinder_manager_mixin.rb

app/models/manageiq/providers/openstack/inventory_collection_default/storage_manager.rb

@Ladas
Copy link
Contributor

Ladas commented Jan 26, 2018

@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. :-)

@mansam mansam closed this Jan 26, 2018
@mansam mansam reopened this Jan 26, 2018
@mansam
Copy link
Contributor Author

mansam commented Jan 26, 2018

@Ladas Should be ready, let me just doublecheck

@mansam
Copy link
Contributor Author

mansam commented Jan 26, 2018

@Ladas This should be good to go now.

:foreign_key => :parent_ems_id,
:class_name => "ManageIQ::Providers::StorageManager::CinderManager",
:autosave => true,
:dependent => :destroy
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

@Ladas Ladas left a 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.

@aufi
Copy link
Member

aufi commented Jan 29, 2018

Looks good to me and trust @Ladas too, merging!

@aufi aufi merged commit 4b784de into ManageIQ:master Jan 29, 2018
@aufi aufi added this to the Sprint 78 Ending Jan 29, 2018 milestone Jan 29, 2018
@simaishi
Copy link
Contributor

@mansam This PR as well as #242 conflicts on VCRs as well...

I know you already have a Gaprindashvili PR for #265. Not sure what needs to be done for this and PR 242...

@mansam
Copy link
Contributor Author

mansam commented Apr 12, 2018

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

@simaishi
Copy link
Contributor

Backported to Gaprindashvili via #274

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