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

Host targeted refresh deleting and re-creating storage, switch, and lan records #336

Merged
merged 8 commits into from
Feb 8, 2019

Conversation

agrare
Copy link
Member

@agrare agrare commented Jan 25, 2019

Add some tests to catch a host targeted refresh causing storage, switch,
and lan records to be deleted+recreated.
@agrare agrare added the wip label Jan 25, 2019
@@ -213,7 +213,7 @@ def infer_related_host_ems_refs_db!
changed_hosts.each do |host|
add_simple_target!(:ems_clusters, uuid_from_target(host.ems_cluster))
host.storages.each do |storage|
add_simple_target!(:storagedomains, uuid_from_target(storage))
add_simple_target!(:storagedomains, storage.ems_ref)
Copy link
Member Author

Choose a reason for hiding this comment

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

This was comparing the wrong property:

references(:storagedomains)
["cd4cf9b7-e1d4-4ef6-a3ed-06adf72c8031"]
Storage.pluck(:ems_ref)
["/api/storagedomains/072fbaa1-08f3-4a40-9f34-a5ca22dd1d74", "/api/storagedomains/cd4cf9b7-e1d4-4ef6-a3ed-06adf72c8031"]

@agrare
Copy link
Member Author

agrare commented Jan 25, 2019

@borod108 the switches reference is empty in the specs, it looks like we get the switch targets and the switches in the parser two different ways.

describe ManageIQ::Providers::Redhat::InfraManager::Refresh::Refresher do
include OvirtRefresherSpecCommon

describe ManageIQ::Providers::Redhat::InfraManager::Refresh::Refresher do
Copy link
Member Author

Choose a reason for hiding this comment

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

@borod108 why are these describe blocks duplicated?

Copy link
Contributor

Choose a reason for hiding this comment

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

For no good reason I can think off.

@jerryk55
Copy link
Member

@agrare @borod108 @roliveri Just as background, the issue described in https://bugzilla.redhat.com/show_bug.cgi?id=1669176 appears to be fixed by @agrare's change to the storage refresh, and backing out the removal of the network refresh from #316. Seeing if the specs pass now...

Code removed by PR ManageIQ#316
caused the problem with disconnected networks indicated in
https://bugzilla.redhat.com/show_bug.cgi?id=1669176
@jerryk55 jerryk55 force-pushed the bz_1669176_host_targeted_refresh branch from 4b75844 to 1a0117d Compare January 31, 2019 22:07
@miq-bot
Copy link
Member

miq-bot commented Jan 31, 2019

Checked commits agrare/manageiq-providers-ovirt@7f9ada6~...1a0117d with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
3 files checked, 0 offenses detected
Everything looks fine. 🏆

@mwperina
Copy link

mwperina commented Feb 1, 2019

Moti, could you please review?
@masayag

Copy link
Contributor

@borod108 borod108 left a comment

Choose a reason for hiding this comment

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

Looks very good to me, better and cleaner. The specs are broken thought.

@agrare
Copy link
Member Author

agrare commented Feb 1, 2019

@borod108 yeah I fixed the storages but the networks are still an issue. I tried checking what host.network_attachments returns here but in the specs it didn't return anything.

@jerryk55
Copy link
Member

jerryk55 commented Feb 1, 2019

@agrare @borod108 @roliveri unfortunately my last commit, while fixing the issue tracked here, results in the same error message that https://bugzilla.redhat.com/show_bug.cgi?id=1658240 fixed. I'm not sure if that's worse that the issue fixed by this PR or not.

@masayag
Copy link
Contributor

masayag commented Feb 6, 2019

@borod108 yeah I fixed the storages but the networks are still an issue. I tried checking what host.network_attachments returns here but in the specs it didn't return anything.

@agrare @borod108 seems like we're missing the proper method of fetching the network_attachments in this context. We should do something similar to:

https://github.com/ManageIQ/manageiq-providers-ovirt/blob/master/app/models/manageiq/providers/redhat/inventory/collector.rb#L141
connection.follow_link(host.network_attachments)

Also updated refresh recording
@mwperina
Copy link

mwperina commented Feb 6, 2019

Does anyone have an environment to quickly verify this change so we can merge?

expect(host.switches.map { |switch| [switch.uid_ems, switch.name] }).to contain_exactly(
a_collection_containing_exactly("00000000-0000-0000-0000-000000000009", "ovirtmgmt"),
a_collection_containing_exactly("5c42817f-03fb-460e-a3ab-a8770553aeee", "vlan123t")
)
expect(host.networks.count).to eq(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just wondering, if we removed this maybe we should also remove the second refresh - (line 63-64)

@masayag
Copy link
Contributor

masayag commented Feb 6, 2019

Does anyone have an environment to quickly verify this change so we can merge?

@mwperina, @borod108 uploaded a commit to this branch that incorporated the proposed changes and updated the test as well.

ATM the spec are failing, but the code fixes the issue reported by @agrare here

add_simple_target!(:storagedomains, storage.ems_ref)
end
host.switches.each do |switch|
add_simple_target!(:networks, switch.uid_ems)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is why the specs are currently failing, this should be add_simple_target!(:switches, switch.uid_ems)

add_simple_target!(:networks, attachement.network.id)
manager.with_provider_connection(VERSION_HASH) do |connection|
connection.follow_link(host.network_attachments).each do |attachement|
add_simple_target!(:networks, attachement.network.id)
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

Okay @masayag @borod108 I pushed fixes for the manager_ref as a hash failures, now it is failing on vcr errors and will have to be re-recorded.

@jerryk55
Copy link
Member

jerryk55 commented Feb 6, 2019

@agrare the last commit you made still causes the V2V Infrastructure Mapping issue for missing Networks. It does make the manager_ref as hash failure error disappear though.

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

@jerryk55 one step at a time :D

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

Okay the issue was that we were still referencing networks when building the targeted arel: https://github.com/ManageIQ/manageiq-providers-ovirt/pull/336/files#diff-c9d64b2c3fed9ede6e26aefcbcb8b276R11

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

@masayag @borod108 it looks like this might need a re-record of the VCRs (I'm not sure why since we didn't change the collectors/parsers at all!?)

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

Testing against a live rhev manager seems to indicate that this is fixed the issue, I'm seeing the same switches and lans before and after host targeted refreshes so I think this just needs a vcr re-record for the specs to pass.

@jerryk55
Copy link
Member

jerryk55 commented Feb 6, 2019

FYI - still seeing the issue. not sure if the "one step at a time" comment is still in play...

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

Hey @jerryk55 I tried to reproduce what I think the issue is on a live system and didn't see the problem anymore.
The problem being after a targeted refresh of a host duplicate switches, lans, and storages were created and then the originals deleted after another full refresh.

What issue are you still seeing ?

@agrare agrare changed the title [WIP] Host targeted refresh deleting and re-creating storage, switch, and lan records Host targeted refresh deleting and re-creating storage, switch, and lan records Feb 6, 2019
@agrare agrare added bug blocker and removed wip labels Feb 6, 2019
@jerryk55
Copy link
Member

jerryk55 commented Feb 6, 2019

Hi @agrare. Creating an Infrastructure Mapping, then running the RHEV host refresh. The Infrastructure mapping shows the Networks missing. Datastore and Cluster are ok. Prior to your change the Datastore was also showing as missing. We had debugged this a while back and saw that the ids for the networks were changed causing the issue.

@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

>> EmsRefresh.refresh(ems)
>> switches = Switch.pluck(:id, :name, :uid_ems)
=> [[1, "NFS", "ed64724b-4ece-488b-ac9e-3bcfabe09323"], [2, "ovirtmgmt", "00000000-0000-0000-0000-000000000009"]]
>> lans = Lan.pluck(:id, :name, :uid_ems)
=> [[1, "NFS", "ed64724b-4ece-488b-ac9e-3bcfabe09323"], [2, "ovirtmgmt", "00000000-0000-0000-0000-000000000009"]]
>> EmsRefresh.refresh(ems.hosts.first)
>> switches == Switch.pluck(:id, :name, :uid_ems)
=> true
>> lans == Lan.pluck(:id, :name, :uid_ems)
=> true

Looks the same to me, @jerryk55 is this on your local env or do you have a link to an appliance where you see this?

@jerryk55
Copy link
Member

jerryk55 commented Feb 6, 2019

@agrare link sent in gitter.

@borod108
Copy link
Contributor

borod108 commented Feb 6, 2019

@agrare any chance can you squash the commits and force push?

@agrare agrare force-pushed the bz_1669176_host_targeted_refresh branch from d26eced to d3d2661 Compare February 6, 2019 19:16
@agrare
Copy link
Member Author

agrare commented Feb 6, 2019

@borod108 okay I squashed the multiple vcr commits, I think the rest are helpful.

@agrare
Copy link
Member Author

agrare commented Feb 8, 2019

@borod108 / @mwperina can you take a look?

@masayag masayag merged commit 2509eda into ManageIQ:master Feb 8, 2019
@agrare
Copy link
Member Author

agrare commented Feb 8, 2019

Thanks @masayag !

@agrare agrare deleted the bz_1669176_host_targeted_refresh branch February 8, 2019 18:43
simaishi pushed a commit that referenced this pull request Feb 11, 2019
Host targeted refresh deleting and re-creating storage, switch, and lan records

(cherry picked from commit 2509eda)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1674673
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 01630df8241d85cc5030cb8daa958b61cbc8872b
Author: Moti Asayag <masayag@redhat.com>
Date:   Fri Feb 8 20:43:38 2019 +0200

    Merge pull request #336 from agrare/bz_1669176_host_targeted_refresh
    
    Host targeted refresh deleting and re-creating storage, switch, and lan records
    
    (cherry picked from commit 2509eda7fb579da4c9f31653a04a2d2269e20931)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1674673


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.

7 participants