mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
bootstrapper: return error on context cancel in WaitForCilium (#1534)
This commit is contained in:
parent
ccb31c9570
commit
8e8124345b
@ -252,23 +252,26 @@ 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 {
|
||||||
time.Sleep(5 * time.Second)
|
select {
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://127.0.0.1:9879/healthz", http.NoBody)
|
case <-ctx.Done():
|
||||||
if err != nil {
|
return ctx.Err()
|
||||||
return fmt.Errorf("unable to create request: %w", err)
|
default:
|
||||||
}
|
time.Sleep(5 * time.Second)
|
||||||
resp, err := client.Do(req)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "http://127.0.0.1:9879/healthz", http.NoBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.With(zap.Error(err)).Infof("Waiting for local Cilium DaemonSet - Pod not healthy yet")
|
return fmt.Errorf("unable to create request: %w", err)
|
||||||
continue
|
}
|
||||||
}
|
resp, err := client.Do(req)
|
||||||
resp.Body.Close()
|
if err != nil {
|
||||||
if resp.StatusCode == 200 {
|
log.With(zap.Error(err)).Infof("Waiting for local Cilium DaemonSet - Pod not healthy yet")
|
||||||
break
|
continue
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
if resp.StatusCode == 200 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FixCilium fixes https://github.com/cilium/cilium/issues/19958
|
// FixCilium fixes https://github.com/cilium/cilium/issues/19958
|
||||||
|
Loading…
Reference in New Issue
Block a user