@@ -226,9 +226,9 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req reconcile.Request) (r
226
226
}
227
227
228
228
if component == registryFacade {
229
- err = waitForRegistryFacade (ipAddress , port , 30 * time . Second )
229
+ err = checkegistryFacade (ipAddress , port )
230
230
if err != nil {
231
- return reconcile.Result {}, fmt . Errorf ( "waiting for registry-facade: %v" , err )
231
+ return reconcile.Result {RequeueAfter : time . Second * 10 } , err
232
232
}
233
233
}
234
234
@@ -306,13 +306,7 @@ func waitForTCPPortToBeReachable(host string, port string, timeout time.Duration
306
306
}
307
307
}
308
308
309
- func waitForRegistryFacade (host , port string , timeout time.Duration ) error {
310
- ctx , cancel := context .WithTimeout (context .Background (), timeout )
311
- defer cancel ()
312
-
313
- ticker := time .NewTicker (1 * time .Second )
314
- defer ticker .Stop ()
315
-
309
+ func checkRegistryFacade (host , port string ) error {
316
310
transport := newDefaultTransport ()
317
311
transport .TLSClientConfig = & tls.Config {
318
312
InsecureSkipVerify : true ,
@@ -323,31 +317,23 @@ func waitForRegistryFacade(host, port string, timeout time.Duration) error {
323
317
}
324
318
325
319
dummyURL := fmt .Sprintf ("https://%v:%v/v2/remote/not-a-valid-image/manifests/latest" , host , port )
320
+ req , err := http .NewRequest (http .MethodGet , dummyURL , nil )
321
+ if err != nil {
322
+ return fmt .Errorf ("unexpected error building HTTP request: %v" , err )
323
+ }
326
324
327
- for {
328
- select {
329
- case <- ctx .Done ():
330
- return fmt .Errorf ("port %v on host %v never reachable" , port , host )
331
- case <- ticker .C :
332
- req , err := http .NewRequest (http .MethodGet , dummyURL , nil )
333
- if err != nil {
334
- log .WithError (err ).Error ("unexpected error building HTTP request" )
335
- continue
336
- }
337
-
338
- req .Header .Set ("Accept" , "application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json" )
339
- resp , err := client .Do (req )
340
- if err != nil {
341
- log .WithError (err ).Error ("unexpected error during HTTP request" )
342
- continue
343
- }
344
- resp .Body .Close ()
325
+ req .Header .Set ("Accept" , "application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json" )
326
+ resp , err := client .Do (req )
327
+ if err != nil {
328
+ return fmt .Errorf ("unexpected error during HTTP request: %v" , err )
329
+ }
330
+ resp .Body .Close ()
345
331
346
- if resp .StatusCode == http .StatusNotFound {
347
- return nil
348
- }
349
- }
332
+ if resp .StatusCode == http .StatusNotFound {
333
+ return nil
350
334
}
335
+
336
+ return fmt .Errorf ("registry-facade is not ready yet" )
351
337
}
352
338
353
339
func newDefaultTransport () * http.Transport {
0 commit comments