-
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
Check provisioning status with the correct tenant scoping #97
Check provisioning status with the correct tenant scoping #97
Conversation
@petrblaho @aufi it would be great if you could check whether this makes sense to you. :) |
Checked commits mansam/manageiq-providers-openstack@be0c3bb~...c5b6338 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
This is a possible fix for #66 |
LGTM +1 |
else | ||
openstack.handled_list(:servers).detect { |s| s.id == clone_task_ref } | ||
end | ||
status = instance.state.downcase.to_sym if instance.present? |
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.
Thanks for the PR. I think we should initialize status
local variable always to avoid undefined variable error since it is part of condition on line 12.
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.
status = instance.state.downcase.to_sym if instance.present?
results in status
being defined as nil
if the condition is false, so an additional initialization shouldn't be necessary.
irb(main):001:0> x = 3 if true
=> 3
irb(main):002:0> x
=> 3
irb(main):003:0> y = 3 if false
=> nil
irb(main):004:0> y
=> nil
irb(main):005:0> z
NameError: undefined local variable or method `z' for main:Object
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, thanks!
If a volume or VM is provisioned in a tenant other than the default, then using
<collection>.get()
may fail to find them during the provisioning status check because the request is scoped to the wrong tenant. This PR scopes the request to use the tenant name from the provisioning request if it is a available.This also fixes a performance problem with the cloning check, where in order to work around the scoping problem it was listing every server from every tenant. If the tenant name is available, then it will use
servers.get()
instead.(Also some minor co-located lint fixes)