@@ -175,7 +175,7 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, cluster *clusterv1.
175
175
log := ctrl .LoggerFrom (ctx , "cluster" , cluster .Name )
176
176
177
177
// If the bootstrap data is populated, set ready and return.
178
- if m .Spec .Bootstrap .DataSecretName != nil && m . Spec . Bootstrap . ConfigRef == nil {
178
+ if m .Spec .Bootstrap .DataSecretName != nil {
179
179
m .Status .BootstrapReady = true
180
180
conditions .MarkTrue (m , clusterv1 .BootstrapReadyCondition )
181
181
return ctrl.Result {}, nil
@@ -222,37 +222,6 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, cluster *clusterv1.
222
222
return ctrl.Result {RequeueAfter : externalReadyWait }, nil
223
223
}
224
224
225
- // If the machine is a control plane machine, check for certificate expiry information in the following places:
226
- // - As an annotation on the Machine
227
- // - As an annotation on the bootstrap config
228
- // If the certificate expiry information is found, set the Machine's status accordingly.
229
- // Note: If both values are defined the value in the machine annotation should take precedence.
230
- if util .IsControlPlaneMachine (m ) {
231
- var annotations map [string ]string
232
-
233
- // Check for certificate expiry information in the bootstrap config.
234
- annotations = bootstrapConfig .GetAnnotations ()
235
- if expiry , ok := annotations [clusterv1 .MachineCertificatesExpiryDateAnnotation ]; ok {
236
- expiryTime , err := time .Parse (time .RFC3339 , expiry )
237
- if err != nil {
238
- return ctrl.Result {}, errors .Wrap (err , "failed to parse expiry date" )
239
- }
240
- expTime := metav1 .NewTime (expiryTime )
241
- m .Status .CertificatesExpiryDate = & expTime
242
- }
243
-
244
- // Check for certificate expiry information in the machine annotation.
245
- annotations = m .GetAnnotations ()
246
- if expiry , ok := annotations [clusterv1 .MachineCertificatesExpiryDateAnnotation ]; ok {
247
- expiryTime , err := time .Parse (time .RFC3339 , expiry )
248
- if err != nil {
249
- return ctrl.Result {}, errors .Wrap (err , "failed to parse expiry date" )
250
- }
251
- expTime := metav1 .NewTime (expiryTime )
252
- m .Status .CertificatesExpiryDate = & expTime
253
- }
254
- }
255
-
256
225
// Get and set the name of the secret containing the bootstrap data.
257
226
secretName , _ , err := unstructured .NestedString (bootstrapConfig .Object , "status" , "dataSecretName" )
258
227
if err != nil {
@@ -261,11 +230,8 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, cluster *clusterv1.
261
230
return ctrl.Result {}, errors .Errorf ("retrieved empty dataSecretName from bootstrap provider for Machine %q in namespace %q" , m .Name , m .Namespace )
262
231
}
263
232
264
- if m .Spec .Bootstrap .DataSecretName == nil {
265
- m .Spec .Bootstrap .DataSecretName = pointer .StringPtr (secretName )
266
- }
233
+ m .Spec .Bootstrap .DataSecretName = pointer .StringPtr (secretName )
267
234
m .Status .BootstrapReady = true
268
- conditions .MarkTrue (m , clusterv1 .BootstrapReadyCondition )
269
235
return ctrl.Result {}, nil
270
236
}
271
237
@@ -346,3 +312,44 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, cluster *clust
346
312
m .Spec .ProviderID = pointer .StringPtr (providerID )
347
313
return ctrl.Result {}, nil
348
314
}
315
+
316
+ func (r * Reconciler ) reconcileCertificateExpiry (ctx context.Context , _ * clusterv1.Cluster , m * clusterv1.Machine ) (ctrl.Result , error ) {
317
+ var annotations map [string ]string
318
+
319
+ if ! util .IsControlPlaneMachine (m ) {
320
+ // If the machine is not a control plane machine, return early.
321
+ return ctrl.Result {}, nil
322
+ }
323
+
324
+ if m .Spec .Bootstrap .ConfigRef != nil {
325
+ bootstrapConfig , err := external .Get (ctx , r .Client , m .Spec .Bootstrap .ConfigRef , m .Namespace )
326
+ if err != nil {
327
+ return ctrl.Result {}, err
328
+ }
329
+
330
+ // Check for certificate expiry information in the bootstrap config.
331
+ annotations = bootstrapConfig .GetAnnotations ()
332
+ if expiry , ok := annotations [clusterv1 .MachineCertificatesExpiryDateAnnotation ]; ok {
333
+ expiryTime , err := time .Parse (time .RFC3339 , expiry )
334
+ if err != nil {
335
+ return ctrl.Result {}, errors .Wrap (err , "failed to parse expiry date" )
336
+ }
337
+ expTime := metav1 .NewTime (expiryTime )
338
+ m .Status .CertificatesExpiryDate = & expTime
339
+ }
340
+ }
341
+
342
+ // Check for certificate expiry information in the machine annotation.
343
+ // This should take precedence over other information.
344
+ annotations = m .GetAnnotations ()
345
+ if expiry , ok := annotations [clusterv1 .MachineCertificatesExpiryDateAnnotation ]; ok {
346
+ expiryTime , err := time .Parse (time .RFC3339 , expiry )
347
+ if err != nil {
348
+ return ctrl.Result {}, errors .Wrap (err , "failed to parse expiry date" )
349
+ }
350
+ expTime := metav1 .NewTime (expiryTime )
351
+ m .Status .CertificatesExpiryDate = & expTime
352
+ }
353
+
354
+ return ctrl.Result {}, nil
355
+ }
0 commit comments