@@ -31,8 +31,6 @@ import (
31
31
"github.com/openshift/cluster-control-plane-machine-set-operator/test/e2e/framework"
32
32
testutils "github.com/openshift/machine-api-operator/pkg/util/testing"
33
33
34
- apierrs "k8s.io/apimachinery/pkg/api/errors"
35
- utilnet "k8s.io/apimachinery/pkg/util/net"
36
34
"sigs.k8s.io/controller-runtime/pkg/client"
37
35
"sigs.k8s.io/controller-runtime/pkg/envtest/komega"
38
36
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -144,11 +142,6 @@ var _ = Describe("Machine Reconciler", func() {
144
142
HaveField ("Status" , Equal (corev1 .ConditionTrue )),
145
143
))))
146
144
147
- By ("Transitioning the AuthoritativeAPI though 'Migrating' to MachineAPI" )
148
- Eventually (k .UpdateStatus (instance , func () {
149
- instance .Status .AuthoritativeAPI = machinev1 .MachineAuthorityMigrating
150
- })).Should (Succeed ())
151
-
152
145
// The condition should remain true whilst transitioning through 'Migrating'
153
146
// Run this in a goroutine so we don't block
154
147
@@ -164,7 +157,7 @@ var _ = Describe("Machine Reconciler", func() {
164
157
165
158
localInstance := instanceCopy .DeepCopy ()
166
159
if err := k8sClient .Get (ctx , client .ObjectKeyFromObject (localInstance ), localInstance ); err != nil {
167
- return g .Expect (err ).Should (WithTransform (isRetryableAPIError , BeTrue ()), "expected temporary error while getting machine: %v" , err )
160
+ return g .Expect (err ).Should (WithTransform (testutils . IsRetryableAPIError , BeTrue ()), "expected temporary error while getting machine: %v" , err )
168
161
}
169
162
170
163
return g .Expect (localInstance .Status .Conditions ).Should (ContainElement (SatisfyAll (
@@ -179,13 +172,18 @@ var _ = Describe("Machine Reconciler", func() {
179
172
180
173
localInstance := instanceCopy .DeepCopy ()
181
174
if err := k8sClient .Get (ctx , client .ObjectKeyFromObject (localInstance ), localInstance ); err != nil {
182
- return g .Expect (err ).Should (WithTransform (isRetryableAPIError , BeTrue ()), "expected temporary error while getting machine: %v" , err )
175
+ return g .Expect (err ).Should (WithTransform (testutils . IsRetryableAPIError , BeTrue ()), "expected temporary error while getting machine: %v" , err )
183
176
}
184
177
185
- return g .Expect (localInstance .Status .AuthoritativeAPI ).ToNot (Equal (machinev1 .MachineAuthorityMachineAPI ))
178
+ return g .Expect (localInstance .Status .AuthoritativeAPI ).To (Equal (machinev1 .MachineAuthorityMachineAPI ))
186
179
})
187
180
}()
188
181
182
+ By ("Transitioning the AuthoritativeAPI though 'Migrating' to MachineAPI" )
183
+ Eventually (k .UpdateStatus (instance , func () {
184
+ instance .Status .AuthoritativeAPI = machinev1 .MachineAuthorityMigrating
185
+ })).Should (Succeed ())
186
+
189
187
By ("Updating the AuthoritativeAPI from Migrating to MachineAPI" )
190
188
Eventually (k .UpdateStatus (instance , func () {
191
189
instance .Status .AuthoritativeAPI = machinev1 .MachineAuthorityMachineAPI
@@ -220,21 +218,3 @@ func cleanResources(namespace string) error {
220
218
221
219
return nil
222
220
}
223
-
224
- // isRetryableAPIError returns whether an API error is retryable or not.
225
- // inspired by: k8s.io/kubernetes/test/utils.
226
- func isRetryableAPIError (err error ) bool {
227
- // These errors may indicate a transient error that we can retry in tests.
228
- if apierrs .IsInternalError (err ) || apierrs .IsTimeout (err ) || apierrs .IsServerTimeout (err ) ||
229
- apierrs .IsTooManyRequests (err ) || utilnet .IsProbableEOF (err ) || utilnet .IsConnectionReset (err ) ||
230
- utilnet .IsHTTP2ConnectionLost (err ) {
231
- return true
232
- }
233
-
234
- // If the error sends the Retry-After header, we respect it as an explicit confirmation we should retry.
235
- if _ , shouldRetry := apierrs .SuggestsClientDelay (err ); shouldRetry {
236
- return true
237
- }
238
-
239
- return false
240
- }
0 commit comments