diff --git a/internal/util/ssa/patch_test.go b/internal/util/ssa/patch_test.go index a3a2fa0b32ae..4d321771c3a1 100644 --- a/internal/util/ssa/patch_test.go +++ b/internal/util/ssa/patch_test.go @@ -21,6 +21,7 @@ import ( "time" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/utils/pointer" @@ -111,6 +112,11 @@ func TestPatch(t *testing.T) { Bootstrap: clusterv1.Bootstrap{ DataSecretName: pointer.String("data-secret"), }, + InfrastructureRef: corev1.ObjectReference{ + // The namespace needs to get set here. Otherwise the defaulting webhook always sets this field again + // which would lead to an resourceVersion bump at the 3rd step and to a flaky test. + Namespace: ns.Name, + }, }, } fieldManager := "test-manager"