From 0850024f0ea0fbe81efefae9d4a49dcf9521a73e Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Thu, 28 Sep 2017 11:54:23 -0700 Subject: Keep Docker builds from thrashing on same server There is a possiblity of multiple docker builds of a docker repo being scheduled on the same host: 1) Patch is merged 2) Docker build is triggered 3) New patch is merged before the Docker build/push finishes triggering a second build 4) First build fails as second build starts by cleaning image from first build Reintroducing the check for builds in progress, but specific to the Docker repo, should allow mulitiple Docker builds on a node to run, while keeping multiple builds on a per-repo basis from thrashing each other. JIRA: RELENG-315 Change-Id: I74c01850a036c831b93a8cd5fa8522337abb9ff4 Signed-off-by: Trevor Bramwell --- jjb/releng/opnfv-docker.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jjb/releng/opnfv-docker.sh b/jjb/releng/opnfv-docker.sh index 954d7c8ab..298d2af51 100644 --- a/jjb/releng/opnfv-docker.sh +++ b/jjb/releng/opnfv-docker.sh @@ -17,6 +17,17 @@ echo "Starting opnfv-docker for $DOCKER_REPO_NAME ..." echo "--------------------------------------------------------" echo +count=30 # docker build jobs might take up to ~30 min +while [[ -n `ps -ef| grep 'docker build' | grep $DOCKER_REPO_NAME | grep -v grep` ]]; do + echo "Build or cleanup of $DOCKER_REPO_NAME in progress. Waiting..." + sleep 60 + count=$(( $count - 1 )) + if [ $count -eq 0 ]; then + echo "Timeout. Aborting..." + exit 1 + fi +done + # Remove previous running containers if exist if [[ -n "$(docker ps -a | grep $DOCKER_REPO_NAME)" ]]; then echo "Removing existing $DOCKER_REPO_NAME containers..." -- cgit 1.2.3-korg