Skip to content

Commit

Permalink
Merge pull request #8166 from sbueringer/pr-fix-test-flake-ssa
Browse files Browse the repository at this point in the history
🐛 Fix flaky TestServerSideApplyWithDefaulting test
  • Loading branch information
k8s-ci-robot authored Feb 24, 2023
2 parents c5f4e0f + fb9dd92 commit 87b19f5
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -655,15 +655,24 @@ func TestServerSideApplyWithDefaulting(t *testing.T) {
}()

// Run defaulting on the KubeadmConfigTemplate (triggered by an "external controller")
// Note: We have to retry this with eventually as it seems to take a bit of time until
// the webhook is active.
if tt.defaultOriginal {
patchKCT := kct.DeepCopy()
if patchKCT.Labels == nil {
patchKCT.Labels = map[string]string{}
}
patchKCT.Labels["trigger"] = "update"
g.Expect(env.Patch(ctx, patchKCT, client.MergeFrom(kct))).To(Succeed())
// Ensure patchKCT was defaulted.
g.Expect(patchKCT.Spec.Template.Spec.Users).To(Equal([]bootstrapv1.User{{Name: "default-user"}}))
g.Eventually(ctx, func(g Gomega) {
patchKCT := &bootstrapv1.KubeadmConfigTemplate{}
g.Expect(env.Get(ctx, client.ObjectKeyFromObject(kct), patchKCT))

if patchKCT.Labels == nil {
patchKCT.Labels = map[string]string{}
}
patchKCT.Labels["trigger"] = "update"

g.Expect(env.Patch(ctx, patchKCT, client.MergeFrom(kct))).To(Succeed())

// Ensure patchKCT was defaulted.
g.Expect(env.Get(ctx, client.ObjectKeyFromObject(kct), patchKCT))
g.Expect(patchKCT.Spec.Template.Spec.Users).To(Equal([]bootstrapv1.User{{Name: "default-user"}}))
}, 5*time.Second).Should(Succeed())
}
// Get original for the update.
original := kct.DeepCopy()
Expand Down

0 comments on commit 87b19f5

Please sign in to comment.