-
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
[3.0] network: set max mtu of a parent to the max of its children #1230
Conversation
max_mtu_nic = all_children.max_by(&:mtu) | ||
else | ||
# parent is not a bond | ||
if ifs.key?(parent_nic.name) && |
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.
Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)
Style/IfInsideElse: Convert if nested inside else to elsif.
# parent is a bond | ||
# check bond slaves interfaces for mtu values | ||
parent_nic.slaves.each do |bond_iface| | ||
next if ifs[bond_iface.name] && |
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.
Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)
Updated with latest changes from 9c7a1b3 |
max_mtu_nic = all_children.max_by{ |k, v| v["mtu"] }[0] | ||
end | ||
ifs[nic.parent]["mtu"] = ifs[max_mtu_nic]["mtu"] | ||
parent_nic.mtu = ifs[max_mtu_nic]["mtu"] |
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/IndentationConsistency: Inconsistent indentation detected.
all_children = ifs.select { |k, v| v["parent"] == nic.parent && v.key?("mtu") } | ||
max_mtu_nic = all_children.max_by{ |k, v| v["mtu"] }[0] | ||
end | ||
ifs[nic.parent]["mtu"] = ifs[max_mtu_nic]["mtu"] |
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/IndentationConsistency: Inconsistent indentation detected.
else | ||
# no problems, set the highest mtu of all children in the same interface | ||
all_children = ifs.select { |k, v| v["parent"] == nic.parent && v.key?("mtu") } | ||
max_mtu_nic = all_children.max_by{ |k, v| v["mtu"] }[0] |
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/SpaceBeforeBlockBraces: Space missing to the left of {.
# no problems, set the highest mtu of the bond's children | ||
all_children = ifs.select { |k, v| v["parent"] == nic.parent && v.key?("mtu") } | ||
max_mtu_nic = all_children.max_by{ |k, v| v["mtu"] }[0] | ||
else |
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/ElseAlignment: Align else with if.
end | ||
# no problems, set the highest mtu of the bond's children | ||
all_children = ifs.select { |k, v| v["parent"] == nic.parent && v.key?("mtu") } | ||
max_mtu_nic = all_children.max_by{ |k, v| v["mtu"] }[0] |
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.
Lint/UselessAssignment: Useless assignment to variable - max_mtu_nic. (https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars)
Style/IndentationConsistency: Inconsistent indentation detected.
Style/SpaceBeforeBlockBraces: Space missing to the left of {.
"wants a mtu of #{ifs[nic.name]["mtu"]}. This configuration is invalid." | ||
Chef::Log.fatal(msg) | ||
raise msg | ||
end |
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.
Lint/BlockAlignment: end at 404, 10 is not aligned with parent_nic.slaves.each do |bond_iface| at 394, 8.
"custom mtu of #{ifs[bond_iface.name]["mtu"]} but children vlan #{nic.name} "\ | ||
"wants a mtu of #{ifs[nic.name]["mtu"]}. This configuration is invalid." | ||
Chef::Log.fatal(msg) | ||
raise msg |
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/IndentationConsistency: Inconsistent indentation detected.
msg = "Interface #{bond_iface.name}, part of bond #{parent_nic.name} has a "\ | ||
"custom mtu of #{ifs[bond_iface.name]["mtu"]} but children vlan #{nic.name} "\ | ||
"wants a mtu of #{ifs[nic.name]["mtu"]}. This configuration is invalid." | ||
Chef::Log.fatal(msg) |
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/IndentationConsistency: Inconsistent indentation detected.
ifs[bond_iface.name] && | ||
ifs[bond_iface.name].key?("mtu") && | ||
ifs[bond_iface.name]["mtu"] < ifs[nic.name]["mtu"] | ||
msg = "Interface #{bond_iface.name}, part of bond #{parent_nic.name} has a "\ |
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/IndentationConsistency: Inconsistent indentation detected.
# parent is a bond | ||
# check bond slaves interfaces for mtu values | ||
parent_nic.slaves.each do |bond_iface| | ||
next unless ifs[nic.name].key?("mtu") && |
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.
Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)
Style/IndentationWidth: Use 2 (not 0) spaces for indentation. (https://github.com/bbatsov/ruby-style-guide#spaces-indentation)
updated with changes from c108dba |
mkcloud HA failure seems related to manila no finding the flavor, doesnt seem to relate to this PR |
Blocked until #1241 is merged first, to preserve proper history of the changes |
For the record, this should also be blocked because #1228 is still not merged... |
I hope that was understood, even if not said :P |
iterate over all the children to obtain the max mtu that we need to set to a parent nic. Before this, only the first vlan children of a parent was used to set an mtu value, failing afterwards if the next vlan had a bigger value. (cherry picked from commit c108dba)
Needs update once #1228 is squashed and merged! |
recovered at #1371 |
iterate over all the children to obtain the max mtu that we need to
set to a parent nic. Before this, only the first vlan children of a parent
was used to set an mtu value, failing afterwards if the next vlan had a bigger
value.
(cherry picked from commit 9c7a1b3)