-
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 MTU for VLAN parent interface (bsc#1024279) #1241
[3.0] network: Set MTU for VLAN parent interface (bsc#1024279) #1241
Conversation
If a physical interface has VLAN(s) configured with a custom MTU set but the underlying physical network is not used directly and has no MTU in its config, use the MTU from the VLAN interface for the parent device. If there are multiple VLANs, use the highest MTU for the parent. Also, if the physical parent from a VLAN interface is configured but the MTU is lower than one of its VLAN interfaces, abort the chef-client run and raise a useful error message. (cherry picked from commit fc4152d)
parent_nic = Nic.new(nic.parent) | ||
Chef::Log.info("vlan #{nic.name} wants mtu #{ifs[nic.name]["mtu"]} but " \ | ||
"parent #{parent_nic.name} wants no/lower mtu. Set mtu "\ | ||
"for #{parent_nic.name} to #{ifs[nic.parent]['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/StringLiteralsInInterpolation: Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation)
end | ||
end | ||
# 2) set the mtu for the parent if needed | ||
if !ifs[nic.parent].key? "mtu" || (ifs[nic.parent]["mtu"].to_i < ifs[nic.name]["mtu"].to_i) |
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/NegatedIf: Favor unless over if for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives)
Lint/RequireParentheses: Use parentheses in the method call to avoid confusion about precedence.
networks_using_parent = if_mapping.select { |net, ifaces| ifaces.include? nic.parent }.keys | ||
networks_using_parent.each do |net_name| | ||
net = Barclamp::Inventory.get_network_by_type(node, net_name) | ||
unless net.use_vlan |
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/Next: Use next to skip iteration. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals)
@Itxaka mkcloud failed here, I guess this should be triggered again. |
If a physical interface has VLAN(s) configured with a custom MTU set but
the underlying physical network is not used directly and has no MTU in
its config, use the MTU from the VLAN interface for the parent device.
If there are multiple VLANs, use the highest MTU for the parent.
Also, if the physical parent from a VLAN interface is configured but the
MTU is lower than one of its VLAN interfaces, abort the chef-client run
and raise a useful error message.
(cherry picked from commit fc4152d)
Backported as requested on #1230 by @vuntz