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

Reduce API calls #2575

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions pkg/ipamd/ipamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,23 +547,30 @@ func (c *IPAMContext) nodeInit() error {
}, 30*time.Second)
}

node, err := k8sapi.GetNode(ctx, c.k8sClient)
if err != nil {
log.Errorf("Failed to get node", err)
podENIErrInc("nodeInit")
return err
}

eniConfigName, err := eniconfig.GetNodeSpecificENIConfigName(node)
if err == nil && c.useCustomNetworking && eniConfigName != "default" {
// Add the feature name to CNINode of this node
err := c.AddFeatureToCNINode(ctx, rcv1alpha1.CustomNetworking, eniConfigName)
if c.useCustomNetworking {
jchen6585 marked this conversation as resolved.
Show resolved Hide resolved
// When custom networking is enabled and a valid ENIConfig is found, IPAMD patches the CNINode
// resource for this instance. The operation is safe as enabling/disabling custom networking
// requires terminating the previous instance.
node, err := k8sapi.GetNode(ctx, c.k8sClient)
if err != nil {
log.Errorf("Failed to add feature custom networking into CNINode", err)
log.Errorf("Failed to get node", err)
podENIErrInc("nodeInit")
return err
}
log.Infof("Enabled feature %s in CNINode for node %s if not existing", rcv1alpha1.CustomNetworking, c.myNodeName)

eniConfigName, err := eniconfig.GetNodeSpecificENIConfigName(node)
if err == nil && eniConfigName != "default" {
// Add the feature name to CNINode of this node
err := c.AddFeatureToCNINode(ctx, rcv1alpha1.CustomNetworking, eniConfigName)
if err != nil {
log.Errorf("Failed to add feature custom networking into CNINode", err)
podENIErrInc("nodeInit")
return err
}
log.Infof("Enabled feature %s in CNINode for node %s if not existing", rcv1alpha1.CustomNetworking, c.myNodeName)
} else {
log.Errorf("No ENIConfig could be found for this node", err)
}
jchen6585 marked this conversation as resolved.
Show resolved Hide resolved
}

if c.enablePodENI {
Expand Down