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

disconnect_storage should be called once #62

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

pkliczewski
Copy link
Contributor

During vm remove we used to call disconnect_storage. The first time
it was called as a first step of removal flow and during refresh.
This caused timing issue which caused lack of update to vm.ems_id.
As a result vm state was "unknown".

We need to make sure that disconnect_storage is called only once.

Bug-Url:
https://bugzilla.redhat.com/1468201

@pkliczewski
Copy link
Contributor Author

@borod108 @masayag please review

@pkliczewski
Copy link
Contributor Author

@pkliczewski
Copy link
Contributor Author

@miq-bot assign @borod108

@pkliczewski
Copy link
Contributor Author

@miq-bot add_label fine/yes

vm_storages = ([storage] + storages).compact.uniq
storage = vm_storages.select { |store| !vm_disks.include?(store.ems_ref) }
end
storage = if vm_disks.blank?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will work and looks more compact:
storage = vm_storages.select { |store| !vm_disks.include?(store.ems_ref) } if vm_disks.blank?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

look reasonable, will update

Copy link
Contributor

@masayag masayag Jul 18, 2017

Choose a reason for hiding this comment

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

I don't think this behaves the same as the code that @pkliczewski wrote.
In @pkliczewski there will be an assignment to storage in any case.
In your suggestion, the storage might have a previous value that won't be erased by your suggested fix.
probably need to add the else part as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masayag is right after testing the change it doesn't have the same behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

@masayag @pkliczewski yes you are right! maybe trinary expression then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@borod108 sure, we can use ternary expression

vm_storages = ([storage] + storages).compact.uniq
return if vm_storages.empty?

vm_disks = collect_disks
Copy link
Contributor

Choose a reason for hiding this comment

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

@pkliczewski Is there a possibility that inside collect_disks:
disks = hardware.disks.map { |disk| "#{disk.storage.ems_ref}/disks/#{disk.filename}" }

disk.storage will return nil ? assuming a case in which vm is connected to several storages and one of them was removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masayag No, if the disk is removed it will be not listed. According to my understanding of the code disk.storage always will have a value.

@pkliczewski
Copy link
Contributor Author

@borod108 @masayag Are you OK with this change?

@pkliczewski pkliczewski force-pushed the master branch 2 times, most recently from dec2f03 to 1bdbfeb Compare July 25, 2017 13:16
During vm remove we used to call disconnect_storage. The first time
it was called as a first step of removal flow and during refresh.
This caused timing issue which caused lack of update to vm.ems_id.
As a result vm state was "unknown".

We need to make sure that disconnect_storage is called only once.
@miq-bot
Copy link
Member

miq-bot commented Jul 25, 2017

Checked commit pkliczewski@23d516a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 0 offenses detected
Everything looks fine. 🍪

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.

LGTM

@oourfali
Copy link
Contributor

Any other review is needed? Shall we merge?

@pkliczewski
Copy link
Contributor Author

@oourfali I think that we have all the acks we need.

@oourfali oourfali merged commit c1257dd into ManageIQ:master Jul 26, 2017
@simaishi
Copy link
Contributor

simaishi commented Aug 8, 2017

Fine backport (to manageiq repo) details:

$ git log -1
commit 1a0907bce19aed801f3b01bb0c06546b2c8ac134
Author: Oved Ourfali <[email protected]>
Date:   Wed Jul 26 11:44:03 2017 +0300

    Merge pull request #62 from pkliczewski/master
    
    disconnect_storage should be called once
    (cherry picked from commit c1257ddd0e200d76a316de03261bf92c2a8cfbfa)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1479481

pkliczewski added a commit to pkliczewski/manageiq that referenced this pull request Oct 26, 2017
There were 2 PRs which fixed number of issues with this flow:
- ManageIQ#14572
- ManageIQ/manageiq-providers-ovirt#62

This commit backports all of above.

Bug-Url:
https://bugzilla.redhat.com/1497522
@simaishi
Copy link
Contributor

Backported to Euwe via ManageIQ/manageiq#16218

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.

6 participants