feat: replace k8s log API streaming with filesystem tailing #11
Reference in New Issue
Block a user
Delete Branch "feat/filesystem-log-tail"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces K8s log API streaming (which was dropping every ~3 seconds at production scale, exhausting the 50-attempt reconnect cap within 2.5 minutes) with filesystem tailing via
teeto a pod log file on the shared PVC.Changes
teeto claudeInvocation to write pod log file, addedmkdir -pto init container to create log directory, addedassertSafePathComponentandbuildPodLogPathhelper with path sanitizationtailPodLogFilefunction with adaptive 250ms/1s polling (speeds up to 1s after 5 consecutive empty polls), replaced k8s log streaming withtailPodLogFileinPromise.allSettledenableRtk,rtkMaxOutputBytes)log-dedup.ts,log-dedup.test.ts(RTK output truncation no longer needed)Design
The pod's Claude command now tees stdout to a file on the shared PVC:
The adapter tails that file directly instead of using the unreliable K8s log API. Path components are sanitized to
[a-zA-Z0-9-]before use.Test Status
The 14 pending tests are
streamPodLogsOnce testsmentioned in the issue - they test the obsolete k8s log streaming approach and need to be rewritten or deleted. They usemockLogFn(k8s streaming) but the code now usestailPodLogFile(filesystem tailing). The fs mock fornode:fs/promisesin vitest does not properly intercept thenode:protocol prefix, making these tests difficult to update without significant rework.Test Plan
tailPodLogFilefunction for correctnessstreamPodLogsOncetests🤖 Generated with Claude Code