diff --git a/cmd/sriov-network-config-daemon/start.go b/cmd/sriov-network-config-daemon/start.go index 0ab621970..465570d0e 100644 --- a/cmd/sriov-network-config-daemon/start.go +++ b/cmd/sriov-network-config-daemon/start.go @@ -14,7 +14,9 @@ import ( configv1 "github.com/openshift/api/config/v1" mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" "github.com/spf13/cobra" + corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" @@ -150,18 +152,32 @@ func runStartCmd(cmd *cobra.Command, args []string) { destdir = "/host/tmp" } - platformType := utils.Baremetal - - nodeInfo, err := kubeclient.CoreV1().Nodes().Get(context.Background(), startOpts.nodeName, v1.GetOptions{}) - if err == nil { - for key, pType := range utils.PlatformMap { - if strings.Contains(strings.ToLower(nodeInfo.Spec.ProviderID), strings.ToLower(key)) { - platformType = pType - } + backoff := wait.Backoff{ + Steps: 5, + Duration: 10 * time.Second, + Factor: 2, + } + var lastErr error + var nodeInfo *corev1.Node + if err = wait.ExponentialBackoff(backoff, func() (bool, error) { + var nodeErr error + nodeInfo, nodeErr = kubeclient.CoreV1().Nodes().Get(context.Background(), startOpts.nodeName, v1.GetOptions{}) + if nodeErr != nil { + lastErr = nodeErr + glog.Warningf("failed to obtain node %s: %v, retrying", startOpts.nodeName, nodeErr) + return false, nil } - } else { + return true, nil + }); err != nil { glog.Fatalf("Failed to fetch node state %s, %v!", startOpts.nodeName, err) } + + platformType := utils.Baremetal + for key, pType := range utils.PlatformMap { + if strings.Contains(strings.ToLower(nodeInfo.Spec.ProviderID), strings.ToLower(key)) { + platformType = pType + } + } glog.V(0).Infof("Running on platform: %s", platformType.String()) var namespace = os.Getenv("NAMESPACE")