From 89f5721a3ab8abf56047577f3c531107def3dee0 Mon Sep 17 00:00:00 2001 From: Manuel Buil Date: Fri, 15 Oct 2021 07:27:35 +0200 Subject: [PATCH] Fix race condition in cloud provider Signed-off-by: Manuel Buil --- pkg/cloudprovider/instances.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/cloudprovider/instances.go b/pkg/cloudprovider/instances.go index a909a24562..dd209a1046 100644 --- a/pkg/cloudprovider/instances.go +++ b/pkg/cloudprovider/instances.go @@ -36,9 +36,12 @@ func (k *k3s) InstanceID(ctx context.Context, nodeName types.NodeName) (string, return "", errors.New("Node informer has not synced yet") } - _, err := k.nodeInformer.Lister().Get(string(nodeName)) + node, err := k.nodeInformer.Lister().Get(string(nodeName)) if err != nil { - return "", fmt.Errorf("Failed to find node %s: %v", nodeName, err) + return "", fmt.Errorf("failed to get node %s: %w", nodeName, err) + } + if (node.Annotations[InternalIPKey] == "") && (node.Labels[InternalIPKey] == "") { + return string(nodeName), errors.New("address annotations not yet set") } return string(nodeName), nil }