-
Notifications
You must be signed in to change notification settings - Fork 59
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
network: Ensure data returned by allocate_ip is correct #1563
base: master
Are you sure you want to change the base?
Conversation
When allocate_ip is called, it returns some data representing the related network information. However, as network attributes can be overridden by having attributes on a node (to override the conduit for a specific network on that node, for instance), which is something that was not reflected here, resulting in incorrect data.
52e2c25
to
9cad67d
Compare
net_info[k] = v unless v.nil? | ||
def build_net_info(role, network, node) | ||
net_info = role.default_attributes["network"]["networks"][network].to_hash | ||
unless node.nil? || node.crowbar.nil? |
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.
Style/IfUnlessModifier: Favor modifier unless usage when having a single-line body. Another good alternative is the usage of control flow &&/||. (https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier)
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 makes the line too long... so no thanks
e6cb56b
to
65acda8
Compare
We were looking for attributes overriding the network proposal only on the node role, but this is not consistent with what the cookbook does (it looks at attributes on the node itself), and customer using this feature are more likely to edit the node directly. So reflect that by looking at the node attributes also. This is slightly tricky, as the merge of node attributes and node role attributes occur on a chef run, and in the rails app, this can be out of sync. So we do our own merge to always see the real values.
65acda8
to
d5bb352
Compare
@@ -428,13 +429,13 @@ def enable_interface(bc_instance, network, name) | |||
node.save | |||
|
|||
Rails.logger.info("Network enable_interface: Assigned: #{name} #{network}") | |||
[200, build_net_info(role, network)] | |||
[200, build_net_info(role, network, nil)] |
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.
@vuntz I might be missing something obvious by why is enable_interface passing nil
here instead of the node?
@vuntz are you still interessted in workin on this? |
When allocate_ip is called, it returns some data representing the
related network information. However, as network attributes can be
overridden by having attributes on a node (to override the conduit for a
specific network on that node, for instance), which is something that
was not reflected here, resulting in incorrect data.