8000 stage1: implement docker volume semantics by iaguis · Pull Request #2315 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

stage1: implement docker volume semantics #2315

Merged
merged 4 commits into from
Mar 31, 2016

Conversation

iaguis
Copy link
Member
@iaguis iaguis commented Mar 22, 2016

Docker volumes are initialized with the files in the image if they
exist, unless a host directory is mounted there (see
https://docs.docker.com/engine/userguide/containers/dockervolumes/#data-volumes).

However, when we convert docker images with docker2aci, we convert
docker volumes to mount points, and if the user doesn't specify a host
path for mounting, we mount an empty volume, effectively masking the
files in the image.

To fix this, we create a special case for the case when application uses
an image converted from docker and we mount an implicit empty volume.
In that case, we copy the files from the image to the volume, so docker
images work correctly.

Note that we won't do this if the user explicitly specifies an empty
volume or if they mount a host directory.

TODO:

  • What if the user runs a pod with several docker images with the same mount point, then the files that end up in the volume are not defined. Maybe we should make implicit empty volumes unique. Prepended the app name which is unique.
  • Tests

@iaguis iaguis added this to the v1.3.0 milestone Mar 22, 2016
@iaguis iaguis force-pushed the iaguis/docker-empty-volumes branch 3 times, most recently from 130433e to a181792 Compare March 23, 2016 14:40
@iaguis iaguis changed the title (WIP) stage1: implement docker volume semantics stage1: implement docker volume semantics Mar 29, 2016
@iaguis iaguis force-pushed the iaguis/docker-empty-volumes branch from 73959c8 to 8e999c0 Compare March 29, 2016 09:33
@iaguis iaguis force-pushed the iaguis/docker-empty-volumes branch from 8e999c0 to 04a0ea0 Compare March 30, 2016 13:43
@iaguis
Copy link
Member Author
iaguis commented Mar 30, 2016

review request

@@ -167,6 +168,11 @@ func CopyTree(src, dest string, uidRange *uid.UidRange) error {
return nil
}

fis, err := ioutil.ReadDir(dest)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really want this change? If we call CopyTree to copy some tree into a directory with some files there, then they will be deleted. Maybe we should rather have a separate function that deletes the old directory and then calls CopyTree?

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAICT, I only remove it if it's empty

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess I could call syscall.Rmdir

Copy link
Collaborator

Choose a reason for hiding this comment

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

Meh, I misread the if condition. And you can probably call os.Remove.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I just read the documentation and it should remove empty dirs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But anyway, what's the point of the change?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the destination is an empty directory, CopyTree fails and I want to be able to call it whether the destination exists (and it's empty) or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That sounds pretty arbitrary. Does CopyTree work, when destination exists and is not empty? I don't know what to expect from this function - it is not documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, it will try to Mkdir the target directory, which already exists, and fail. That's why I'm removing it if it exists and it's empty.

And yes, we must document the function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Alright, then I think it is the caller of CopyTree who should be responsible for removing the directory, even if it is empty. It might be surprising later that suddenly a directory has different permissions/mode/whatever and that happened because CopyTree just removed it and then recreated with different permissions.

iaguis added 4 commits March 31, 2016 13:26
Docker volumes are initialized with the files in the image if they
exist, unless a host directory is mounted there (see
https://docs.docker.com/engine/userguide/containers/dockervolumes/#data-volumes).

However, when we convert docker images with docker2aci, we convert
docker volumes to mount points, and if the user doesn't specify a host
path for mounting, we mount an empty volume, effectively masking the
files in the image.

To fix this, we create a special case for the case when application uses
an image converted from docker and we mount an implicit empty volume.
In that case, we copy the files from the image to the volume, so docker
images work correctly.

Note that we won't do this if the user explicitly specifies an empty
volume or if they mount a host directory.
To test Docker volume semantics, we simulate the inspect aci is a
Docker-converted image. The other tests don't care about this.
@iaguis iaguis force-pushed the iaguis/docker-empty-volumes branch from 04a0ea0 to 4ebff8a Compare March 31, 2016 11:28
@iaguis
Copy link
Member Author
iaguis commented Mar 31, 2016

Updated

@krnowak
Copy link
Collaborator
krnowak commented Mar 31, 2016

LFAD.

@yifan-gu
Copy link
Contributor
yifan-gu commented Apr 5, 2016

Awesome! Thank you guys, we can test some previous failing images now @sjpotter

// GenerateMounts maps MountPoint paths to volumes, returning a list of Mounts.
func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []schema.Mount {
func convertedFromDocker(ra *schema.RuntimeApp) bool {
ann := ra.Annotations
Copy link
Contributor

Choose a reason for hiding this comment

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

@iaguis Bad news, not working for rktnetes still, as it's using run --pod-manifest... When running from the run --pod-manifest, we don't really have the annotations in the runtime app. So probably we should check the image's annotation instead?

Copy link
Member

Choose a reason for hiding this comment

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

Right, checking the image's annotation sounds better, since it is a property of the image.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
3174
0