Fix working directory for Docker images without home directories#489
Merged
ameowlia merged 1 commit intocloudfoundry:mainfrom Mar 13, 2026
Merged
Conversation
ameowlia
requested changes
Jan 26, 2026
Member
ameowlia
left a comment
There was a problem hiding this comment.
Unit tests please! Other than that it looks fine.
ameowlia
approved these changes
Jan 28, 2026
Member
|
I am getting a failure in one of the unit tests that were already there: |
Docker images using `adduser --no-create-home` crash when Guardian tries to set a non-existent home directory as the working directory. This causes `diego-sshd` and `launcher` processes to fail with `exit status 2` and error message `create-workdir-failed`. Add getRootDir() function that: - Uses spec.Dir if set, otherwise falls back to user's home directory - Checks if the directory exists in the container's rootFS - Falls back to `/` (which always exists) if the directory doesn't exist Fixes cloudfoundry/diego-release#1089
39d1741 to
29a621c
Compare
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.
Summary
Fixes cloudfoundry/diego-release#1089 - Intermittent
create-workdir-failedfor Docker images using system users with no home directory.Docker images using
adduser --no-create-homecrash when Guardian tries to set a non-existent home directory as the working directory. This causesdiego-sshdandlauncherprocesses to fail withexit status 2and error messagecreate-workdir-failed.Root Cause:
When
DesiredLRPdoesn't explicitly set aDirproperty, Guardian defaults to the home directory from/etc/passwd. For system users created with--no-create-home, this directory doesn't exist in the container's rootFS, causing the process creation to fail.Solution:
Added
getRootDir()function inrundmc/processes/builder.gothat:os.Stat()/(which always exists) if the directory doesn't existBackward Compatibility
Breaking Change? No
This change is backwards compatible. It only affects containers where the working directory doesn't exist (which currently crash). Containers with existing home directories continue to work as before.