Skip to content

Commit cc77c16

Browse files
authored
feat: skips healthcheck for agents (#3366)
1 parent 63be3bf commit cc77c16

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

internal/web/healthcheck.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,19 @@ import (
99
func (h *handler) healthcheck(w http.ResponseWriter, r *http.Request) {
1010
log.Trace().Msg("Healthcheck request received")
1111

12-
_, errors := h.multiHostService.ListAllContainers()
13-
if len(errors) > 0 {
14-
log.Error().Err(errors[0]).Msg("Error listing containers")
15-
http.Error(w, "Error listing containers", http.StatusInternalServerError)
16-
} else {
17-
w.WriteHeader(http.StatusOK)
12+
for _, host := range h.multiHostService.Hosts() {
13+
if host.Type == "agent" {
14+
log.Debug().Str("host", host.ID).Msg("Skipping agent host")
15+
continue
16+
}
17+
18+
_, err := h.multiHostService.ListContainersForHost(host.ID)
19+
if err != nil {
20+
log.Error().Err(err).Str("host", host.ID).Msg("Error listing containers")
21+
http.Error(w, "Error listing containers", http.StatusInternalServerError)
22+
return
23+
}
1824
}
25+
26+
w.WriteHeader(http.StatusOK)
1927
}

0 commit comments

Comments
 (0)