-
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
Targeted refresh workaround for events that don't identify objects #323
Conversation
7cfa21a
to
1a3ebf9
Compare
@@ -309,7 +311,7 @@ def infer_related_vm_ems_refs_db! | |||
|
|||
all_stacks.each { |s| add_simple_target!(:orchestration_stacks, s.ems_ref, :tenant_id => s.cloud_tenant.ems_ref) } | |||
vm.cloud_networks.collect(&:ems_ref).compact.each { |ems_ref| add_simple_target!(:cloud_networks, ems_ref) } | |||
vm.floating_ips.collect(&:address).compact.each { |address| add_simple_target!(:floating_ips, address) } | |||
vm.floating_ips.collect(&:ems_ref).compact.each { |address| add_simple_target!(:floating_ips, address) } |
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.
probably rename also the other address to ems_ref
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.
👍
@cloud_volume_backups = targets_by_association(:cloud_volume_backups).collect do |target| | ||
scoped_get_backup(target.manager_ref[:ems_ref], target.options[:tenant_id]) | ||
end.compact | ||
@cloud_volume_backups = cinder_service.handled_list(:list_backups_detailed, {:__request_body_index => "backups"}, cinder_admin?) |
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.
we will need specs for this, I think this way it would lead to duplication of existing cloud_volume_backups
I think what we could do to make this work on persistor could be switching :targeted => true/false
. Given references will be [nil] or [], then targeted => true
will not update or delete anything, since the targeted query will not return any records. With :targeted => false
, we will do a full refresh of the cloud_volume_backups IC.
Same for the key_pairs. But lets do specs to verify this will work.
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 write specs to make sure this behaves correctly. Why do you suspect it would result in duplicated objects?
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.
so the targeted refresh takes the references and it builds a query, so it would be:
CloudVolumeBackups.where(:ems_ref => references(...))
So if this returns always [], the refresh will create anything built by the parser. In this case that would be all cloud_volume_backups are created again. While the correct behavior should be that the query returns the existing ones, and we just update them.
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.
Ah, gotcha
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.
Local testing as well as my new specs suggest that this duplication does not occur.
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.
builder.add_properties(:targeted => false)
doesn't make a difference. I'm not sure why resource
is being set conditionally, I think that happened during the builder refactor. I'll investigate that later. And it's fine to call TargetedCollection's key pair method, I just was mistakenly believing I'd see a different call when targeted => 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.
right, targeted => false
should only change how we look at db. With targeted => true, we do ems.key_pairs.where(references(:vms))
with false we do ``````ems.key_pairs```
So with false it loads all key_pairs and it will delete those you will not .build in parser. While with true, it just loads the ones you've built, so it will just update.
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.
in the spec, try also ems.key_pairs, since there might be the bug with :resource being 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.
Doesn't seem to make a difference either way, though I'm continuing to investigate.
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 Nevermind me, the spec wasn't written properly. >.>
65bc98a
to
eaa3e81
Compare
@@ -123,9 +123,10 @@ def add_key_pairs(extra_properties = {}) | |||
add_collection(cloud, :key_pairs, extra_properties) do |builder| | |||
builder.add_properties( | |||
:model_class => ManageIQ::Providers::Openstack::CloudManager::AuthKeyPair, | |||
# targeted refresh workaround-- always refresh the whole keypair collection | |||
:targeted => 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.
I think we still need to conditionalize this , it should copy what we do in https://github.com/ManageIQ/manageiq-providers-openstack/pull/323/files#diff-0698b10bec7e7c31e8eabb30dc507213R140
So we fetch all entities only if there is something in references.
Now, it the references would be blank, we would delete all keypairs
eaa3e81
to
fe65bab
Compare
else | ||
builder.add_default_values(:ems_id => manager.id) | ||
end | ||
# targeted refresh workaround-- always refresh the whole backup collection |
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 would probably write here why:
``Because OpenStack doesn't give us UUIDs of changed volume_backups, we just get an event that one of them changed```
Btw. is this a bug? :-D It's like super unhelpful event. :-) Or does it use ID we don't recognize?
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.
Good call on the improved comment. I'm not sure whether this is officially a bug, but it is a really unhelpful event. There are some other IDs present like the request ID, but nothing that helps us as far as I know.
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 👍
Just a nit for a better comment, so we remember why we do this :-)
fe65bab
to
8ef539e
Compare
This pull request is not mergeable. Please rebase and repush. |
8ef539e
to
90f75d0
Compare
Checked commit mansam@90f75d0 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Some comments on commit mansam@90f75d0 spec/models/manageiq/providers/openstack/cloud_manager/stubbed_refresher_spec.rb
|
Looks good! Merging. |
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1596058 in combination with ManageIQ/manageiq-content#371 and ManageIQ/manageiq-content#372