Merge pull request #237 from Random-Liu/create-host-path
Create host path is mount source does not exist.
This commit is contained in:
commit
4ee0f964ee
@ -62,20 +62,34 @@ fi
|
|||||||
# For multiple GOPATHs, keep the first one only
|
# For multiple GOPATHs, keep the first one only
|
||||||
GOPATH=${GOPATH%%:*}
|
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
|
# Install runc
|
||||||
go get -d ${RUNC_PKG}/...
|
checkout_repo ${RUNC_PKG} ${RUNC_VERSION}
|
||||||
cd ${GOPATH}/src/${RUNC_PKG}
|
cd ${GOPATH}/src/${RUNC_PKG}
|
||||||
git fetch --all
|
|
||||||
git checkout ${RUNC_VERSION}
|
|
||||||
BUILDTAGS=${BUILDTAGS:-seccomp apparmor}
|
BUILDTAGS=${BUILDTAGS:-seccomp apparmor}
|
||||||
make BUILDTAGS="$BUILDTAGS"
|
make BUILDTAGS="$BUILDTAGS"
|
||||||
${sudo} make install -e DESTDIR=${RUNC_DIR}
|
${sudo} make install -e DESTDIR=${RUNC_DIR}
|
||||||
|
|
||||||
# Install cni
|
# Install cni
|
||||||
go get -d ${CNI_PKG}/...
|
checkout_repo ${CNI_PKG} ${CNI_VERSION}
|
||||||
cd ${GOPATH}/src/${CNI_PKG}
|
cd ${GOPATH}/src/${CNI_PKG}
|
||||||
git fetch --all
|
|
||||||
git checkout ${CNI_VERSION}
|
|
||||||
./build.sh
|
./build.sh
|
||||||
${sudo} mkdir -p ${CNI_DIR}
|
${sudo} mkdir -p ${CNI_DIR}
|
||||||
${sudo} cp -r ./bin ${CNI_DIR}
|
${sudo} cp -r ./bin ${CNI_DIR}
|
||||||
@ -107,9 +121,7 @@ ${sudo} bash -c 'cat >'${CNI_CONFIG_DIR}'/10-containerd-net.conflist <<EOF
|
|||||||
EOF'
|
EOF'
|
||||||
|
|
||||||
# Install containerd
|
# Install containerd
|
||||||
go get -d ${CONTAINERD_PKG}/...
|
checkout_repo ${CONTAINERD_PKG} ${CONTAINERD_VERSION}
|
||||||
cd ${GOPATH}/src/${CONTAINERD_PKG}
|
cd ${GOPATH}/src/${CONTAINERD_PKG}
|
||||||
git fetch --all
|
|
||||||
git checkout ${CONTAINERD_VERSION}
|
|
||||||
make
|
make
|
||||||
${sudo} make install -e DESTDIR=${CONTAINERD_DIR}
|
${sudo} make install -e DESTDIR=${CONTAINERD_DIR}
|
||||||
|
@ -18,6 +18,7 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -484,6 +485,16 @@ func addOCIBindMounts(g *generate.Generator, mounts []*runtime.Mount, mountLabel
|
|||||||
for _, mount := range mounts {
|
for _, mount := range mounts {
|
||||||
dst := mount.GetContainerPath()
|
dst := mount.GetContainerPath()
|
||||||
src := mount.GetHostPath()
|
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"}
|
options := []string{"rbind"}
|
||||||
switch mount.GetPropagation() {
|
switch mount.GetPropagation() {
|
||||||
case runtime.MountPropagation_PROPAGATION_PRIVATE:
|
case runtime.MountPropagation_PROPAGATION_PRIVATE:
|
||||||
|
Loading…
Reference in New Issue
Block a user