Skip to content

Commit dbb8d93

Browse files
committed
review fixes
1 parent 2520457 commit dbb8d93

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

exp/addons/api/v1beta1/clusterresourceset_types.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,22 @@ import (
2525

2626
// ClusterResourceSet's ResourcesApplied condition and corresponding reasons that will be used in v1Beta2 API version.
2727
const (
28-
// ResourcesAppliedV1beta2Condition surfaces wether the resources in the ClusterResourceSet are applied to all matching clusters.
28+
// ResourcesAppliedV1Beta2Condition surfaces wether the resources in the ClusterResourceSet are applied to all matching clusters.
2929
// This indicates all resources exist, and no errors during applying them to all clusters.
30-
ResourcesAppliedV1beta2Condition = "ResourcesApplied"
30+
ResourcesAppliedV1Beta2Condition = "ResourcesApplied"
3131

3232
// ResourcesAppliedV1beta2Reason is the reason used when all resources in the ClusterResourceSet object got applied
3333
// to all matching clusters.
3434
ResourcesAppliedV1beta2Reason = "Applied"
3535

36-
// ResourcesAppliedApplyFailedV1beta2Reason is the reason used when applying at least one of the resources to one of the matching clusters failed.
37-
ResourcesAppliedApplyFailedV1beta2Reason = "ApplyFailed"
36+
// ResourcesNotAppliedV1Beta2Reason is the reason used when applying at least one of the resources to one of the matching clusters failed.
37+
ResourcesNotAppliedV1Beta2Reason = "NotApplied"
3838

39-
// ResourcesAppliedRemoteClusterClientFailedV1beta2Reason is the reason used on failures during getting the remote cluster client.
40-
ResourcesAppliedRemoteClusterClientFailedV1beta2Reason = "RemoteClusterClientFailed"
39+
// ResourcesAppliedWrongSecretTypeV1Beta2Reason is the reason used when the Secret's type in the resource list is not supported.
40+
ResourcesAppliedWrongSecretTypeV1Beta2Reason = "WrongSecretType"
4141

42-
// ResourcesAppliedClusterMatchFailedV1beta2Reason is the reason used on failure getting clusters that match the clusterSelector.
43-
ResourcesAppliedClusterMatchFailedV1beta2Reason = "ClusterMatchFailed"
44-
45-
// ResourcesAppliedRetrievingResourceFailedV1beta2Reason is the reason used when resources are not successfully retrieved.
46-
ResourcesAppliedRetrievingResourceFailedV1beta2Reason = "RetrievingResourceFailed"
47-
48-
// ResourcesAppliedWrongSecretTypeV1beta2Reason is the reason used when the the Secret's type in the resource list is not supported.
49-
ResourcesAppliedWrongSecretTypeV1beta2Reason = "WrongSecretType"
42+
// ResourcesAppliedInternalErrorV1Beta2Reason surfaces unexpected failures when reconciling a ClusterResourceSet.
43+
ResourcesAppliedInternalErrorV1Beta2Reason = clusterv1.InternalErrorV1Beta2Reason
5044
)
5145

5246
const (

exp/addons/internal/controllers/clusterresourceset_controller.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ func (r *ClusterResourceSetReconciler) Reconcile(ctx context.Context, req ctrl.R
160160
log.Error(err, "Failed fetching clusters that matches ClusterResourceSet labels", "ClusterResourceSet", klog.KObj(clusterResourceSet))
161161
conditions.MarkFalse(clusterResourceSet, addonsv1.ResourcesAppliedCondition, addonsv1.ClusterMatchFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
162162
v1beta2conditions.Set(clusterResourceSet, metav1.Condition{
163-
Type: addonsv1.ResourcesAppliedV1beta2Condition,
163+
Type: addonsv1.ResourcesAppliedV1Beta2Condition,
164164
Status: metav1.ConditionFalse,
165-
Reason: addonsv1.ResourcesAppliedClusterMatchFailedV1beta2Reason,
166-
Message: "Failed to get Clusters by ClusterSelector",
165+
Reason: addonsv1.ResourcesAppliedInternalErrorV1Beta2Reason,
166+
Message: "Please check controller logs for errors",
167167
})
168168
return ctrl.Result{}, err
169169
}
@@ -317,18 +317,18 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
317317
if err == ErrSecretTypeNotSupported {
318318
conditions.MarkFalse(clusterResourceSet, addonsv1.ResourcesAppliedCondition, addonsv1.WrongSecretTypeReason, clusterv1.ConditionSeverityWarning, err.Error())
319319
v1beta2conditions.Set(clusterResourceSet, metav1.Condition{
320-
Type: addonsv1.ResourcesAppliedV1beta2Condition,
320+
Type: addonsv1.ResourcesAppliedV1Beta2Condition,
321321
Status: metav1.ConditionFalse,
322-
Reason: addonsv1.ResourcesAppliedWrongSecretTypeV1beta2Reason,
322+
Reason: addonsv1.ResourcesAppliedWrongSecretTypeV1Beta2Reason,
323323
Message: fmt.Sprintf("Secret type of resource %s is not supported", resource.Name),
324324
})
325325
} else {
326326
conditions.MarkFalse(clusterResourceSet, addonsv1.ResourcesAppliedCondition, addonsv1.RetrievingResourceFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
327327
v1beta2conditions.Set(clusterResourceSet, metav1.Condition{
328-
Type: addonsv1.ResourcesAppliedV1beta2Condition,
328+
Type: addonsv1.ResourcesAppliedV1Beta2Condition,
329329
Status: metav1.ConditionFalse,
330-
Reason: addonsv1.ResourcesAppliedRetrievingResourceFailedV1beta2Reason,
331-
Message: "Failed to get resource",
330+
Reason: addonsv1.ResourcesAppliedInternalErrorV1Beta2Reason,
331+
Message: "Please check controller logs for errors",
332332
})
333333

334334
// Continue without adding the error to the aggregate if we can't find the resource.
@@ -383,9 +383,9 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
383383
if err != nil {
384384
conditions.MarkFalse(clusterResourceSet, addonsv1.ResourcesAppliedCondition, addonsv1.RemoteClusterClientFailedReason, clusterv1.ConditionSeverityError, err.Error())
385385
v1beta2conditions.Set(clusterResourceSet, metav1.Condition{
386-
Type: addonsv1.ResourcesAppliedV1beta2Condition,
386+
Type: addonsv1.ResourcesAppliedV1Beta2Condition,
387387
Status: metav1.ConditionFalse,
388-
Reason: addonsv1.ResourcesAppliedRemoteClusterClientFailedV1beta2Reason,
388+
Reason: clusterv1.InternalErrorV1Beta2Reason,
389389
Message: "Please check controller logs for errors",
390390
})
391391
return err
@@ -440,9 +440,9 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
440440
log.Error(err, "Failed to apply ClusterResourceSet resource", resource.Kind, klog.KRef(clusterResourceSet.Namespace, resource.Name))
441441
conditions.MarkFalse(clusterResourceSet, addonsv1.ResourcesAppliedCondition, addonsv1.ApplyFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
442442
v1beta2conditions.Set(clusterResourceSet, metav1.Condition{
443-
Type: addonsv1.ResourcesAppliedV1beta2Condition,
443+
Type: addonsv1.ResourcesAppliedV1Beta2Condition,
444444
Status: metav1.ConditionFalse,
445-
Reason: addonsv1.ResourcesAppliedApplyFailedV1beta2Reason,
445+
Reason: addonsv1.ResourcesNotAppliedV1Beta2Reason,
446446
Message: "Failed to apply ClusterResourceSet resources to Cluster",
447447
})
448448
errList = append(errList, err)
@@ -461,7 +461,7 @@ func (r *ClusterResourceSetReconciler) ApplyClusterResourceSet(ctx context.Conte
461461

462462
conditions.MarkTrue(clusterResourceSet, addonsv1.ResourcesAppliedCondition)
463463
v1beta2conditions.Set(clusterResourceSet, metav1.Condition{
464-
Type: addonsv1.ResourcesAppliedV1beta2Condition,
464+
Type: addonsv1.ResourcesAppliedV1Beta2Condition,
465465
Status: metav1.ConditionTrue,
466466
Reason: addonsv1.ResourcesAppliedV1beta2Reason,
467467
})

exp/addons/internal/controllers/clusterresourceset_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ metadata:
899899
g.Expect(appliedCondition.Reason).To(Equal(addonsv1.ApplyFailedReason))
900900
g.Expect(appliedCondition.Message).To(ContainSubstring("creating object /v1, Kind=ConfigMap %s/cm-missing-namespace", missingNamespace))
901901

902-
appliedConditionV1Beta2 := v1beta2conditions.Get(crs, addonsv1.ResourcesAppliedV1beta2Condition)
902+
appliedConditionV1Beta2 := v1beta2conditions.Get(crs, addonsv1.ResourcesAppliedV1Beta2Condition)
903903
g.Expect(appliedConditionV1Beta2).NotTo(BeNil())
904904
g.Expect(appliedConditionV1Beta2.Status).To(BeEquivalentTo(corev1.ConditionFalse))
905905
g.Expect(appliedConditionV1Beta2.Reason).To(Equal(addonsv1.ApplyFailedReason))

0 commit comments

Comments
 (0)