diff --git a/pkg/operator/sync.go b/pkg/operator/sync.go index c26ccfbcca..ba636ed6b4 100644 --- a/pkg/operator/sync.go +++ b/pkg/operator/sync.go @@ -345,34 +345,44 @@ func (optr *Operator) getImageRegistryBundles() ([]mcfgv1.ImageRegistryBundle, [ // Sync cloud config on supported platform from cloud.conf available in openshift-config-managed/kube-cloud-config ConfigMap. func (optr *Operator) syncCloudConfig(spec *mcfgv1.ControllerConfigSpec, infra *configv1.Infrastructure) error { - cm, err := optr.clusterCmLister.ConfigMaps("openshift-config-managed").Get("kube-cloud-config") - if err != nil { - if apierrors.IsNotFound(err) { - if isKubeCloudConfigCMRequired(infra) { - // Return error only if the kube-cloud-config ConfigMap is required, otherwise proceeds further. - return fmt.Errorf("%s/%s configmap is required on platform %s but not found: %w", - "openshift-config-managed", "kube-cloud-config", infra.Status.PlatformStatus.Type, err) + var lastErr error + if err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, 3*time.Second, true, func(_ context.Context) (bool, error) { + cm, err := optr.clusterCmLister.ConfigMaps("openshift-config-managed").Get("kube-cloud-config") + if err != nil { + if apierrors.IsNotFound(err) { + if isKubeCloudConfigCMRequired(infra) { + // Return error only if the kube-cloud-config ConfigMap is required, otherwise proceeds further. + lastErr = fmt.Errorf("%s/%s configmap is required on platform %s but not found: %w", + "openshift-config-managed", "kube-cloud-config", infra.Status.PlatformStatus.Type, err) + return false, nil + } + return true, nil } - return nil + lastErr = err + return false, nil } - return err - } - // Read cloud.conf from openshift-config-managed/kube-cloud-config ConfigMap. - cc, err := getCloudConfigFromConfigMap(cm, "cloud.conf") - if err != nil { - if isCloudConfRequired(infra) { - // Return error only if cloud.conf is required, otherwise proceeds further. - return fmt.Errorf("%s/%s configmap must have the %s key on platform %s but not found", - "openshift-config-managed", "kube-cloud-config", "cloud.conf", infra.Status.PlatformStatus.Type) + // Read cloud.conf from openshift-config-managed/kube-cloud-config ConfigMap. + cc, err := getCloudConfigFromConfigMap(cm, "cloud.conf") + if err != nil { + if isCloudConfRequired(infra) { + // Return error only if cloud.conf is required, otherwise proceeds further. + lastErr = fmt.Errorf("%s/%s configmap must have the %s key on platform %s but not found", + "openshift-config-managed", "kube-cloud-config", "cloud.conf", infra.Status.PlatformStatus.Type) + return false, nil + } + } else { + spec.CloudProviderConfig = cc } - } else { - spec.CloudProviderConfig = cc - } - caCert, err := ctrlcommon.GetCAsFromConfigMap(cm, "ca-bundle.pem") - if err == nil { - spec.CloudProviderCAData = caCert + caCert, err := ctrlcommon.GetCAsFromConfigMap(cm, "ca-bundle.pem") + if err == nil { + spec.CloudProviderCAData = caCert + } + return true, nil + }); err != nil { + return fmt.Errorf("during kube-cloud-config check: %w", kubeErrs.NewAggregate([]error{err, lastErr})) } + return nil }