[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 2 commits: djm: add --help option
Holger Levsen (@holger)
gitlab at salsa.debian.org
Tue May 16 16:07:01 BST 2023
Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net
Commits:
6d98bb36 by Holger Levsen at 2023-05-16T16:40:47+02:00
djm: add --help option
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
5bd9f84d by Holger Levsen at 2023-05-16T17:01:01+02:00
djm: refactoring, sort actions and reasons alphabetically
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
2 changed files:
- TODO
- bin/djm
Changes:
=====================================
TODO
=====================================
@@ -32,9 +32,9 @@ See link:https://jenkins.debian.net/userContent/about.html["about jenkins.debian
** maybe: rm /tmp/mmdebstrap.* older than 3 days
* split TODO in TODO and TODO.legacy?
* djm:
-** ACTION: deploy git
-** ACTION: rmstamp
-** ACTION: c (or rc) - run arbitrary command (with and without reset_clock)
+** ACTION: d|eploy-git
+** ACTION: rm|stamp
+** ACTION: c|command - run arbitrary command (with and without reset_clock)
** then get rid of deploy_jdn
** also log an id, so that one command effecting several hosts is counted as on action
*** make actions triggering 'all' be only one entry in the djm logfile -> more sensible stats
=====================================
bin/djm
=====================================
@@ -62,7 +62,7 @@ node_in_the_future () {
#
# thanks to /usr/share/doc/util-linux/examples/getopt-parse.bash
-TEMP=$(getopt -o 'dfrv' --long 'dry-run,fetch,report,verbose' -n 'djm' -- "$@")
+TEMP=$(getopt -o 'dfhrv' --long 'dry-run,fetch,help,report,verbose' -n 'djm' -- "$@")
if [ $? -ne 0 ]; then
echo 'Terminating...' >&2
exit 1
@@ -82,6 +82,11 @@ while true; do
shift
continue
;;
+ '-h'|'--help')
+ MODE=help
+ shift
+ continue
+ ;;
'-r'|'--report')
MODE=report
shift
@@ -103,35 +108,61 @@ while true; do
esac
done
# show report if not called with any options
-if [ -z "$1" ] ; then
- MODE=report
-else
- MODE=djm
+if [ -z "$MODE" ] ; then
+ if [ -z "$1" ] ; then
+ MODE=report
+ else
+ MODE=djm
+ fi
fi
show_help(){
+ seperator "="
+ djm_header
+ seperator "="
echo
- echo problem parsing parameters, eithers of these are possible:
- echo "djm -d/--dry-run -f/--fetch -r/--report -v/--verbose"
+ echo Either of these are possible:
+ echo "djm -d/--dry-run -f/--fetch -r/--report -v/--verbose -h/--help"
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, _b_ring-back, _f_fix-future or _u_pgrade."
- 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, su=security updates"
- echo
- echo params given:
- echo
- echo "\$1 = $1"
- echo "\$2 = $2"
- echo "\$3 = $3"
+ echo " or special target '.' for jenkins-ui ACTION."
echo
- echo parsing problems:
+ echo "ACTION= one of these:"
+ echo " _a_utoremove apt autoremove && apt clean"
+ echo " _b_ring-back mark host as online"
+ echo " _f_fix-future fix clock on hosts running in the future"
+ echo " _j_enkins-ui for when doing things manually in the jenkins-ui"
+ echo " _p_owercycle"
+ echo " _r_eboot"
+ echo " _s_shell for manual maintenance"
+ echo " _u_pgrade apt update && apt -y dist-upgrade"
echo
- echo -e "$4"
+ echo "REASON= one of these:"
+ echo " cs=clock skew"
+ echo " dj=debug job problems"
+ echo " hb=host is back"
+ echo " ho=host is overloaded"
+ echo " ku=kernel upgrade"
+ echo " np=no ping"
+ echo " nt=new things"
+ echo " rm=regular maintenance"
+ echo " su=security updates"
echo
+ if [ -n "$1" ] ; then
+ seperator
+ echo
+ echo problem parsing given parameters:
+ echo
+ echo "\$1 = $1"
+ echo "\$2 = $2"
+ echo "\$3 = $3"
+ echo
+ echo parsing problems:
+ echo
+ echo -e "$4"
+ echo
+ fi
}
verify_target_action_reason(){
@@ -153,29 +184,27 @@ verify_target_action_reason(){
FAIL_REASON="${FAIL_REASON}Undefined target.\n"
fi
case $ACTION in
- r|reboot) ACTION=reboot ; CONFIRM=true ;;
+ a|autoremove) ACTION=autoremove ;;
+ b|bring-back) ACTION=bring-back ;;
+ f|fix-future) ACTION=fix-future ;;
+ j|jenkins-ui) ACTION=jenkins-ui ;;
p|powercycle) ACTION=powercycle ; CONFIRM=true ;;
- a|autoremove) ACTION=autoremove ;;
- s|shell) ACTION=shell ;;
- j|jenkins-ui) ACTION=jenkins-ui ;;
- b|bring-back) ACTION=bring-back ;;
- f|fix-future) ACTION=fix-future ;;
- u|upgrade) ACTION=apt-upgrade ;;
- *) FAIL_REASON="${FAIL_REASON}Undefined action.\n"
- ;;
+ r|reboot) ACTION=reboot ; CONFIRM=true ;;
+ s|shell) ACTION=shell ;;
+ u|upgrade) ACTION=apt-upgrade ;;
+ *) FAIL_REASON="${FAIL_REASON}Undefined action.\n" ;;
esac
case $REASON in
- ku) REASON="kernel upgrade" ;;
- np) REASON="no ping" ;;
- dj) REASON="debug job problems" ;;
- rm) REASON="regular maintenance" ;;
- cs) REASON="clock skew" ;;
- hb) REASON="host is back" ;;
- ho) REASON="host is overloaded" ;;
- nt) REASON="new things" ;;
- su) REASON="security updates" ;;
- *) FAIL_REASON="${FAIL_REASON}Undefined reason.\n"
- ;;
+ cs) REASON="clock skew" ;;
+ dj) REASON="debug job problems" ;;
+ hb) REASON="host is back" ;;
+ ho) REASON="host is overloaded" ;;
+ ku) REASON="kernel upgrade" ;;
+ np) REASON="no ping" ;;
+ nt) REASON="new things" ;;
+ rm) REASON="regular maintenance" ;;
+ su) REASON="security updates" ;;
+ *) FAIL_REASON="${FAIL_REASON}Undefined reason.\n" ;;
esac
#
# some targets only allow specific actions
@@ -187,6 +216,11 @@ verify_target_action_reason(){
fi
}
+djm_header() {
+ echo "djm = documented jenkins maintenance"
+ echo " jenkins.debian.net exists since 2012, djm since 2023-04."
+ echo " so expect changes for some time."
+}
seperator() {
local CHAR="${1:--}"
@@ -237,9 +271,7 @@ djm_report() {
echo " - $LOCAL_LOGFILE"
echo " - $UI_LOGFILE"
echo
- echo "djm = documented jenkins maintenance"
- echo " jenkins.debian.net exists since 2012, djm since 2023-04."
- echo " so expect changes for some time."
+ djm_header
seperator "="
printf "$TWO_C" "month:" "$LOGMONTH"
seperator
@@ -498,23 +530,25 @@ djm_do() {
echo Thank you for doing documented jenkins maintenance.
}
+djm_init() {
+ 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_RUN ; then
+ echo "Fetching remote logs."
+ djm_fetch
+ fi
+ else
+ echo "Not fetching remote logs."
+ fi
+ rm $DUMMY
+}
+
#
# main
#
-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_RUN ; then
- echo "Fetching remote logs."
- djm_fetch
- fi
-else
- echo "Not fetching remote logs."
-fi
-rm $DUMMY
-
-if [ "$MODE" = "report" ] ; then
- djm_report
-elif [ "$MODE" = "djm" ] ; then
- djm_do $1 $2 $3
-fi
+case $MODE in
+ report) djm_init ; djm_report ;;
+ djm) djm_init ; djm_do $1 $2 $3 ;;
+ help) show_help ;;
+esac
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/1b96205a54d67ecc9c3c079aca656c902bb581e5...5bd9f84d32f38ad9f0723ceddbb9c37999d8e04b
--
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/1b96205a54d67ecc9c3c079aca656c902bb581e5...5bd9f84d32f38ad9f0723ceddbb9c37999d8e04b
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/20230516/6a3557d2/attachment-0001.htm>
More information about the Qa-jenkins-scm
mailing list