Skip to content

Conversation

@rudyfly
Copy link
Collaborator

@rudyfly rudyfly commented Apr 16, 2018

Ⅰ. Describe what this PR did

Add volumes-from for container, container can use the volumes of another
containers. The format is <containerID>[:mode]

Ⅱ. Does this pull request fix one issue?

fixes #463

Ⅲ. Describe how you did it

Ⅳ. Describe how to verify it

  1. create old container with volume
# pouch volume create -n test-volume
CreatedAt:    2018-4-16 14:46:18
Driver:       local
Labels:       map[]
Mountpoint:   /mnt/local/test-volume
Name:         test-volume
Scope:
Status:       map[sifter:Default]

# pouch run -d --name volumes-from-test -v test-volume:/mnt registry.hub.docker.com/library/busybox:latest top
6203151a7134ae9305cbeddba90c874d76eff9bf345cc30a9e34277d89a4d7d4
  1. stop old container
# pouch stop volumes-from-test
  1. create new container with old container's volume
# pouch run -d --volumes-from 6203151a7134ae9305cbeddba90c874d76eff9bf345cc30a9e34277d89a4d7d4 registry.hub.docker.com/library/busybox:latest top
6821c74073fb6a2262b1c00aa2ceaabc47463e06f4e6e718e8827889afd83492

Ⅴ. Special notes for reviews

Signed-off-by: Rudy Zhang [email protected]

@codecov-io
Copy link

codecov-io commented Apr 16, 2018

Codecov Report

Merging #1131 into master will decrease coverage by 0.24%.
The diff coverage is 54.45%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1131      +/-   ##
==========================================
- Coverage   15.57%   15.33%   -0.25%     
==========================================
  Files         172      173       +1     
  Lines        9727     9782      +55     
==========================================
- Hits         1515     1500      -15     
- Misses       8103     8174      +71     
+ Partials      109      108       -1
Impacted Files Coverage Δ
cli/container.go 0% <0%> (ø) ⬆️
cli/common_flags.go 0% <0%> (ø) ⬆️
daemon/mgr/container.go 0% <0%> (-4.6%) ⬇️
pkg/opts/mountpoint.go 84.61% <84.61%> (ø)
pkg/utils/utils.go 75.64% <0%> (-2.52%) ⬇️
cli/cli.go 0% <0%> (ø) ⬆️
pkg/randomid/id.go 75% <0%> (ø) ⬆️
client/client.go 39.39% <0%> (+10.82%) ⬆️

flagSet.StringVar(&c.utsMode, "uts", "", "UTS namespace to use")

flagSet.StringSliceVarP(&c.volume, "volume", "v", nil, "Bind mount volumes to container, format is: [source:]<destination>[:mode], [source] can be volume or host's path, <destination> is container's path, [mode] can be \"ro/rw/dr/rr/z/Z/nocopy/private/rprivate/slave/rslave/shared/rshared\"")
flagSet.StringSliceVar(&c.volumesFrom, "volumes-from", nil, "set volumes from other containers, format is <container>[:mode]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is other container, since we cannot set volumes for multiple containers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think so, the api VolumesFrom is a slice, it means it can use more than one container's volumes.

return arr, nil
}

func parseVolumesFrom(volume string) (string, string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this part into pkg opts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK

@allencloud
Copy link
Collaborator

Could we add some integration test for this PR. Thanks a lot. @rudyfly

@Letty5411
Copy link
Contributor

Letty5411 commented Apr 17, 2018

May I give some suggestions about integration tests, I would prefer tests like following:
Negative test:
2. create a container with volumes from a non-existing container
3. create a container with volumes from a container without volumes
4. create container A with volumes V1, remove V1, create container B with volumes from container A

Positive test:

  1. create container with volumes from a container with more than two volumes, verify these volumes
  2. create container B with volumes from container A, then create container C with volumes from container B?
  3. upgrade container with different volumes from different container
  4. create container A with volumes from two containers B and C
  5. test different mode could work, like mode="" default is RW, mode="R", can't write
  6. create a container with volumes from a running/stopped/exited/paused container
  7. create a volume V1, create a container A with volume V1, create container B with volume V1 and volumes from container A.

for _, line := range strings.Split(out, "\n") {
if strings.Contains(line, "\"volumesfrom-test-volume\": \"/mnt\"") {
volumeFound = true
continue
Copy link
Collaborator

Choose a reason for hiding this comment

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

break?

Add volumes-from for container, container can use the volumes of another
containers. The format is "<containerID>[:mode]"

Signed-off-by: Rudy Zhang <[email protected]>
@allencloud
Copy link
Collaborator

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Apr 17, 2018
@allencloud allencloud merged commit dc75691 into AliyunContainerService:master Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

areas/storage kind/feature LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] support container options, such as isolation and configurations

5 participants