Repository navigation
Treat a missing log file as empty in container logs - #2393
Merged
Merged
Conversation
ContainersService.logs(id:) opened stdio.log and vminitd.log eagerly, so either one missing failed the whole request. RuntimeLinux creates both when it bootstraps a container, so one that has never been started has neither, and only RuntimeLinux writes vminitd.log, so with another runtime plugin even plain container logs failed. A missing log now reads as empty, opened as /dev/null with a debug log line; any other failure to open one still throws. /dev/null rather than FileHandle.nullDevice, which has no file descriptor: a -1 dups back as -1 over XPC and the client's fileHandles(key:) returns nil. The opens use O_NOFOLLOW, since these paths are created as regular files and following a symlink there would return its target's contents.
Code Coverage
|
jglogan
approved these changes
Oct 15, 2026
This was referenced Oct 24, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Motivation and Context
Fixes #2392.
ContainersService.logs(id:)openedstdio.logandvminitd.logeagerly, so either one missing failed the whole request. Both are created byRuntimeLinuxat bootstrap, so a container that has never been started has neither. And onlyRuntimeLinuxwritesvminitd.log, so with another runtime plugin even plaincontainer logsfailed.A missing log now reads as empty: it's opened as
/dev/null, with a debug log line. Any other failure to open a log still throws./dev/null, notFileHandle.nullDevice.nullDevicehas no file descriptor (fileDescriptoris -1). These handles go back to the client over XPC, a -1 dups back as -1, andfileHandles(key:)then returns nil, socontainer logswould still fail.O_NOFOLLOWon the opens. These are fixed paths that runtimes create as regular files, so a symlink there is never legitimate, and following one would return its target's contents. A symlink fails withELOOP, so it's refused rather than read as an empty log.fhs[0]/fhs[1]indexing is unchanged, and nothing is written into the bundle.Testing
Tests/ContainerAPIServiceTests/LogFileTests.swift(7):XPCMessageround trip whileFileHandle.nullDevicedoesn't.swift test --filter ContainerAPIServiceTestspasses (17), andmake swift-fmt-checkis clean.