@@ -46,6 +46,7 @@ import (
46
46
resourcepredicates "sigs.k8s.io/cluster-api/exp/addons/internal/controllers/predicates"
47
47
"sigs.k8s.io/cluster-api/util"
48
48
"sigs.k8s.io/cluster-api/util/conditions"
49
+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
49
50
"sigs.k8s.io/cluster-api/util/finalizers"
50
51
"sigs.k8s.io/cluster-api/util/patch"
51
52
"sigs.k8s.io/cluster-api/util/paused"
@@ -158,6 +159,12 @@ func (r *ClusterResourceSetReconciler) Reconcile(ctx context.Context, req ctrl.R
158
159
if err != nil {
159
160
log .Error (err , "Failed fetching clusters that matches ClusterResourceSet labels" , "ClusterResourceSet" , klog .KObj (clusterResourceSet ))
160
161
conditions .MarkFalse (clusterResourceSet , addonsv1 .ResourcesAppliedCondition , addonsv1 .ClusterMatchFailedReason , clusterv1 .ConditionSeverityWarning , err .Error ())
162
+ v1beta2conditions .Set (clusterResourceSet , metav1.Condition {
163
+ Type : addonsv1 .ResourcesAppliedV1Beta2Condition ,
164
+ Status : metav1 .ConditionFalse ,
165
+ Reason : addonsv1 .ResourcesAppliedInternalErrorV1Beta2Reason ,
166
+ Message : "Please check controller logs for errors" ,
167
+ })
161
168
return ctrl.Result {}, err
162
169
}
163
170
@@ -309,8 +316,20 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
309
316
if err != nil {
310
317
if err == ErrSecretTypeNotSupported {
311
318
conditions .MarkFalse (clusterResourceSet , addonsv1 .ResourcesAppliedCondition , addonsv1 .WrongSecretTypeReason , clusterv1 .ConditionSeverityWarning , err .Error ())
319
+ v1beta2conditions .Set (clusterResourceSet , metav1.Condition {
320
+ Type : addonsv1 .ResourcesAppliedV1Beta2Condition ,
321
+ Status : metav1 .ConditionFalse ,
322
+ Reason : addonsv1 .ResourcesAppliedWrongSecretTypeV1Beta2Reason ,
323
+ Message : fmt .Sprintf ("Secret type of resource %s is not supported" , resource .Name ),
324
+ })
312
325
} else {
313
326
conditions .MarkFalse (clusterResourceSet , addonsv1 .ResourcesAppliedCondition , addonsv1 .RetrievingResourceFailedReason , clusterv1 .ConditionSeverityWarning , err .Error ())
327
+ v1beta2conditions .Set (clusterResourceSet , metav1.Condition {
328
+ Type : addonsv1 .ResourcesAppliedV1Beta2Condition ,
329
+ Status : metav1 .ConditionFalse ,
330
+ Reason : addonsv1 .ResourcesAppliedInternalErrorV1Beta2Reason ,
331
+ Message : "Please check controller logs for errors" ,
332
+ })
314
333
315
334
// Continue without adding the error to the aggregate if we can't find the resource.
316
335
if apierrors .IsNotFound (err ) {
@@ -363,6 +382,12 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
363
382
remoteClient , err := r .ClusterCache .GetClient (ctx , util .ObjectKey (cluster ))
364
383
if err != nil {
365
384
conditions .MarkFalse (clusterResourceSet , addonsv1 .ResourcesAppliedCondition , addonsv1 .RemoteClusterClientFailedReason , clusterv1 .ConditionSeverityError , err .Error ())
385
+ v1beta2conditions .Set (clusterResourceSet , metav1.Condition {
386
+ Type : addonsv1 .ResourcesAppliedV1Beta2Condition ,
387
+ Status : metav1 .ConditionFalse ,
388
+ Reason : clusterv1 .InternalErrorV1Beta2Reason ,
389
+ Message : "Please check controller logs for errors" ,
390
+ })
366
391
return err
367
392
}
368
393
@@ -414,6 +439,12 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
414
439
isSuccessful = false
415
440
log .Error (err , "Failed to apply ClusterResourceSet resource" , resource .Kind , klog .KRef (clusterResourceSet .Namespace , resource .Name ))
416
441
conditions .MarkFalse (clusterResourceSet , addonsv1 .ResourcesAppliedCondition , addonsv1 .ApplyFailedReason , clusterv1 .ConditionSeverityWarning , err .Error ())
442
+ v1beta2conditions .Set (clusterResourceSet , metav1.Condition {
443
+ Type : addonsv1 .ResourcesAppliedV1Beta2Condition ,
444
+ Status : metav1 .ConditionFalse ,
445
+ Reason : addonsv1 .ResourcesNotAppliedV1Beta2Reason ,
446
+ Message : "Failed to apply ClusterResourceSet resources to Cluster" ,
447
+ })
417
448
errList = append (errList , err )
418
449
}
419
450
@@ -429,6 +460,11 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
429
460
}
430
461
431
462
conditions .MarkTrue (clusterResourceSet , addonsv1 .ResourcesAppliedCondition )
463
+ v1beta2conditions .Set (clusterResourceSet , metav1.Condition {
464
+ Type : addonsv1 .ResourcesAppliedV1Beta2Condition ,
465
+ Status : metav1 .ConditionTrue ,
466
+ Reason : addonsv1 .ResourcesAppliedV1beta2Reason ,
467
+ })
432
468
433
469
return nil
434
470
}
0 commit comments