feat: include rotated agent logs in support bundles (#26055)

Support bundles previously captured only the active coder-agent.log, losing
history across agent restarts. Add an optional `after` filter to the agent's
/debug/logs endpoint: without it the endpoint is unchanged (active log only,
10 MiB cap); with it the response includes the active log plus rotated
coder-agent-*.log files modified after the cutoff, newest first. Support
bundles request the last 24h.

Closes #25395
This commit is contained in:
Ehab Younes
2026-06-22 16:38:18 +03:00
committed by GitHub
parent adad5bdd49
commit f5cb2e547e
10 changed files with 512 additions and 30 deletions
@@ -3,6 +3,7 @@ package workspacesdk
import (
neturl "net/url"
"testing"
"time"
"github.com/stretchr/testify/require"
)
@@ -48,4 +49,22 @@ func TestAgentAPIPath(t *testing.T) {
require.Equal(t, "50", parsed.Query().Get("max_response_lines"))
require.Equal(t, "60", parsed.Query().Get("max_response_bytes"))
})
t.Run("debug logs zero after", func(t *testing.T) {
t.Parallel()
got := debugLogsPath(time.Time{})
require.Equal(t, "/debug/logs", got)
})
t.Run("debug logs after", func(t *testing.T) {
t.Parallel()
after := time.Date(2026, 5, 18, 12, 34, 56, 789, time.FixedZone("test", -7*60*60))
got := debugLogsPath(after)
parsed, err := neturl.Parse(got)
require.NoError(t, err)
require.Equal(t, "/debug/logs", parsed.Path)
require.Equal(t, after.UTC().Format(time.RFC3339Nano), parsed.Query().Get("after"))
})
}