fix(codersdk/agentsdk): improve ctx cancel in agent logs flush, fix test (#10214)

Fixes #9719
Related #9865
This commit is contained in:
Mathias Fredriksson
2023-10-11 15:42:30 +03:00
committed by GitHub
parent a1ee4d44aa
commit a2cd6640f3
2 changed files with 31 additions and 9 deletions

View File

@ -344,7 +344,9 @@ func TestStartupLogsSender(t *testing.T) {
return nil
}
sendLog, flushAndClose := agentsdk.LogsSender(uuid.New(), patchLogs, slogtest.Make(t, nil).Leveled(slog.LevelDebug))
// Prevent race between auto-flush and context cancellation with
// a really long timeout.
sendLog, flushAndClose := agentsdk.LogsSender(uuid.New(), patchLogs, slogtest.Make(t, nil).Leveled(slog.LevelDebug), agentsdk.LogsSenderFlushTimeout(time.Hour))
defer func() {
_ = flushAndClose(ctx)
}()