rancher / convoy

A Docker volume plugin, managing persistent container volumes.
Apache License 2.0
1.31k stars 135 forks source link

Multiple containers in a rancher service with same convoy volume name is pointing to same volume #40

Closed rahulgoel1985 closed 9 years ago

rahulgoel1985 commented 9 years ago

In a Rancher service, we are creating multiple containers with ebs convoy volumes. If more than one container is getting created in a single AWS instance, then only the first container is creating the vol and all other subsequent containers are mounted to the same pre-exisitng vol

e.g. A zookeeper service is created in Rancher with "ebs" convoy driver and "dev-zkdata:/var/lib/zookeeper/data" data volume. First container is being launched correctly i.e. it's creating EBS volume in AWS (let's say vol-ABC) and mounting vol-ABC to the first container. When we scale up the rancher service and adds the second container, if second container is created on the same AWS instance, second container mounts wrongly to vol-ABC instead of creating a new volume for itself.

yasker commented 9 years ago

Hi @rahulgoel1985

In the scale case, the second container would use the same volume name dev-zkdata for Docker. Docker would call into Convoy, then Convoy would check if the volume already exists, and if there is already a volume called dev-zkdata(as your case when first container created), Convoy would return that volume.

It's always expected for volume plugin to reuse the volume if the volume with that name needed to be used in the same host. The volume name is unique in the host, would always refer to the same volume.

I guess something need to be done at Rancher side if you want different volumes for each container, e.g. generate different volume names for them.

rahulgoel1985 commented 9 years ago

Hi Yasker, Thanks for the reply! It would have been useful feature if convoy could check that the volume dev-zkdata is already mounted to a container or not. If yes vol is already mounted to the container, then create a new volume else re-use the same volume. Let us know your thoughts on this.

But yes, as you said we will definitely contact rancher for this feature request.

yasker commented 9 years ago

@rahulgoel1985

In fact there is no way to tell the situation apart. Because what Docker ask Convoy is only: create/delete volume by this name, mount/umount volume by this name, show mount path of volume by this name etc. Convoy can't know how volume would be used by Docker. Convoy can only execute the Docker's request without guessing. Mounted or not is kind of judgment depends on Docker use of volume plugin API, and it's inside Docker logic. Convoy doesn't have that knowledge, and unless Docker would define it explicitly in the API and maintain it in the future, Convoy cannot integrate with that knowledge.

Also inside Convoy, for each host, volume name is unique, same volume name means the same volume. It's the fundamental definition of volume for each host, for both Docker and Convoy.

rahulgoel1985 commented 9 years ago

Thanks Yasker for your quick reply. We will follow up with Rancher on this feature request