Skip to content

Commit 5aedcdc

Browse files
committed
fix agent logic
1 parent 7c70495 commit 5aedcdc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

agent/apphealth.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, client *codersdk.Client)
6767
}
6868

6969
client := &http.Client{
70-
Timeout: time.Duration(app.Healthcheck.Interval),
70+
Timeout: time.Duration(time.Duration(app.Healthcheck.Interval) * time.Second),
7171
}
7272
err := func() error {
7373
req, err := http.NewRequestWithContext(ctx, http.MethodGet, app.Healthcheck.URL, nil)
@@ -85,9 +85,11 @@ func NewWorkspaceAppHealthReporter(logger slog.Logger, client *codersdk.Client)
8585

8686
return nil
8787
}()
88-
if err == nil {
88+
if err != nil {
89+
logger.Debug(ctx, "failed healthcheck", slog.Error(err), slog.F("app", app))
8990
mu.Lock()
9091
failures[app.Name]++
92+
logger.Debug(ctx, "failed healthcheck", slog.Error(err), slog.F("app", app), slog.F("failures", failures[app.Name]))
9193
if failures[app.Name] > int(app.Healthcheck.Threshold) {
9294
health[app.Name] = codersdk.WorkspaceAppHealthUnhealthy
9395
}

0 commit comments

Comments
 (0)