Skip to content

fix(jsonfile): Create per-container log directory before opening log file - #394

Merged
aaithal merged 1 commit into
aws:mainfrom
aaithal:fix-jsonfile-mkdir-logdir
Jun 18, 2026
Merged

fix(jsonfile): Create per-container log directory before opening log file#394
aaithal merged 1 commit into
aws:mainfrom
aaithal:fix-jsonfile-mkdir-logdir

Conversation

@aaithal

@aaithal aaithal commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description of changes:

The json-file driver receives a log path whose parent directory may not exist yet. When dockerjsonfilelog.New() attempts to open the file, it fails with "no such file or directory" because the per-container subdirectory has not been created.

This change adds os.MkdirAll on the parent directory of the log path before opening the file. The directory is created with mode 02750 (setgid + owner rwx, group rx) so that files and subdirectories inherit the parent's group ownership when the parent has the setgid bit set.

Includes unit tests for directory creation and idempotency, and an e2e test that verifies the shim-logger creates the directory when it does not exist.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aaithal
aaithal requested a review from a team as a code owner June 18, 2026 05:13
…file

The json-file driver receives a log path whose parent directory may not
exist yet. Without this fix, dockerjsonfilelog.New() fails with
"no such file or directory" and the container exits immediately.

Add os.MkdirAll on the parent directory of the log path before opening
the file. The directory is created with mode 02750 (setgid + owner rwx,
group rx) so that subdirectories and files inherit the parent's group
ownership when the parent has the setgid bit set.
@aaithal
aaithal force-pushed the fix-jsonfile-mkdir-logdir branch from 925ffdb to ea068fe Compare June 18, 2026 05:19
@aaithal
aaithal merged commit 443b7e5 into aws:main Jun 18, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants