-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework mount
command string generation
#537
Rework mount
command string generation
#537
Conversation
- Move command generation logic to separate function; - Add check if `src` argument is undefined;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, can you help add a unit test to validate this fix?
…lyakov/add_proper_handling_for_src_arg_in_mount_command
Added test in 7fc4270 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - thanks @alexander-smolyakov !
Here's the spec article on anonymous volumes https://docs.docker.com/storage/volumes/#choose-the--v-or---mount-flag. Not sure why this is particularly useful, I guess so as to not clutter up a container's filesystem between starts/stops? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this!
- Could you make
source
optional in the interface:source: string; - Handle the two references to source for Docker Compose:
cli/src/spec-node/dockerCompose.ts
Line 546 in 9064c70
- ${m.source}:${m.target}`).join('')}` : ''}${gpuResources}${volumeMounts.length ? `
We will also need to update the schemas to make source optional: https://github.com/devcontainers/spec/tree/main/schemas
- Make `source` property optional in `Mount` interface; - Move logic for converting mount to volume to separate function; - Add test to cover docker compose case;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A few polishing suggestions. Thanks.
…lyakov/add_proper_handling_for_src_arg_in_mount_command
Description:
This PR addresses the issue when the Docker volume is named as
undefined
if thesrc
argument is not specified in themount
command.The issue related to the following code:
cli/src/spec-node/singleContainer.ts
Lines 359 to 364 in 7de4011
When the
mount
command string is generated, there is no check for thesrc
argument. This results in thesrc
attribute being set toundefined
when cast to a string.To fix this behavior, we need to apply null-check for the
src
argument and don't pass it to Docker. When thesrc
arg is not passed, Docker generates a random name for the volume.Repro sample:
Examples:
Without fix:
node ➜ /workspaces/devcontainers-cli (main) $ docker inspect -f '{{json .Mounts }}' a85f6e52d478
With fix:
node ➜ /workspaces/devcontainers-cli (users/alexander-smolyakov/add_proper_handling_for_src_arg_in_mount_command) $ docker inspect -f '{{json .Mounts }}' 2e77ff5392dc
Attached related issue:
Changelog:
mount
command generation logic to a separate function;src
argument is undefined;