Skip to content

Commit

Permalink
Wrap validation error instead of recreating
Browse files Browse the repository at this point in the history
Signed-off-by: wangchl01 <[email protected]>
  • Loading branch information
wangchenglong01 authored and tpantelis committed Nov 18, 2021
1 parent 71a2e11 commit f40880e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/routeagent_driver/cni/cni_iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package cni

import (
"context"
"fmt"
"net"

"github.com/pkg/errors"
Expand Down Expand Up @@ -89,13 +88,13 @@ func discover(clusterCIDR string) (*Interface, error) {
func AnnotateNodeWithCNIInterfaceIP(nodeName string, clientSet kubernetes.Interface, clusterCidr []string) error {
cniIface, err := Discover(clusterCidr[0])
if err != nil {
return fmt.Errorf("Discover returned error %w", err)
return errors.Wrap(err, "Discover returned error")
}

retryErr := retry.RetryOnConflict(retry.DefaultRetry, func() error {
node, err := clientSet.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
if err != nil {
return errors.Wrapf(err, "unable to get node info for node %v", nodeName)
return errors.Wrapf(err, "unable to get node info for node %q", nodeName)
}

annotations := node.GetAnnotations()
Expand All @@ -109,7 +108,7 @@ func AnnotateNodeWithCNIInterfaceIP(nodeName string, clientSet kubernetes.Interf
})

if retryErr != nil {
return errors.Wrapf(err, "error updatating node %q", nodeName)
return errors.Wrapf(retryErr, "error updatating node %q", nodeName)
}

klog.Infof("Successfully annotated node %q with cniIfaceIP %q", nodeName, cniIface.IPAddress)
Expand Down

0 comments on commit f40880e

Please sign in to comment.