Skip to content

Commit 8d55602

Browse files
committed
fix comments cont.
1 parent ad9bda9 commit 8d55602

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

pkg/controllers/updaterun/controller_integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,16 +435,16 @@ func generateTestApprovalRequest(name string) *placementv1alpha1.ClusterApproval
435435
}
436436

437437
func validateUpdateRunHasFinalizer(ctx context.Context, updateRun *placementv1alpha1.ClusterStagedUpdateRun) {
438-
namepsacedName := types.NamespacedName{Name: updateRun.Name}
438+
namespacedName := types.NamespacedName{Name: updateRun.Name}
439439
Eventually(func() error {
440-
if err := k8sClient.Get(ctx, namepsacedName, updateRun); err != nil {
441-
return fmt.Errorf("failed to get clusterStagedUpdateRun %s: %w", namepsacedName, err)
440+
if err := k8sClient.Get(ctx, namespacedName, updateRun); err != nil {
441+
return fmt.Errorf("failed to get clusterStagedUpdateRun %s: %w", namespacedName, err)
442442
}
443443
if !controllerutil.ContainsFinalizer(updateRun, placementv1alpha1.ClusterStagedUpdateRunFinalizer) {
444-
return fmt.Errorf("finalizer not added to clusterStagedUpdateRun %s", namepsacedName)
444+
return fmt.Errorf("finalizer not added to clusterStagedUpdateRun %s", namespacedName)
445445
}
446446
return nil
447-
}, timeout, interval).Should(Succeed(), "failed to add finalizer to clusterStagedUpdateRun %s", namepsacedName)
447+
}, timeout, interval).Should(Succeed(), "failed to add finalizer to clusterStagedUpdateRun %s", namespacedName)
448448
}
449449

450450
func validateUpdateRunIsDeleted(ctx context.Context, name types.NamespacedName) {

pkg/controllers/updaterun/initialization.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func (r *Reconciler) determinePolicySnapshot(
105105
}
106106
if len(policySnapshotList.Items) != 1 {
107107
if len(policySnapshotList.Items) > 1 {
108-
err := fmt.Errorf("more than one (%d in actual) latest policy snapshots associated with the clusterResourcePlacement: %s", len(policySnapshotList.Items), placementName)
109-
klog.ErrorS(controller.NewUnexpectedBehaviorError(err), "Failed to find the latest policy snapshot", "clusterResourcePlacement", placementName, "clusterStagedUpdateRun", updateRunRef)
108+
err := controller.NewUnexpectedBehaviorError(fmt.Errorf("more than one (%d in actual) latest policy snapshots associated with the clusterResourcePlacement: %s", len(policySnapshotList.Items), placementName))
109+
klog.ErrorS(err, "Failed to find the latest policy snapshot", "clusterResourcePlacement", placementName, "clusterStagedUpdateRun", updateRunRef)
110110
// no more retries for this error.
111111
return nil, -1, fmt.Errorf("%w: %s", errInitializedFailed, err.Error())
112112
}
@@ -122,8 +122,8 @@ func (r *Reconciler) determinePolicySnapshot(
122122

123123
// Get the cluster count from the policy snapshot.
124124
if latestPolicySnapshot.Spec.Policy == nil {
125-
nopolicyErr := fmt.Errorf("policy snapshot `%s` does not have a policy", latestPolicySnapshot.Name)
126-
klog.ErrorS(controller.NewUnexpectedBehaviorError(nopolicyErr), "Failed to get the policy from the latestPolicySnapshot", "clusterResourcePlacement", placementName, "latestPolicySnapshot", latestPolicySnapshot.Name, "clusterStagedUpdateRun", updateRunRef)
125+
nopolicyErr := controller.NewUnexpectedBehaviorError(fmt.Errorf("policy snapshot `%s` does not have a policy", latestPolicySnapshot.Name))
126+
klog.ErrorS(nopolicyErr, "Failed to get the policy from the latestPolicySnapshot", "clusterResourcePlacement", placementName, "latestPolicySnapshot", latestPolicySnapshot.Name, "clusterStagedUpdateRun", updateRunRef)
127127
// no more retries here.
128128
return nil, -1, fmt.Errorf("%w: %s", errInitializedFailed, nopolicyErr.Error())
129129
}
@@ -132,8 +132,8 @@ func (r *Reconciler) determinePolicySnapshot(
132132
if latestPolicySnapshot.Spec.Policy.PlacementType == placementv1beta1.PickNPlacementType {
133133
count, err := annotations.ExtractNumOfClustersFromPolicySnapshot(&latestPolicySnapshot)
134134
if err != nil {
135-
annErr := fmt.Errorf("%w: the policy snapshot `%s` doesn't have valid cluster count annotation", err, latestPolicySnapshot.Name)
136-
klog.ErrorS(controller.NewUnexpectedBehaviorError(annErr), "Failed to get the cluster count from the latestPolicySnapshot", "clusterResourcePlacement", placementName, "latestPolicySnapshot", latestPolicySnapshot.Name, "clusterStagedUpdateRun", updateRunRef)
135+
annErr := controller.NewUnexpectedBehaviorError(fmt.Errorf("%w: the policy snapshot `%s` doesn't have valid cluster count annotation", err, latestPolicySnapshot.Name))
136+
klog.ErrorS(annErr, "Failed to get the cluster count from the latestPolicySnapshot", "clusterResourcePlacement", placementName, "latestPolicySnapshot", latestPolicySnapshot.Name, "clusterStagedUpdateRun", updateRunRef)
137137
// no more retries here.
138138
return nil, -1, fmt.Errorf("%w, %s", errInitializedFailed, annErr.Error())
139139
}

pkg/controllers/updaterun/initialization_integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ var _ = Describe("Updaterun initialization tests", func() {
261261
By("Creating a new clusterStagedUpdateRun")
262262
Expect(k8sClient.Create(ctx, updateRun)).To(Succeed())
263263

264-
By("Validating the initialization failed")
264+
By("Validating policy snapshot details are copied to the updateRun status")
265265
Eventually(func() error {
266266
if err := k8sClient.Get(ctx, updateRunNamespacedName, updateRun); err != nil {
267267
return err
@@ -294,7 +294,7 @@ var _ = Describe("Updaterun initialization tests", func() {
294294
By("Creating a new clusterStagedUpdateRun")
295295
Expect(k8sClient.Create(ctx, updateRun)).To(Succeed())
296296

297-
By("Validating the initialization failed")
297+
By("Validating policy snapshot details are copied to the updateRun status")
298298
Eventually(func() error {
299299
if err := k8sClient.Get(ctx, updateRunNamespacedName, updateRun); err != nil {
300300
return err
@@ -326,7 +326,7 @@ var _ = Describe("Updaterun initialization tests", func() {
326326
By("Creating a new clusterStagedUpdateRun")
327327
Expect(k8sClient.Create(ctx, updateRun)).To(Succeed())
328328

329-
By("Validating the initialization failed")
329+
By("Validating policy snapshot details are copied to the updateRun status")
330330
Eventually(func() error {
331331
if err := k8sClient.Get(ctx, updateRunNamespacedName, updateRun); err != nil {
332332
return err
@@ -384,14 +384,14 @@ var _ = Describe("Updaterun initialization tests", func() {
384384
It("Should fail to initialize if the bindings are not in Scheduled or Bound state", func() {
385385
By("Creating a not scheduled clusterResourceBinding")
386386
binding := generateTestClusterResourceBinding(policySnapshot.Name, "cluster-1")
387-
binding.Spec.State = ""
387+
binding.Spec.State = placementv1beta1.BindingStateUnscheduled
388388
Expect(k8sClient.Create(ctx, binding)).To(Succeed())
389389

390390
By("Creating a new clusterStagedUpdateRun")
391391
Expect(k8sClient.Create(ctx, updateRun)).To(Succeed())
392392

393393
By("Validating the initialization failed")
394-
validateFailedInitCondition(ctx, updateRun, "state is not scheduled or bound")
394+
validateFailedInitCondition(ctx, updateRun, "state Unscheduled is not scheduled or bound")
395395

396396
By("Deleting the clusterResourceBinding")
397397
Expect(k8sClient.Delete(ctx, binding)).Should(Succeed())

0 commit comments

Comments
 (0)