Skip to content

Commit 7d61007

Browse files
committed
minor fixes
Signed-off-by: Britania Rodriguez Reyes <britaniar@microsoft.com>
1 parent 80e62da commit 7d61007

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

pkg/controllers/workapplier/controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ func (r *Reconciler) ensureAppliedWork(ctx context.Context, work *fleetv1beta1.W
561561
return nil, controller.NewAPIServerError(false, err)
562562
}
563563
}
564+
if err := r.spokeClient.Get(ctx, types.NamespacedName{Name: workRef.Name}, appliedWork); err != nil {
565+
klog.ErrorS(err, "Failed to get the appliedWork", "appliedWork", appliedWork.Name)
566+
return nil, controller.NewAPIServerError(false, err)
567+
}
564568
klog.InfoS("Recreated the appliedWork resource", "appliedWork", workRef.Name)
565569
return appliedWork, nil
566570
}

test/e2e/placement_apply_strategy_test.go

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,21 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
7878
})
7979

8080
AfterAll(func() {
81-
//By("removing the owner reference of the namespace")
82-
//// Remove the extra owner reference from the namespace to avoid deletion delays.
83-
//// With the new change to use foreground deletion on applied Work resources, the Work will be blocked
84-
//// from deleting until the applied work is fully deleted. If the namespace has
85-
//// multiple owner references, it won’t be deleted immediately, which can cause resource overlap
86-
//// and flakiness in subsequent tests.
87-
//removeOtherOwner(allMemberClusters[0])
88-
8981
By("deleting created work resources on member cluster")
9082
cleanWorkResourcesOnCluster(allMemberClusters[0])
9183

84+
By(fmt.Sprintf("deleting placement %s", crpName))
85+
cleanupCRP(crpName)
86+
9287
// Check if work is deleted. Needed to ensure that the Work resource is cleaned up before the next CRP is created.
9388
// This is because the Work resource is created with a finalizer that blocks deletion until the all applied work
9489
// and applied work itself is successfully deleted. If the Work resource is not deleted, it can cause resource overlap
9590
// and flakiness in subsequent tests.
9691
By("Check if work is deleted")
9792
Eventually(func() bool {
9893
work := &placementv1beta1.Work{}
99-
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: "crp-1-work", Namespace: "fleet-member-kind-cluster-1"}, work))
94+
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s-work", crpName), Namespace: fmt.Sprintf("fleet-member-%s", allMemberClusterNames[0])}, work))
10095
}, 6*eventuallyDuration, eventuallyInterval).Should(BeTrue(), "Work resource should be deleted from hub")
101-
102-
By(fmt.Sprintf("deleting placement %s", crpName))
103-
cleanupCRP(crpName)
104-
10596
})
10697

10798
It("should update CRP status as expected", func() {
@@ -166,7 +157,7 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
166157
By("Check if work is deleted")
167158
Eventually(func() bool {
168159
work := &placementv1beta1.Work{}
169-
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: "crp-1-work", Namespace: "fleet-member-kind-cluster-1"}, work))
160+
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s-work", crpName), Namespace: fmt.Sprintf("fleet-member-%s", allMemberClusterNames[0])}, work))
170161
}, 6*eventuallyDuration, eventuallyInterval).Should(BeTrue(), "Work resource should be deleted from hub")
171162

172163
By(fmt.Sprintf("deleting placement %s", crpName))
@@ -281,29 +272,21 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
281272
})
282273

283274
AfterAll(func() {
284-
//By("removing the owner reference of the namespace")
285-
//// Remove the extra owner reference from the namespace to avoid deletion delays.
286-
//// With the new change to use foreground deletion on applied Work resources, the Work will be blocked
287-
//// from deleting until the applied work is fully deleted. If the namespace has
288-
//// multiple owner references, it won’t be deleted immediately, which can cause resource overlap
289-
//// and flakiness in subsequent tests.
290-
//removeOtherOwner(allMemberClusters[0])
291-
292275
By("deleting created work resources on member cluster")
293276
cleanWorkResourcesOnCluster(allMemberClusters[0])
294277

278+
By(fmt.Sprintf("deleting placement %s", crpName))
279+
cleanupCRP(crpName)
280+
295281
// Check if work is deleted. Needed to ensure that the Work resource is cleaned up before the next CRP is created.
296282
// This is because the Work resource is created with a finalizer that blocks deletion until the all applied work
297283
// and applied work itself is successfully deleted. If the Work resource is not deleted, it can cause resource overlap
298284
// and flakiness in subsequent tests.
299285
By("Check if work is deleted")
300286
Eventually(func() bool {
301287
work := &placementv1beta1.Work{}
302-
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: "crp-1-work", Namespace: "fleet-member-kind-cluster-1"}, work))
288+
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s-work", crpName), Namespace: fmt.Sprintf("fleet-member-%s", allMemberClusterNames[0])}, work))
303289
}, 6*eventuallyDuration, eventuallyInterval).Should(BeTrue(), "Work resource should be deleted from hub")
304-
305-
By(fmt.Sprintf("deleting placement %s", crpName))
306-
cleanupCRP(crpName)
307290
})
308291

309292
It("should update CRP status as expected", func() {
@@ -434,29 +417,21 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
434417
})
435418

436419
AfterAll(func() {
437-
//By("removing the owner reference of the namespace")
438-
//// Remove the extra owner reference from the namespace to avoid deletion delays.
439-
//// With the new change to use foreground deletion on applied Work resources, the Work will be blocked
440-
//// from deleting until the applied work is fully deleted. If the namespace has
441-
//// multiple owner references, it won’t be deleted immediately, which can cause resource overlap
442-
//// and flakiness in subsequent tests.
443-
//removeOtherOwner(allMemberClusters[0])
444-
445420
By("deleting created work resources on member cluster")
446421
cleanWorkResourcesOnCluster(allMemberClusters[0])
447422

423+
By(fmt.Sprintf("deleting placement %s", crpName))
424+
cleanupCRP(crpName)
425+
448426
// Check if work is deleted. Needed to ensure that the Work resource is cleaned up before the next CRP is created.
449427
// This is because the Work resource is created with a finalizer that blocks deletion until the all applied work
450428
// and applied work itself is successfully deleted. If the Work resource is not deleted, it can cause resource overlap
451429
// and flakiness in subsequent tests.
452430
By("Check if work is deleted")
453431
Eventually(func() bool {
454432
work := &placementv1beta1.Work{}
455-
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: "crp-1-work", Namespace: "fleet-member-kind-cluster-1"}, work))
433+
return errors.IsNotFound(hubClient.Get(ctx, types.NamespacedName{Name: fmt.Sprintf("%s-work", crpName), Namespace: fmt.Sprintf("fleet-member-%s", allMemberClusterNames[0])}, work))
456434
}, 7*eventuallyDuration, eventuallyInterval).Should(BeTrue(), "Work resource should be deleted from hub")
457-
458-
By(fmt.Sprintf("deleting placement %s", crpName))
459-
cleanupCRP(crpName)
460435
})
461436

462437
It("should update CRP status as expected", func() {

test/e2e/rollout_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ var _ = Describe("placing wrapped resources using a CRP", Ordered, func() {
718718
})
719719
// job is not trackable, so we need to wait for a bit longer for each roll out
720720
It("should update CRP status as expected", func() {
721-
crpStatusUpdatedActual := customizedCRPStatusUpdatedActual(crpName, wantSelectedResources, allMemberClusterNames, nil, "1", false)
721+
crpStatusUpdatedActual := customizedCRPStatusUpdatedActual(crpName, wantSelectedResources, allMemberClusterNames, nil, "0", false)
722722
Eventually(crpStatusUpdatedActual, 6*time.Duration(unAvailablePeriodSeconds)*time.Second, eventuallyInterval).Should(Succeed(), "Failed to update CRP status as expected")
723723
})
724724

0 commit comments

Comments
 (0)