-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Reducing calls to checkConflictingNodes() #915
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,14 +84,17 @@ func main() { | |
node := getNode(client, nodeName) | ||
|
||
// Configure and verify the node IP addresses and subnets. | ||
configureIPsAndSubnets(node) | ||
checkConflicts := configureIPsAndSubnets(node) | ||
|
||
// If we report an IP change (v4 or v6) we should verify there are no | ||
// conflicts between Nodes. | ||
if checkConflicts && os.Getenv("DISABLE_NODE_IP_CHECK") != "true" { | ||
checkConflictingNodes(client, node) | ||
} | ||
|
||
// Configure the node AS number. | ||
configureASNumber(node) | ||
|
||
// Check for conflicting node configuration | ||
checkConflictingNodes(client, node) | ||
|
||
// Check expected filesystem | ||
ensureFilesystemAsExpected() | ||
|
||
|
@@ -235,8 +238,8 @@ func getNode(client *client.Client, nodeName string) *api.Node { | |
} | ||
|
||
// configureIPsAndSubnets updates the supplied node resource with IP and Subnet | ||
// information to use for BGP. | ||
func configureIPsAndSubnets(node *api.Node) { | ||
// information to use for BGP. This returns true if we detect a change in Node IP address. | ||
func configureIPsAndSubnets(node *api.Node) bool { | ||
// If the node resource currently has no BGP configuration, add an empty | ||
// set of configuration as it makes the processing below easier, and we | ||
// must end up configuring some BGP fields before we complete. | ||
|
@@ -245,6 +248,9 @@ func configureIPsAndSubnets(node *api.Node) { | |
node.Spec.BGP = &api.NodeBGPSpec{} | ||
} | ||
|
||
oldIpv4 := node.Spec.BGP.IPv4Address | ||
oldIpv6 := node.Spec.BGP.IPv6Address | ||
|
||
// Determine the autodetection type for IPv4 and IPv6. Note that we | ||
// only autodetect IPv4 when it has not been specified. IPv6 must be | ||
// explicitly requested using the "autodetect" value. | ||
|
@@ -308,6 +314,17 @@ func configureIPsAndSubnets(node *api.Node) { | |
validateIP(node.Spec.BGP.IPv6Address) | ||
} | ||
|
||
// Detect if we've seen the IP address change, and flag that we need to check for conflicting Nodes | ||
if oldIpv4 == nil || !node.Spec.BGP.IPv4Address.IP.Equal(oldIpv4.IP) { | ||
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. You should log in these two branches. |
||
log.Info("Node IPv4 changed, will check for conflicts") | ||
return true | ||
} | ||
if (oldIpv6 == nil && node.Spec.BGP.IPv6Address != nil) || (oldIpv6 != nil && !node.Spec.BGP.IPv6Address.IP.Equal(oldIpv6.IP)) { | ||
log.Info("Node IPv6 changed, will check for conflicts") | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
// fetchAndValidateIPAndNetwork fetches and validates the IP configuration from | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It feels like we should be more forgiving about the value that people can pass in - I think anything that resembles a boolean true should be sufficient: true t y 1 (case insensitive)
@caseydavenport @heschlie WDYT?
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.
What do we respect for other true/false variables? Seems fine/good to do, but I'm happy to merge without.
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.
Yes I'm happy to merge without too. I'll raise an issue to track better handling of boolean envs.