Skip to content
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

Volume mounts need to use "Binds" API field #23947

Merged
merged 1 commit into from
Jul 1, 2016

Conversation

cpuguy83
Copy link
Member

Swarm was putting volume type mounts into the container config's
"Volumes" field, but really these need to go into "Binds".
"Volumes" is only for normal "-v /foo" volumes, not named volumes or
anything else.

I was looking at adding an integration test for this, however it dawned on me I was testing implementation detail as there is not really an easy way to actually get at the underlying container object to have a look at it, or really any good way to dive into this service.

@@ -207,7 +206,7 @@ func getMountMask(m *api.Mount) string {
func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
return &enginecontainer.HostConfig{
Resources: c.resources(),
Binds: c.bindMounts(),
Binds: append(c.bindMounts(), c.volumes()...),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And now you might see why I think the engine side API is horrible :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double check this works with an empty source...

When I tried to implement this, volumes that were just the dst/target were required to be in Volumes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we even allow an empty source?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fills in the role of an anonymous volume. It's a use case we support today and I'm not sure we can actually leave out.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok... one thing I don't like here (different topic) is docker will automatically create the volume with the given name if it doesn't already exist.

For example:

$ docker service create --mount type=volume,source=test,target=/foo busybox top

Even though we've not provided any create options, we'll get a volume with the specified name, on the local driver.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following should also work, given docker's current model:

docker service create --mount type=volume,target=/foo busybox top

It's going to be a big change to not automagically create volumes. These are declared this way all over the place, including in docker files.

The solution, as you have suggested, is to bind the lifecycle of these volumes to the scope of the container lifecycle.

@dnephin dnephin added this to the 1.12.0 milestone Jun 25, 2016
@dnephin dnephin added the kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. label Jun 25, 2016
@stevvooe
Copy link
Contributor

LGTM

Swarm was putting volume type mounts into the container config's
"Volumes" field, but really these need to go into "Binds".

😢

Does swarmkit need this fix, as well?

@stevvooe
Copy link
Contributor

Is it possible to use the mount structures directly in the engine code?

@cpuguy83
Copy link
Member Author

@stevvooe That would be nice, and ultimately what #22373 is trying to do. That PR should be adapted to whatever we end up with in the service mounts.

@stevvooe
Copy link
Contributor

@cpuguy83 bump.

Does swarmkit need this fix, as well?

I ask this because swarmkit tries to put source-less volumes in the Volumes field and the rest in binds, whereas this PR doesn't populate Volumes.

@cpuguy83
Copy link
Member Author

@stevvooe By swarmkit do you mean swarmd?

@stevvooe
Copy link
Contributor

@cpuguy83 I mean github.com/docker/swarmkit.

Swarm was putting volume type mounts into the container config's
"Volumes" field, but really these need to go into "Binds".
"Volumes" is only for normal "-v /foo" volumes, not named volumes or
anything else.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@cpuguy83
Copy link
Member Author

@stevvooe This is updated.

Will have to look at swarmkit.

@tonistiigi
Copy link
Member

LGTM

1 similar comment
@thaJeztah
Copy link
Member

LGTM

@thaJeztah thaJeztah merged commit adb4848 into moby:master Jul 1, 2016
@cpuguy83 cpuguy83 deleted the fix_mount_target branch July 1, 2016 20:24
@cpuguy83
Copy link
Member Author

cpuguy83 commented Jul 1, 2016

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. process/cherry-picked status/2-code-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants