mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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"))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user