From 02f3828283e61271050e1f623f5776c31b9eefe9 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Mon, 22 May 2017 17:19:49 +0200 Subject: [PATCH] server: workaround images with Config.Volumes Signed-off-by: Antonio Murdaca --- server/container_create.go | 8 ++++++++ test/ctr.bats | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/server/container_create.go b/server/container_create.go index c15985e9..4d9de686 100644 --- a/server/container_create.go +++ b/server/container_create.go @@ -589,6 +589,14 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string, containerImageConfig := containerInfo.Config + // TODO: volume handling in CRI-O + // right now, we do just mount tmpfs in order to have images like + // gcr.io/k8s-testimages/redis:e2e to work with CRI-O + for dest := range containerImageConfig.Config.Volumes { + destOptions := []string{"mode=1777", "size=" + strconv.Itoa(64*1024*1024)} + specgen.AddTmpfsMount(dest, destOptions) + } + processArgs, err := buildOCIProcessArgs(containerConfig, containerImageConfig) if err != nil { return nil, err diff --git a/test/ctr.bats b/test/ctr.bats index 703a58a1..831d3bd4 100644 --- a/test/ctr.bats +++ b/test/ctr.bats @@ -573,3 +573,23 @@ function teardown() { cleanup_pods stop_crio } + +@test "run ctr with image with Config.Volumes" { + start_crio + run crioctl image pull gcr.io/k8s-testimages/redis:e2e + echo "$output" + [ "$status" -eq 0 ] + run crioctl pod run --config "$TESTDATA"/sandbox_config.json + echo "$output" + [ "$status" -eq 0 ] + pod_id="$output" + volumesconfig=$(cat "$TESTDATA"/container_redis.json | python -c 'import json,sys;obj=json.load(sys.stdin);obj["image"]["image"] = "gcr.io/k8s-testimages/redis:e2e"; json.dump(obj, sys.stdout)') + echo "$volumesconfig" > "$TESTDIR"/container_config_volumes.json + run crioctl ctr create --config "$TESTDIR"/container_config_volumes.json --pod "$pod_id" + echo "$output" + [ "$status" -eq 0 ] + + cleanup_ctrs + cleanup_pods + stop_crio +}