Merge pull request #16081 from jlowdermilk/please-leave-flock-alone

Revert the flock command to the working version and add a warning
This commit is contained in:
Jeff Grafton 2015-10-21 18:47:13 -07:00
commit d3862d453f

View File

@ -1113,10 +1113,32 @@ if [[ "${E2E_UP,,}" == "true" || "${JENKINS_FORCE_GET_TARS:-}" =~ ^[yY]$ ]]; the
# other. # other.
export KUBE_SKIP_UPDATE=y export KUBE_SKIP_UPDATE=y
( (
flock -x -n 9 # ----------- WARNING! DO NOT TOUCH THIS CODE -----------
sudo gcloud components update -q || true #
sudo gcloud components update alpha -q || true # The purpose of this code is to ensure that only one job attempts to
sudo gcloud components update beta -q || true # update gcloud. To do this, we call call `sudo flock` and fail
# silently if the lock can't be acquired, as that means another job is
# currently updating the components.
#
# We do NOT want to run gcloud components update under sudo, as that causes
# the gcloud files to get chown'd by root, which makes them undeletable in
# the case where we are installing gcloud under the workspace (e.g. for gke-ci
# and friends). If we can't cleanup old workspaces, jenkins runs out of disk
# and many devs get angry.
#
# If jenkins was recently restarted and jobs are failing with
#
# flock: 9: Bad file descriptor
#
# ssh into the jenkins master and run
# $ `sudo chown root:root /var/run/lock/gcloud-components.lock`
#
# AGAIN: DO NOT TOUCH THIS CODE unless you are certain you understand
# implications and have approval from jlowdermilk@ or brendandburns@
sudo flock -x -n 9
gcloud components update -q || true
gcloud components update alpha -q || true
gcloud components update beta -q || true
) 9>/var/run/lock/gcloud-components.lock ) 9>/var/run/lock/gcloud-components.lock
if [[ ! -z ${JENKINS_EXPLICIT_VERSION:-} ]]; then if [[ ! -z ${JENKINS_EXPLICIT_VERSION:-} ]]; then