Skip to content

Comments

[docker-29.x backport] layer: Clean up init layer if initialization fails#51826

Merged
thaJeztah merged 2 commits intomoby:docker-29.xfrom
thaJeztah:29.x_backport_45939-init-layer-cleanup
Jan 8, 2026
Merged

[docker-29.x backport] layer: Clean up init layer if initialization fails#51826
thaJeztah merged 2 commits intomoby:docker-29.xfrom
thaJeztah:29.x_backport_45939-init-layer-cleanup

Conversation

@thaJeztah
Copy link
Member

- What I did

Add cleanup for the init layer directory if any operation fails after driver.CreateReadWrite() succeeds in initMount(). Previously, failures in driver.Get(), initFunc(), or driver.Put() would leave an orphaned overlay2 directory.

Related to #45939

- How I did it

Added a defer-based cleanup with a success flag (same pattern as registerWithDescriptor()). If any operation after CreateReadWrite() fails, the init layer is removed.

- How to verify it

  • All existing layer tests pass: go test ./daemon/internal/layer/...
  • golangci-lint passes with 0 issues
  • Code review confirms the fix prevents the orphan scenario
Fix potential creation of orphaned overlay2 layers

jschfflr and others added 2 commits January 8, 2026 11:00
Add cleanup for the init layer directory if any operation fails after
driver.CreateReadWrite() succeeds in initMount(). Previously, failures
in driver.Get(), initFunc(), or driver.Put() would leave an orphaned
overlay2 directory.

Related to moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
(cherry picked from commit 3fdde52)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 26bb1af)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added this to the 29.1.4 milestone Jan 8, 2026
@thaJeztah thaJeztah marked this pull request as ready for review January 8, 2026 14:59
@thaJeztah thaJeztah merged commit 515dbc8 into moby:docker-29.x Jan 8, 2026
229 of 235 checks passed
@thaJeztah thaJeztah deleted the 29.x_backport_45939-init-layer-cleanup branch January 8, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants