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

Fix storage domain issue when attaching LUN #107

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

sbernhard
Copy link

Thanks @Manisha15

@sbernhard
Copy link
Author

Workaround for https://projects.theforeman.org/issues/30199

Review would be nice @orrabin / @ShimShtein

@sbernhard sbernhard force-pushed the fix_storage_domain_nil branch 3 times, most recently from ac884be to aa0cf63 Compare December 8, 2023 14:50
@sbernhard
Copy link
Author

Thoughts on this @ShimShtein ?

@sbernhard
Copy link
Author

ping @ShimShtein :-)

Copy link
Collaborator

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

I think we don't want to push 0 as the storage domain id, if storage_domains returned nil or and empty list. If we don't use the safe navigation operator here, we will end up in the rescue block (which is not desired, I think)

I can understand that in the case of an actual error, we can assume there is at least one domain, but we can't get the list, so we assume there is only one.

lib/fog/ovirt/requests/compute/v4/list_vm_volumes.rb Outdated Show resolved Hide resolved
@sbernhard
Copy link
Author

I think we don't want to push 0 as the storage domain id, if storage_domains returned nil or and empty list. If we don't use the safe navigation operator here, we will end up in the rescue block (which is not desired, I think)

I can understand that in the case of an actual error, we can assume there is at least one domain, but we can't get the list, so we assume there is only one.

This would then not work. The original issue was:
image

So, attachment_disk.storage_domains is nil and the access to "[0]" crashes. In this case, and only in this case it should return with "0" which would then work in case of direct attached LUN disks.

Its still better to return 0 instead of crashing.

Copy link
Collaborator

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

Didn't test it, but now the code looks good.

I see three cases here:

  1. storage_domains returns one or more domains (the "happy" path), then the storage_domain property would be set to the first domain from the list
  2. storage_domains returns an empty list, then the storage_domain property should be set to nil (we didn't find a good candidate).
  3. storage_domains throws an exception, then we want to guess the storage domain id. We are setting the storage_domain property to 0, since it's our best guess.

@dosas
Copy link
Contributor

dosas commented Aug 22, 2024

@sbernhard There were quite some changes on the default branch. Could you rebase to enable the CI?

@sbernhard
Copy link
Author

@ShimShtein I had a look at the code again.

  1. in case of there is 'attachment_disk_storage_domains' first entry with an id => use this id
  2. in case of there is 'attachment_disk_storage_domains' first entry but no id field is found => nil should be returned
  3. in case of NO 'attachment_disk_storage_domains' first entry, fallback to 0

This is what https://bugzilla.redhat.com/show_bug.cgi?id=1882404#c9 suggestes and works for us.

@sbernhard
Copy link
Author

@ShimShtein can you have a look at this again, please?

@dosas
Copy link
Contributor

dosas commented Oct 2, 2024

@ShimShtein Do you think you could merge this? We do not have the necessary permissions.

@ShimShtein ShimShtein merged commit 258871d into fog:master Oct 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants