From 6cd0f77c4e53457323b2db96e7ecc869d807e06b Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Tue, 12 Sep 2017 00:58:34 +0000 Subject: [PATCH 1/2] Create host path is mount source does not exist. Signed-off-by: Lantao Liu --- pkg/server/container_create.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/server/container_create.go b/pkg/server/container_create.go index 80ff32bec..d76644df8 100644 --- a/pkg/server/container_create.go +++ b/pkg/server/container_create.go @@ -18,6 +18,7 @@ package server import ( "fmt" + "os" "strings" "time" @@ -484,6 +485,16 @@ func addOCIBindMounts(g *generate.Generator, mounts []*runtime.Mount, mountLabel for _, mount := range mounts { dst := mount.GetContainerPath() src := mount.GetHostPath() + // Create the host path if it doesn't exist. + // TODO(random-liu): Add CRI validation test for this case. + if _, err := os.Stat(src); err != nil { + if !os.IsNotExist(err) { + return fmt.Errorf("failed to stat %q: %v", src, err) + } + if err := os.MkdirAll(src, 0755); err != nil { + return fmt.Errorf("failed to mkdir %q: %v", src, err) + } + } options := []string{"rbind"} switch mount.GetPropagation() { case runtime.MountPropagation_PROPAGATION_PRIVATE: From 7429953386071a68023df6c6153a62e95003c71d Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Tue, 12 Sep 2017 04:01:20 +0000 Subject: [PATCH 2/2] Fix install.deps Signed-off-by: Lantao Liu --- hack/install-deps.sh | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/hack/install-deps.sh b/hack/install-deps.sh index a66dba164..8746755d3 100755 --- a/hack/install-deps.sh +++ b/hack/install-deps.sh @@ -62,20 +62,34 @@ fi # For multiple GOPATHs, keep the first one only GOPATH=${GOPATH%%:*} +# checkout_repo checks out specified repository +# and switch to specified version. +# Varset: +# 1) Repo name; +# 2) Version. +checkout_repo() { + repo=$1 + version=$2 + path="${GOPATH}/src/${repo}" + if [ ! -d ${path} ]; then + mkdir -p ${path} + git clone https://${repo} ${path} + fi + cd ${path} + git fetch --all + git checkout ${version} +} + # Install runc -go get -d ${RUNC_PKG}/... +checkout_repo ${RUNC_PKG} ${RUNC_VERSION} cd ${GOPATH}/src/${RUNC_PKG} -git fetch --all -git checkout ${RUNC_VERSION} BUILDTAGS=${BUILDTAGS:-seccomp apparmor} make BUILDTAGS="$BUILDTAGS" ${sudo} make install -e DESTDIR=${RUNC_DIR} # Install cni -go get -d ${CNI_PKG}/... +checkout_repo ${CNI_PKG} ${CNI_VERSION} cd ${GOPATH}/src/${CNI_PKG} -git fetch --all -git checkout ${CNI_VERSION} ./build.sh ${sudo} mkdir -p ${CNI_DIR} ${sudo} cp -r ./bin ${CNI_DIR} @@ -107,9 +121,7 @@ ${sudo} bash -c 'cat >'${CNI_CONFIG_DIR}'/10-containerd-net.conflist <