readiness: fix data race

Change-Id: If548f2b28d4ebaaa7d5a2127f684371fad6c2451
This commit is contained in:
Leo 2021-07-21 20:59:47 +02:00 committed by Leopold Schabel
parent e58730168d
commit 07106497f1
1 changed files with 2 additions and 0 deletions

View File

@ -49,6 +49,7 @@ func Handler(w http.ResponseWriter, r *http.Request) {
panic(err)
}
mu.Lock()
for k, v := range registry {
_, err = fmt.Fprintln(resp, fmt.Sprintf("%s\t%v", k, v))
if err != nil {
@ -59,6 +60,7 @@ func Handler(w http.ResponseWriter, r *http.Request) {
ready = false
}
}
mu.Unlock()
if !ready {
w.WriteHeader(http.StatusPreconditionFailed)