Skip to content

Commit 87b19f5

Browse files
authored
Merge pull request #8166 from sbueringer/pr-fix-test-flake-ssa
🐛 Fix flaky TestServerSideApplyWithDefaulting test
2 parents c5f4e0f + fb9dd92 commit 87b19f5

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

internal/controllers/topology/cluster/structuredmerge/serversidepathhelper_test.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -655,15 +655,24 @@ func TestServerSideApplyWithDefaulting(t *testing.T) {
655655
}()
656656

657657
// Run defaulting on the KubeadmConfigTemplate (triggered by an "external controller")
658+
// Note: We have to retry this with eventually as it seems to take a bit of time until
659+
// the webhook is active.
658660
if tt.defaultOriginal {
659-
patchKCT := kct.DeepCopy()
660-
if patchKCT.Labels == nil {
661-
patchKCT.Labels = map[string]string{}
662-
}
663-
patchKCT.Labels["trigger"] = "update"
664-
g.Expect(env.Patch(ctx, patchKCT, client.MergeFrom(kct))).To(Succeed())
665-
// Ensure patchKCT was defaulted.
666-
g.Expect(patchKCT.Spec.Template.Spec.Users).To(Equal([]bootstrapv1.User{{Name: "default-user"}}))
661+
g.Eventually(ctx, func(g Gomega) {
662+
patchKCT := &bootstrapv1.KubeadmConfigTemplate{}
663+
g.Expect(env.Get(ctx, client.ObjectKeyFromObject(kct), patchKCT))
664+
665+
if patchKCT.Labels == nil {
666+
patchKCT.Labels = map[string]string{}
667+
}
668+
patchKCT.Labels["trigger"] = "update"
669+
670+
g.Expect(env.Patch(ctx, patchKCT, client.MergeFrom(kct))).To(Succeed())
671+
672+
// Ensure patchKCT was defaulted.
673+
g.Expect(env.Get(ctx, client.ObjectKeyFromObject(kct), patchKCT))
674+
g.Expect(patchKCT.Spec.Template.Spec.Users).To(Equal([]bootstrapv1.User{{Name: "default-user"}}))
675+
}, 5*time.Second).Should(Succeed())
667676
}
668677
// Get original for the update.
669678
original := kct.DeepCopy()

0 commit comments

Comments
 (0)