@@ -160,7 +160,14 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
160
160
defer func () {
161
161
// Always attempt to patch the object and status after each reconciliation.
162
162
// Patch ObservedGeneration only if the reconciliation completed successfully
163
- patchOpts := []patch.Option {}
163
+ patchOpts := []patch.Option {
164
+ patch.WithOwnedConditions {Conditions : []clusterv1.ConditionType {
165
+ clusterv1 .RemediationAllowedCondition ,
166
+ }},
167
+ patch.WithOwnedV1Beta2Conditions {Conditions : []string {
168
+ clusterv1 .MachineHealthCheckRemediationAllowedV1Beta2Condition ,
169
+ }},
170
+ }
164
171
if reterr == nil {
165
172
patchOpts = append (patchOpts , patch.WithStatusObservedGeneration {})
166
173
}
@@ -300,7 +307,18 @@ func (r *Reconciler) reconcile(ctx context.Context, logger logr.Logger, cluster
300
307
}
301
308
errList := []error {}
302
309
for _ , t := range append (healthy , unhealthy ... ) {
303
- if err := t .patchHelper .Patch (ctx , t .Machine ); err != nil {
310
+ patchOpts := []patch.Option {
311
+ patch.WithOwnedConditions {Conditions : []clusterv1.ConditionType {
312
+ clusterv1 .MachineHealthCheckSucceededCondition ,
313
+ // Note: intentionally leaving out OwnerRemediated condition which is mostly controlled by the owner.
314
+ }},
315
+ patch.WithOwnedV1Beta2Conditions {Conditions : []string {
316
+ clusterv1 .MachineHealthCheckSucceededV1Beta2Condition ,
317
+ // Note: intentionally leaving out OwnerRemediated condition which is mostly controlled by the owner.
318
+ // (Same for ExternallyRemediated condition)
319
+ }},
320
+ }
321
+ if err := t .patchHelper .Patch (ctx , t .Machine , patchOpts ... ); err != nil {
304
322
errList = append (errList , errors .Wrapf (err , "failed to patch machine status for machine: %s/%s" , t .Machine .Namespace , t .Machine .Name ))
305
323
continue
306
324
}
@@ -380,7 +398,18 @@ func (r *Reconciler) patchHealthyTargets(ctx context.Context, logger logr.Logger
380
398
}
381
399
}
382
400
383
- if err := t .patchHelper .Patch (ctx , t .Machine ); err != nil {
401
+ patchOpts := []patch.Option {
402
+ patch.WithOwnedConditions {Conditions : []clusterv1.ConditionType {
403
+ clusterv1 .MachineHealthCheckSucceededCondition ,
404
+ // Note: intentionally leaving out OwnerRemediated condition which is mostly controlled by the owner.
405
+ }},
406
+ patch.WithOwnedV1Beta2Conditions {Conditions : []string {
407
+ clusterv1 .MachineHealthCheckSucceededV1Beta2Condition ,
408
+ // Note: intentionally leaving out OwnerRemediated condition which is mostly controlled by the owner.
409
+ // (Same for ExternallyRemediated condition)
410
+ }},
411
+ }
412
+ if err := t .patchHelper .Patch (ctx , t .Machine , patchOpts ... ); err != nil {
384
413
logger .Error (err , "failed to patch healthy machine status for machine" , "Machine" , klog .KObj (t .Machine ))
385
414
errList = append (errList , errors .Wrapf (err , "failed to patch healthy machine status for machine: %s/%s" , t .Machine .Namespace , t .Machine .Name ))
386
415
}
@@ -486,7 +515,18 @@ func (r *Reconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logg
486
515
}
487
516
}
488
517
489
- if err := t .patchHelper .Patch (ctx , t .Machine ); err != nil {
518
+ patchOpts := []patch.Option {
519
+ patch.WithOwnedConditions {Conditions : []clusterv1.ConditionType {
520
+ clusterv1 .MachineHealthCheckSucceededCondition ,
521
+ // Note: intentionally leaving out OwnerRemediated condition which is mostly controlled by the owner.
522
+ }},
523
+ patch.WithOwnedV1Beta2Conditions {Conditions : []string {
524
+ clusterv1 .MachineHealthCheckSucceededV1Beta2Condition ,
525
+ // Note: intentionally leaving out OwnerRemediated condition which is mostly controlled by the owner.
526
+ // (Same for ExternallyRemediated condition)
527
+ }},
528
+ }
529
+ if err := t .patchHelper .Patch (ctx , t .Machine , patchOpts ... ); err != nil {
490
530
errList = append (errList , errors .Wrapf (err , "failed to patch unhealthy machine status for machine: %s/%s" , t .Machine .Namespace , t .Machine .Name ))
491
531
continue
492
532
}
0 commit comments