Skip to content

Commit

Permalink
Handle mismatched nodenames when setting NetworkUnavailable (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
caseydavenport authored Apr 21, 2021
1 parent 725ccb7 commit e23388d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/startup/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,15 @@ func Run() {
configureASNumber(node)

if clientset != nil {
// Determine the Kubernetes node name. Default to the Calico node name unless an explicit
// value is provided.
k8sNodeName := nodeName
if nodeRef := os.Getenv("CALICO_K8S_NODE_REF"); nodeRef != "" {
k8sNodeName = nodeRef
}

log.Info("Setting NetworkUnavailable to False")
err := setNodeNetworkUnavailableFalse(*clientset, nodeName)
err := setNodeNetworkUnavailableFalse(*clientset, k8sNodeName)
if err != nil {
log.WithError(err).Error("Unable to set NetworkUnavailable to False")
}
Expand Down Expand Up @@ -483,7 +490,6 @@ func writeNodeConfig(nodeName string) {
// been created, it returns a blank node resource.
func getNode(ctx context.Context, client client.Interface, nodeName string) *api.Node {
node, err := client.Nodes().Get(ctx, nodeName, options.GetOptions{})

if err != nil {
if _, ok := err.(cerrors.ErrorResourceDoesNotExist); !ok {
log.WithError(err).WithField("Name", nodeName).Info("Unable to query node configuration")
Expand Down

0 comments on commit e23388d

Please sign in to comment.