@@ -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