@@ -127,20 +127,6 @@ func TestPatch(t *testing.T) {
127
127
g .Expect (Patch (ctx , env .GetClient (), fieldManager , createObject )).To (Succeed ())
128
128
// Verify that gvk is still set
129
129
g .Expect (createObject .GroupVersionKind ()).To (Equal (initialObject .GroupVersionKind ()))
130
- // Note: We have to patch the status here to explicitly set these two status fields.
131
- // If we don't do it the Machine defaulting webhook will try to set the two fields to false.
132
- // For an unknown reason this will happen with the 2nd update call (3.) below and not before.
133
- // This means that this call would unexpectedly not cache the object because the resourceVersion
134
- // is changed because the fields are set.
135
- // It's unclear why those status fields are not already set during create (1.) or the first update (2.)
136
- // (the webhook is returning patches for the two fields in those requests as well).
137
- // To further investigate this behavior it would be necessary to debug the kube-apiserver.
138
- // Fortunately, in reality this is not an issue as the fields will be set sooner or later and then
139
- // the requests are cached.
140
- createObjectWithStatus := createObject .DeepCopy ()
141
- createObjectWithStatus .Status .BootstrapReady = false
142
- createObjectWithStatus .Status .InfrastructureReady = false
143
- g .Expect (env .Status ().Patch (ctx , createObjectWithStatus , client .MergeFrom (createObject ))).To (Succeed ())
144
130
145
131
// 2. Update the object and verify that the request was not cached as the object was changed.
146
132
// Get the original object.
@@ -161,6 +147,14 @@ func TestPatch(t *testing.T) {
161
147
// Verify that request was not cached (as it changed the object)
162
148
g .Expect (ssaCache .Has (requestIdentifier )).To (BeFalse ())
163
149
150
+ // Wait for 1 second. We are also trying to verify in this test that the resourceVersion of the Machine
151
+ // is not increased. Under some circumstances this would only happen if the timestamp in managedFields would
152
+ // be increased by 1 second.
153
+ // Please see the following issues for more context:
154
+ // * https://github.com/kubernetes-sigs/cluster-api/issues/10533
155
+ // * https://github.com/kubernetes/kubernetes/issues/124605
156
+ time .Sleep (1 * time .Second )
157
+
164
158
// 3. Repeat the same update and verify that the request was cached as the object was not changed.
165
159
// Get the original object.
166
160
originalObject = initialObject .DeepCopy ()
0 commit comments