fix: agentcontainers: fix flake when ctx cancelled while running docker inspect (#18526)

Should fix https://github.com/coder/internal/issues/738
This commit is contained in:
Cian Johnston
2025-06-24 13:30:09 +01:00
committed by GitHub
parent b091b996af
commit 40667855b1
2 changed files with 20 additions and 2 deletions
+10 -2
View File
@@ -378,7 +378,11 @@ func (api *API) updaterLoop() {
// and anyone looking to interact with the API.
api.logger.Debug(api.ctx, "performing initial containers update")
if err := api.updateContainers(api.ctx); err != nil {
api.logger.Error(api.ctx, "initial containers update failed", slog.Error(err))
if errors.Is(err, context.Canceled) {
api.logger.Warn(api.ctx, "initial containers update canceled", slog.Error(err))
} else {
api.logger.Error(api.ctx, "initial containers update failed", slog.Error(err))
}
} else {
api.logger.Debug(api.ctx, "initial containers update complete")
}
@@ -399,7 +403,11 @@ func (api *API) updaterLoop() {
case api.updateTrigger <- done:
err := <-done
if err != nil {
api.logger.Error(api.ctx, "updater loop ticker failed", slog.Error(err))
if errors.Is(err, context.Canceled) {
api.logger.Warn(api.ctx, "updater loop ticker canceled", slog.Error(err))
} else {
api.logger.Error(api.ctx, "updater loop ticker failed", slog.Error(err))
}
}
default:
api.logger.Debug(api.ctx, "updater loop ticker skipped, update in progress")