Skip to content

Commit eb8e591

Browse files
committed
update return values from GetCloudConfigTransformer
This change adds a boolean return value to the GetCloudConfigTransformer function to indicate when a the cloud config ConfigMap should be looked up from the CCO namespace. It is being added so that we can return a config transformer and also be able to lookup the default values from the CCO. This is primarily to address OCPBUGS-20213 which requires an updated config on Azure Stack Hub.
1 parent 5662bea commit eb8e591

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

pkg/cloud/cloud.go

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,43 @@ import (
2626
type cloudConfigTransformer func(source string, infra *configv1.Infrastructure, network *configv1.Network) (string, error)
2727

2828
// GetCloudConfigTransformer returns the function that should be used to transform
29-
// the cloud configuration config map
30-
func GetCloudConfigTransformer(platformStatus *configv1.PlatformStatus) (cloudConfigTransformer, error) {
29+
// the cloud configuration config map, and a boolean to indicate if the config should
30+
// be synced from the CCO namespace before applying the transformation.
31+
// TODO: the boolean return value to indicate if the config should be synced can be
32+
// removed once we migrate the AWS and Azure logic from the CCO to this operator.
33+
// See the FIXME comments below, and the TODO comment in the Reconcile function
34+
// inside cloud_config_sync_controller.go.
35+
func GetCloudConfigTransformer(platformStatus *configv1.PlatformStatus) (cloudConfigTransformer, bool, error) {
3136
switch platformStatus.Type {
3237
case configv1.AlibabaCloudPlatformType:
33-
return common.NoOpTransformer, nil
38+
return common.NoOpTransformer, false, nil
3439
case configv1.AWSPlatformType:
3540
// We intentionally return nil rather than NoOpTransformer since we
3641
// want to handle this differently in the caller.
3742
// FIXME: We need to implement a transformer for this. Currently we're
3843
// relying on CCO to do the heavy lifting for us.
39-
return nil, nil
44+
return nil, true, nil
4045
case configv1.AzurePlatformType:
4146
// We intentionally return nil rather than NoOpTransformer since we
4247
// want to handle this differently in the caller.
4348
// FIXME: We need to implement a transformer for this. Currently we're
4449
// relying on CCO to do the heavy lifting for us.
45-
return nil, nil
50+
return nil, true, nil
4651
case configv1.GCPPlatformType:
47-
return common.NoOpTransformer, nil
52+
return common.NoOpTransformer, false, nil
4853
case configv1.IBMCloudPlatformType:
49-
return common.NoOpTransformer, nil
54+
return common.NoOpTransformer, false, nil
5055
case configv1.OpenStackPlatformType:
51-
return openstack.CloudConfigTransformer, nil
56+
return openstack.CloudConfigTransformer, false, nil
5257
case configv1.PowerVSPlatformType:
5358
//Power VS platform uses ibm cloud provider
54-
return common.NoOpTransformer, nil
59+
return common.NoOpTransformer, false, nil
5560
case configv1.VSpherePlatformType:
56-
return vsphere.CloudConfigTransformer, nil
61+
return vsphere.CloudConfigTransformer, false, nil
5762
case configv1.NutanixPlatformType:
58-
return common.NoOpTransformer, nil
63+
return common.NoOpTransformer, false, nil
5964
default:
60-
return nil, newPlatformNotFoundError(platformStatus.Type)
65+
return nil, false, newPlatformNotFoundError(platformStatus.Type)
6166
}
6267
}
6368

pkg/controllers/cloud_config_sync_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
6969
return ctrl.Result{}, nil
7070
}
7171

72-
cloudConfigTransformerFn, err := cloud.GetCloudConfigTransformer(infra.Status.PlatformStatus)
72+
cloudConfigTransformerFn, needsManagedConfigLookup, err := cloud.GetCloudConfigTransformer(infra.Status.PlatformStatus)
7373
if err != nil {
7474
klog.Errorf("unable to get cloud config transformer function; unsupported platform")
7575
if err := r.setDegradedCondition(ctx); err != nil {
@@ -89,7 +89,7 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
8989
// CCCMO, allowing us to drop this kinda-sorta reliance on CCO stuff. We
9090
// may also wish to merge the use of cloudConfigTransformerFn into the
9191
// prepareSourceConfigMap helper function
92-
if cloudConfigTransformerFn == nil {
92+
if needsManagedConfigLookup {
9393
defaultSourceCMObjectKey := client.ObjectKey{
9494
Name: managedCloudConfigMapName,
9595
Namespace: OpenshiftManagedConfigNamespace,

0 commit comments

Comments
 (0)