diff --git a/cluster/gce/gci/mounter/mounter b/cluster/gce/gci/mounter/mounter index 3d826fad603..6f45a56abf4 100755 --- a/cluster/gce/gci/mounter/mounter +++ b/cluster/gce/gci/mounter/mounter @@ -24,13 +24,14 @@ ROOT_DIR=/home/kubernetes/bin RKT_BINARY=${ROOT_DIR}/rkt STAGE1_ACI=${ROOT_DIR}/stage1-fly.aci MOUNTER_ACI=${ROOT_DIR}/gci-mounter-${MOUNTER_VERSION}.aci +MOUNTER_IMAGE=gcr.io/google_containers/gci-mounter:${MOUNTER_VERSION} function gc { # Attempt to garbage collect rkt pods with 5 retries. # Rkt pods end up creating new copies of mounts on the host. Hence it is ideal to clean them up right away. attempt=0 until [ $attempt -ge 5 ]; do - ${RKT_BINARY} gc --grace-period=0s && break + ${RKT_BINARY} gc --grace-period=0s &> /dev/null && break attempt=$[$attempt+1] sleep 1 done @@ -39,12 +40,16 @@ function gc { # Garbage collect old rkt containers on exit trap gc EXIT +if [[ ! $(${RKT_BINARY} image list | grep ${MOUNTER_IMAGE}) ]]; then + ${RKT_BINARY} fetch --insecure-options=image file://${MOUNTER_ACI} +fi + echo "Running mount using a rkt fly container" ${RKT_BINARY} run --stage1-path=${STAGE1_ACI} \ --insecure-options=image \ --volume=kubelet,kind=host,source=/var/lib/kubelet,readOnly=false,recursive=true \ --mount volume=kubelet,target=/var/lib/kubelet \ - file://${MOUNTER_ACI} --user=${MOUNTER_USER} --exec /bin/mount -- "$@" + ${MOUNTER_IMAGE} --user=${MOUNTER_USER} --exec /bin/mount -- "$@" echo "Successfully ran mount using a rkt fly container" diff --git a/cluster/gce/gci/mounter/stage-upload.sh b/cluster/gce/gci/mounter/stage-upload.sh index 4fbc706af14..66780da381e 100755 --- a/cluster/gce/gci/mounter/stage-upload.sh +++ b/cluster/gce/gci/mounter/stage-upload.sh @@ -1,5 +1,24 @@ #!/bin/sh +# Copyright 2016 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Due to the GCE custom metadata size limit, we split the entire script into two +# files configure.sh and configure-helper.sh. The functionality of downloading +# kubernetes configuration, manifests, docker images, and binary files are +# put in configure.sh, which is uploaded via GCE custom metadata. + set -o errexit set -o pipefail set -o nounset