Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 33 additions & 23 deletions pkg/operator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down