-
Notifications
You must be signed in to change notification settings - Fork 227
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
MGMT-20043: Modify MTU Validatin CMN to support multiple machine networks #7357
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -346,19 +346,24 @@ func (v *validator) isMtuValidAllInterfaces(c *validationContext, connectivityRe | |
|
||
// isMtuValidInMachineNetwork - intended for CMN, focusing exclusively on the MTU reports for the machine network. | ||
func (v *validator) isMtuValidInMachineNetwork(c *validationContext, connectivityReport *models.ConnectivityReport) (ValidationStatus, string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General note about this validation, I think we can improve its performance - I M worried about the time it will take to perform it on large clusters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but I'm not sure if there's a better way to optimize it. The best I can think of, though I'm not sure how much it would improve performance, is to loop over the machine networks beforehand, parse them once, and store them in a separate list to avoid repeated parsing. Other than that, I'm not sure how else we can improve it. Do you have any other suggestions? |
||
for _, machineNet := range c.cluster.MachineNetworks { | ||
_, mNetwork, err := net.ParseCIDR(string(machineNet.Cidr)) | ||
if err != nil { | ||
return ValidationError, "Internal error - failed to parse machine network CIDR" | ||
} | ||
for _, r := range connectivityReport.RemoteHosts { | ||
for _, mtuReport := range r.MtuReport { | ||
sourceIP, err := network.FindSourceIPInMachineNetwork(mtuReport.OutgoingNic, mNetwork, c.inventory.Interfaces) | ||
for _, r := range connectivityReport.RemoteHosts { | ||
for _, mtuReport := range r.MtuReport { | ||
// We are only interested in the source IP within machine networks. If it is not part of any machine network, we don't need to consider it. | ||
isSourceIPOk, err := network.IsSourceIPBelongsToAnyMachineNetwork(mtuReport.OutgoingNic, c.cluster.MachineNetworks, c.inventory.Interfaces) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I understand this check. Why do we care if the interface belongs to any machine network ? is it because we want to ignore ISCSI interfaces ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MTU check is layer 3 check right ? why do we care about machine networks at all ? if in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because in CMN, we only care about communication between interfaces within the machine networks. If the ping is sent from an interface outside the machine network, we don't want to consider it.
In CMN, the machine networks are known in advance, so we only check interfaces within those networks. In UMN, since the machine networks are not known in advance, we check all interfaces. |
||
if err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth checking for error before the other logic no ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's what I do. checking the error before if !isSourceIPOk |
||
return ValidationError, err.Error() | ||
} | ||
if !isSourceIPOk { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can move this few lines above for early skip and avoid the opposite There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how. I need the MTU report data, so I placed it right after the for loop begins. |
||
continue | ||
} | ||
remoteIP := net.ParseIP(mtuReport.RemoteIPAddress) | ||
for _, machineNet := range c.cluster.MachineNetworks { | ||
_, mNetwork, err := net.ParseCIDR(string(machineNet.Cidr)) | ||
if err != nil { | ||
return ValidationError, err.Error() | ||
return ValidationError, "Internal error - failed to parse machine network CIDR" | ||
} | ||
remoteIP := net.ParseIP(mtuReport.RemoteIPAddress) | ||
if mNetwork.Contains(remoteIP) && sourceIP != "" { | ||
// We are only interested in the remote IP within machine networks. If it is not part of any machine network, we don't need to consider it. | ||
if mNetwork.Contains(remoteIP) { | ||
linoyaslan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if !mtuReport.MtuSuccessful { | ||
return ValidationFailure, fmt.Sprintf("MTU is broken. Interface: %s, remote IP address: %s", mtuReport.OutgoingNic, mtuReport.RemoteIPAddress) | ||
} | ||
|
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.
Please also test dual stack happy and failing flow