-
Notifications
You must be signed in to change notification settings - Fork 60
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
Allow for possibility of private IP #172
Conversation
This pull request is not mergeable. Please rebase and repush. |
Redefine allowed_floating_ip_addresses. Use integers instead of strings to avoid sorting errors on UI side, and update text slightly. Update nic_id handling based on floating_ip value. Remove explicit 'None' option since UI already effectively provides it. Update nic_id handling, force scope for Azure::Armrest classes. Update expected count, and add a test, for allowed floating ips. Update test for change to cloning rules. Use options hash to distinguish between npublic IP and private IP. Default to creating a new NIC if there is a floating IP but no associated port can be found.
Checked commit https://github.com/djberg96/manageiq-providers-azure/commit/70fbc2f62b293ad1490a1530b98ae28473e6632a with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 spec/models/manageiq/providers/azure/cloud_manager/provision_spec.rb
|
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 have inserted a few questions inline
# desire for a new Public IP address vs a private IP. | ||
# | ||
if floating_ip | ||
nic_id = associated_nic || create_nic(true) |
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.
@djberg96 - In what scenario will create_nic
on this line be called? Looks like this line will only be executed if floating_ip is not nil, which means a valid floating IP was selected and there is no need to create a new one.
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.
This was something the specs caught. It's possible that a public IP exists, but isn't actually associated with a NIC yet.
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 I see. So this means when the user selects a floating ip from the drop down that is not associated with a NIC we create a new IP called "<dest_name>-PublicIp" which isn't what the user intended.
This is what we have always done, I wonder should we at least add some info logging since we are doing something the user didn't intend?
Or should we exclude any floating IPs without a NIC since they cannot be used.
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.
The other option is to just create the NIC dynamically if it's not associated with a NIC, and then associate it with the newly created NIC. Excluding them would be easier, though.
In any case, I think that's something that should be in a separate PR. I don't get the impression that people create public IP's independently of a NIC much in practice.
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.
yeah it has always been there so i think its fine if it is addressed in a separate PR.
nic_id = associated_nic || create_nic(true) | ||
else | ||
public_ip = options[:floating_ip_address].first == -1 | ||
nic_id = create_nic(public_ip) |
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 else
statement will be executed if floating_ip is nil
which would mean either:
- the floating_ip dropdown was ignored altogether
or - "New" was selected and therefore the look up in the options helper returns
nil
- refer to lookup here
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.
Correct.
if floating_ip | ||
nic_id = associated_nic || create_nic(true) | ||
else | ||
public_ip = options[:floating_ip_address].first == -1 |
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.
@djberg96 - Can you point me to where the options hash gets populated? What does this line mean?
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.
It's coming from the UI. The line in question is https://github.com/djberg96/manageiq-providers-azure/blob/70fbc2f62b293ad1490a1530b98ae28473e6632a/app/models/manageiq/providers/azure/cloud_manager/provision_workflow.rb#L30
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 was looking for the code that populates the options hash with all the valid floating Ips.
Does this line return what the user selected from the floating_ip drop down?
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'm not sure where it's populated originally, somewhere on the UI side. Yes, that line returns what the user selected as a key/value pair on a typical Rails dropdown menu. I interjected the -1 there for us to distinguish between "create new" and "not selected".
I would have preferred to use a string key to be more descriptive, but the UI code blew up when it tried to sort it.
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 reason I was looking for the code that populates the options hash is because this line returns an array of floating ips, so its a multi-select? Will first
always be -1?
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.
Oops I misspoke. The options[:floating_ip_address]
will be a two element array of the currently selected item, i.e. [-1, "New"]. If the user actually selects something, then it will be something else.
} | ||
} | ||
} | ||
|
||
# The -1 value is set in ProvisionWorkflow to distinguish between the | ||
# desire for a new Public IP address vs a private IP. |
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.
Is the word "private" correct here?
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.
Not sure what you're asking. If a Public IP isn't assigned, Azure will automatically assign a private IP.
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.
Ok, thanks
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 reality, just poking around on the Azure portal, it appears that NIC's with a public IP still have a private IP as well.
Can the key to the "New" value also be "New" instead of -1? |
Nope, the UI blew up when I tried that due to some sorting code. I started with that. :) |
Yea the key is the floating IP Id which is an integer. |
Looks great @djberg96 ! |
Allow for possibility of private IP (cherry picked from commit 9b9fba3) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1530728
Gaprindashvili backport details:
|
Allow for possibility of private IP (cherry picked from commit 9b9fba3) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1531256
Fine backport details:
|
Handle the possibility that the user may not want to assign a Public IP to a VM when provisioning since the Azure portal allows this.
WIP for now until I know for sure what the UI option is. I'll update the specs once that's settled.Addresses https://bugzilla.redhat.com/show_bug.cgi?id=1497202
On a side note, I also scoped out the Armrest related Azure classes to avoid any potential class name conflicts. We already do this in the refresh parser.