@@ -55,21 +55,6 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
55
55
return ctrl.Result {}, err
56
56
}
57
57
58
- syncNeeded , err := r .isCloudConfigSyncNeeded (infra .Status .PlatformStatus , infra .Spec .CloudConfig )
59
- if err != nil {
60
- if err := r .setDegradedCondition (ctx ); err != nil {
61
- return ctrl.Result {}, fmt .Errorf ("failed to set conditions for cloud config controller: %v" , err )
62
- }
63
- return ctrl.Result {}, err
64
- }
65
- if ! syncNeeded {
66
- if err := r .setAvailableCondition (ctx ); err != nil {
67
- return ctrl.Result {}, fmt .Errorf ("failed to set conditions for cloud config controller: %v" , err )
68
- }
69
- klog .Infof ("cloud-config sync is not needed, returning early" )
70
- return ctrl.Result {}, nil
71
- }
72
-
73
58
cloudConfigTransformerFn , needsManagedConfigLookup , err := cloud .GetCloudConfigTransformer (infra .Status .PlatformStatus )
74
59
if err != nil {
75
60
klog .Errorf ("unable to get cloud config transformer function; unsupported platform" )
@@ -113,15 +98,20 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
113
98
Name : infra .Spec .CloudConfig .Name ,
114
99
Namespace : OpenshiftConfigNamespace ,
115
100
}
116
- if err := r .Get (ctx , openshiftUnmanagedCMKey , sourceCM ); err != nil {
101
+ if err := r .Get (ctx , openshiftUnmanagedCMKey , sourceCM ); err == nil {
102
+ return ctrl.Result {}, err
103
+ } else if errors .IsNotFound (err ) {
104
+ klog .Warningf ("unmanaged cloud-config is not found, falling back to default cloud config." )
105
+ } else {
117
106
klog .Errorf ("unable to get cloud-config for sync" )
118
107
if err := r .setDegradedCondition (ctx ); err != nil {
119
108
return ctrl.Result {}, fmt .Errorf ("failed to set conditions for cloud config controller: %v" , err )
120
109
}
121
- return ctrl.Result {}, err
122
110
}
123
111
}
124
112
113
+ klog .Infof ("PAST NOT FOUND" )
114
+
125
115
sourceCM , err = r .prepareSourceConfigMap (sourceCM , infra )
126
116
if err != nil {
127
117
if err := r .setDegradedCondition (ctx ); err != nil {
@@ -130,6 +120,8 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
130
120
return ctrl.Result {}, err
131
121
}
132
122
123
+ klog .Infof ("PAST PREPARE" )
124
+
133
125
if cloudConfigTransformerFn != nil {
134
126
// We ignore stuff in sourceCM.BinaryData. This isn't allowed to
135
127
// contain any key that overlaps with those found in sourceCM.Data and
@@ -144,6 +136,8 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
144
136
sourceCM .Data [defaultConfigKey ] = output
145
137
}
146
138
139
+ klog .Infof ("PAST TRANSFORM" )
140
+
147
141
targetCM := & corev1.ConfigMap {}
148
142
targetConfigMapKey := client.ObjectKey {
149
143
Namespace : r .ManagedNamespace ,
@@ -183,27 +177,6 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
183
177
return ctrl.Result {}, nil
184
178
}
185
179
186
- func (r * CloudConfigReconciler ) isCloudConfigSyncNeeded (platformStatus * configv1.PlatformStatus , infraCloudConfigRef configv1.ConfigMapFileReference ) (bool , error ) {
187
- if platformStatus == nil {
188
- return false , fmt .Errorf ("platformStatus is required" )
189
- }
190
- switch platformStatus .Type {
191
- case configv1 .AzurePlatformType ,
192
- configv1 .GCPPlatformType ,
193
- configv1 .VSpherePlatformType ,
194
- configv1 .IBMCloudPlatformType ,
195
- configv1 .PowerVSPlatformType ,
196
- configv1 .OpenStackPlatformType ,
197
- configv1 .NutanixPlatformType :
198
- return true , nil
199
- case configv1 .AWSPlatformType :
200
- // Some of AWS regions might require to sync a cloud-config, in such case reference in infra resource will be presented
201
- return infraCloudConfigRef .Name != "" , nil
202
- default :
203
- return false , nil
204
- }
205
- }
206
-
207
180
func (r * CloudConfigReconciler ) prepareSourceConfigMap (source * corev1.ConfigMap , infra * configv1.Infrastructure ) (* corev1.ConfigMap , error ) {
208
181
// Keys might be different between openshift-config/cloud-config and openshift-config-managed/kube-cloud-config
209
182
// Always use "cloud.conf" which is default one across openshift
@@ -218,10 +191,11 @@ func (r *CloudConfigReconciler) prepareSourceConfigMap(source *corev1.ConfigMap,
218
191
delete (cloudConfCm .Data , infraConfigKey )
219
192
return cloudConfCm , nil
220
193
}
221
- return nil , fmt .Errorf (
222
- "key %s specified in infra resource does not found in source configmap %s" ,
223
- infraConfigKey , client .ObjectKeyFromObject (source ),
224
- )
194
+
195
+ // If there was no relevant data in the configmap, make a default entry for it.
196
+ cloudConfCm .Data [defaultConfigKey ] = ""
197
+
198
+ return cloudConfCm , nil
225
199
}
226
200
227
201
func (r * CloudConfigReconciler ) isCloudConfigEqual (source * corev1.ConfigMap , target * corev1.ConfigMap ) bool {
0 commit comments