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

network: Ensure data returned by allocate_ip is correct #1563

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vuntz
Copy link
Member

@vuntz vuntz commented Apr 26, 2018

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.

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.
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?

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)

Copy link
Member Author

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

@vuntz vuntz force-pushed the netinfo-from-node branch 4 times, most recently from e6cb56b to 65acda8 Compare April 30, 2018 11:49
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.
@vuntz vuntz removed the wip label Apr 30, 2018
@vuntz vuntz requested a review from rhafer May 2, 2018 11:17
@@ -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)]
Copy link
Contributor

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?

@toabctl
Copy link
Contributor

toabctl commented Dec 5, 2018

@vuntz are you still interessted in workin on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants