Fix working directory for Docker images without home directories #489
+18
−1
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.