bootstrapper: return error on context cancel in WaitForCilium (#1534)

This commit is contained in:
Nils Hanke 2023-03-28 14:41:17 +02:00 committed by GitHub
parent ccb31c9570
commit 8e8124345b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -252,6 +252,10 @@ func (k *KubernetesUtil) WaitForCilium(ctx context.Context, log *logger.Logger)
// wait for cilium pod to be healthy // wait for cilium pod to be healthy
client := http.Client{} client := http.Client{}
for { for {
select {
case <-ctx.Done():
return ctx.Err()
default:
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://127.0.0.1:9879/healthz", http.NoBody) req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://127.0.0.1:9879/healthz", http.NoBody)
if err != nil { if err != nil {
@ -264,11 +268,10 @@ func (k *KubernetesUtil) WaitForCilium(ctx context.Context, log *logger.Logger)
} }
resp.Body.Close() resp.Body.Close()
if resp.StatusCode == 200 { if resp.StatusCode == 200 {
break
}
}
return nil return nil
}
}
}
} }
// FixCilium fixes https://github.com/cilium/cilium/issues/19958 // FixCilium fixes https://github.com/cilium/cilium/issues/19958