[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] djm: refactoring

Holger Levsen (@holger) gitlab at salsa.debian.org
Mon May 15 14:49:49 BST 2023



Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net


Commits:
4d8b820c by Holger Levsen at 2023-05-15T15:49:11+02:00
djm: refactoring

Signed-off-by: Holger Levsen <holger at layer-acht.org>

- - - - -


1 changed file:

- bin/djm


Changes:

=====================================
bin/djm
=====================================
@@ -15,7 +15,7 @@ set -o pipefail		# see eg http://petereisentraut.blogspot.com/2010/11/pipefail.h
 # define environment and global variables
 #
 MODE=djm
-DRY_MODE=false
+DRY_RUN=false
 VERBOSE=false
 FETCH=false
 LOGFILE=~/.djm.log
@@ -25,7 +25,6 @@ BG=""
 TARGET=
 ACTION=
 REASON=
-# djm-logparser
 LOCAL_LOGFILE=~/.djm.log
 UI_LOGFILE=~/.djm-jenkins-ui.log
 PARSER_LOGFILE=~/.djm-jenkins-parser.log
@@ -63,7 +62,7 @@ unset TEMP
 while true; do
 	case "$1" in
 		'-d'|'--dry-run')
-			DRY_MODE=true
+			DRY_RUN=true
 			shift
 			continue
 			;;
@@ -93,6 +92,32 @@ while true; do
 	esac
 done
 
+show_help(){
+	echo
+	echo problem parsing parameters, eithers of these are possible:
+	echo "djm -d/--dry-run -f/--fetch -r/--report -v/--verbose"
+	echo "djm -d/--dry-run \$TARGET \$ACTION \$REASON"
+	echo
+	echo "TARGET=	'all' or grepable (jenkins, amd64, ionos, osuosl3) from ./nodes/list_nodes"
+	echo "         	or special target '.'"
+	echo "ACTION=	r_eboot, _p_owercycle, _a_utoremove, _s_shell (for manual maintenance),"
+	echo "         	_j_enkins-ui or _b_ring-back"
+	echo "REASON=	ku=kernel update, np=no pings, dj=debug job problems, rm=regular maintenance,"
+	echo "         	cs=clock skew, hb=host back, ho=host overloaded, nt=new things"
+	echo
+	echo params given:
+	echo
+	echo "\$1 = $1"
+	echo "\$2 = $2"
+	echo "\$3 = $3"
+	echo
+	echo parsing problems:
+	echo
+	echo -e "$4"
+	echo
+}
+
+
 seperator() {
 	local CHAR="${1:--}"
 	for i in $(seq 1 79) ; do
@@ -112,7 +137,7 @@ printf_heading() {
 	printf "$ONE_C" "$(for i in $(seq 1 ${#1}) ; do echo -n '-' ; done)"
 }
 
-djm_fetch_logs() {
+djm_fetch() {
 	#
 	# parse jenkins build logs and copy the result over
 	#
@@ -122,7 +147,7 @@ djm_fetch_logs() {
 	ssh $DJM_USER at jenkins.debian.net "cd ~jenkins/jobs ; ls -1d reproducible_* |wc -l" > $JOBS
 }
 
-djm_logparser() {
+djm_report() {
 	TMP_LOGFILE=$(mktemp)
 	cat $LOCAL_LOGFILE $UI_LOGFILE | grep ^$LOGMONTH | sort -u > $TMP_LOGFILE
 	TOTAL=$(grep -c ^$LOGMONTH $TMP_LOGFILE)
@@ -310,31 +335,6 @@ verify_target_action_reason(){
 	fi
 }
 
-show_help(){
-	echo
-	echo problem parsing parameters, eithers of these are possible:
-	echo "djm -d/--dry-run -f/--fetch -r/--report -v/--verbose"
-	echo "djm -d/--dry-run \$TARGET \$ACTION \$REASON"
-	echo
-	echo "TARGET=	'all' or grepable (jenkins, amd64, ionos, osuosl3) from ./nodes/list_nodes"
-	echo "         	or special target '.'"
-	echo "ACTION=	r_eboot, _p_owercycle, _a_utoremove, _s_shell (for manual maintenance),"
-	echo "         	_j_enkins-ui or _b_ring-back"
-	echo "REASON=	ku=kernel update, np=no pings, dj=debug job problems, rm=regular maintenance,"
-	echo "         	cs=clock skew, hb=host back, ho=host overloaded, nt=new things"
-	echo
-	echo params given:
-	echo
-	echo "\$1 = $1"
-	echo "\$2 = $2"
-	echo "\$3 = $3"
-	echo
-	echo parsing problems:
-	echo
-	echo -e "$4"
-	echo
-}
-
 djm_do() {
 	#
 	# make sure we have target, action & reason
@@ -352,7 +352,7 @@ djm_do() {
 	#
 	# main
 	#
-	if $DRY_MODE ; then
+	if $DRY_RUN ; then
 		echo "###"
 		echo "###"
 		echo "###  running in dry-run mode, not doing anything for real."
@@ -364,7 +364,7 @@ djm_do() {
 		echo
 	fi
 	
-	if $DRY_MODE || $CONFIRM ; then
+	if $DRY_RUN || $CONFIRM ; then
 		for NODE in $TARGET ; do
 			if [ "$NODE" != "." ] ; then
 				SHORTNODE=$(echo $NODE | cut -d '.' -f1)
@@ -375,7 +375,7 @@ djm_do() {
 		done
 	fi
 	
-	if $DRY_MODE ; then
+	if $DRY_RUN ; then
 		echo
 		echo "# dry-run end."
 		exit 0
@@ -460,10 +460,10 @@ djm_do() {
 #
 DUMMY=$(mktemp)
 touch -d "$(date -u -d "18 hours ago" '+%Y-%m-%d %H:%M') UTC" $DUMMY
-if [ $FETCH ] || [ ! -f $JOBS ] || [ $DUMMY -nt $JOBS ] ; then
-	if ! $DRY_MODE ; then
+if $FETCH || [ ! -f $JOBS ] || [ $DUMMY -nt $JOBS ] ; then
+	if ! $DRY_RUN ; then
 		echo "Fetching remote logs."
-		djm_fetch_logs
+		djm_fetch
 	fi
 else
 	echo "Not fetching remote logs."
@@ -471,7 +471,7 @@ fi
 rm $DUMMY
 
 if [ "$MODE" = "report" ] ; then
-	djm_logparser
+	djm_report
 elif [ "$MODE" = "djm" ] ; then
 	djm_do $1 $2 $3
 fi



View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/4d8b820c2106070f28c538b91b78fe333b40f037

-- 
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/4d8b820c2106070f28c538b91b78fe333b40f037
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20230515/c8cea911/attachment-0001.htm>


More information about the Qa-jenkins-scm mailing list