[arvados] created: 2.6.0-241-g07c01cca0

git repository hosting git at public.arvados.org
Fri Jun 2 20:26:01 UTC 2023


        at  07c01cca03555cc5311e2cba717803d4455cc657 (commit)


commit 07c01cca03555cc5311e2cba717803d4455cc657
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Fri Jun 2 16:18:07 2023 -0400

    20548: Rework git deployment a bit
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/tools/salt-install/installer.sh b/tools/salt-install/installer.sh
index 104ce3a60..db5bffcd6 100755
--- a/tools/salt-install/installer.sh
+++ b/tools/salt-install/installer.sh
@@ -60,6 +60,13 @@ checktools() {
     fi
 }
 
+cleanup() {
+    local NODE=$1
+    local SSH=`ssh_cmd "$NODE"`
+    # Delete the old repository
+    $SSH $DEPLOY_USER@$NODE rm -rf ${GITTARGET}.git ${GITTARGET}
+}
+
 sync() {
     local NODE=$1
     local BRANCH=$2
@@ -68,33 +75,26 @@ sync() {
     # each node, pushing our branch, and updating the checkout.
 
     if [[ "$NODE" != localhost ]] ; then
-		SSH=`ssh_cmd "$NODE"`
-		GIT="eval `git_cmd $NODE`"
-		if ! $SSH $DEPLOY_USER@$NODE test -d ${GITTARGET}.git ; then
-
-			# Initialize the git repository (1st time case).  We're
-			# actually going to make two repositories here because git
-			# will complain if you try to push to a repository with a
-			# checkout. So we're going to create a "bare" repository
-			# and then clone a regular repository (with a checkout)
-			# from that.
-
-			$SSH $DEPLOY_USER@$NODE git init --bare --shared=0600 ${GITTARGET}.git
-			if ! $GIT remote add $NODE $DEPLOY_USER@$NODE:${GITTARGET}.git ; then
-				$GIT remote set-url $NODE $DEPLOY_USER@$NODE:${GITTARGET}.git
-			fi
-			$GIT push $NODE $BRANCH
-			$SSH $DEPLOY_USER@$NODE "umask 0077 && git clone ${GITTARGET}.git ${GITTARGET}"
-		fi
+	SSH=`ssh_cmd "$NODE"`
+	GIT="eval `git_cmd $NODE`"
 
-		# The update case.
-		#
-		# Push to the bare repository on the remote node, then in the
-		# remote node repository with the checkout, pull the branch
-		# from the bare repository.
+	cleanup $NODE
 
-		$GIT push $NODE $BRANCH
-		$SSH $DEPLOY_USER@$NODE "git -C ${GITTARGET} checkout ${BRANCH} && git -C ${GITTARGET} pull"
+	# Update the git remote for the remote repository.
+	if ! $GIT remote add $NODE $DEPLOY_USER@$NODE:${GITTARGET}.git ; then
+	    $GIT remote set-url $NODE $DEPLOY_USER@$NODE:${GITTARGET}.git
+	fi
+
+	# Initialize the git repository.  We're
+	# actually going to make two repositories here because git
+	# will complain if you try to push to a repository with a
+	# checkout. So we're going to create a "bare" repository
+	# and then clone a regular repository (with a checkout)
+	# from that.
+
+	$SSH $DEPLOY_USER@$NODE git init --bare --shared=0600 ${GITTARGET}.git
+	$GIT push $NODE $BRANCH
+	$SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout ${BRANCH}"
     fi
 }
 
@@ -112,7 +112,7 @@ deploynode() {
     fi
 
     logfile=deploy-${NODE}-$(date -Iseconds).log
-	SSH=`ssh_cmd "$NODE"`
+    SSH=`ssh_cmd "$NODE"`
 
     if [[ "$NODE" = localhost ]] ; then
 	    SUDO=''
@@ -121,7 +121,8 @@ deploynode() {
 		fi
 		$SUDO ./provision.sh --config ${CONFIG_FILE} ${ROLES} 2>&1 | tee $logfile
 	else
-		$SSH $DEPLOY_USER@$NODE "cd ${GITTARGET} && sudo ./provision.sh --config ${CONFIG_FILE} ${ROLES}" 2>&1 | tee $logfile
+	    $SSH $DEPLOY_USER@$NODE "cd ${GITTARGET} && sudo ./provision.sh --config ${CONFIG_FILE} ${ROLES}" 2>&1 | tee $logfile
+	    cleanup $NODE
     fi
 }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list