fix(logs): cap streamed log reads so dockerd does not scan the full log file

Closes #7693
This commit is contained in:
Andras Bacsai
2026-11-03 22:22:22 +01:00
parent dec776025e
commit 1b571f4509
3 changed files with 15 additions and 5 deletions
@@ -221,7 +221,7 @@ describe('GetLogs browser-rendered output', function () {
->call('getLogs', '2026-09-28T10:00:02.123456789Z')
->assertReturned('2026-09-28T10:00:03Z new');
Process::assertRan(fn ($process) => str_contains(remoteProcessScript($process), 'docker logs --since 2026-09-28T10:00:02.123456789Z -t test-container'));
Process::assertRan(fn ($process) => str_contains(remoteProcessScript($process), 'docker logs --since 2026-09-28T10:00:02.123456789Z -n 50000 -t test-container'));
});
test('getLogs prefixes the streaming command with sudo for non-root servers', function () {
@@ -234,7 +234,7 @@ describe('GetLogs browser-rendered output', function () {
'container' => 'test-container',
])->call('getLogs', '2026-09-28T10:00:02Z');
Process::assertRan(fn ($process) => str_contains(remoteProcessScript($process), '(sudo docker logs --since 2026-09-28T10:00:02Z -t test-container) 2>&1 | head -c'));
Process::assertRan(fn ($process) => str_contains(remoteProcessScript($process), '(sudo docker logs --since 2026-09-28T10:00:02Z -n 50000 -t test-container) 2>&1 | head -c'));
});
test('getLogs ignores a since value that is not a docker timestamp', function (string $since) {
+1 -1
View File
@@ -180,7 +180,7 @@ it('asks each source only for lines after its own timestamp', function () {
$frankfurt = collect($commands)->first(fn (string $command): bool => str_contains($command, 'web-frankfurt'));
$helsinki = collect($commands)->first(fn (string $command): bool => str_contains($command, 'web-helsinki'));
expect($frankfurt)->toContain('--since 2026-09-28T10:00:01.123456789Z')
expect($frankfurt)->toContain('--since 2026-09-28T10:00:01.123456789Z -n 50000 -t')
->and($helsinki)->toContain('docker logs -n ')
->and($helsinki)->not->toContain('--since');
});