[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] 2 commits: djm: new feature: fix-future for hosts running in the future
Holger Levsen (@holger)
gitlab at salsa.debian.org
Tue May 16 12:44:03 BST 2023
Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net
Commits:
1ef89d6f by Holger Levsen at 2023-05-16T13:38:08+02:00
djm: new feature: fix-future for hosts running in the future
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
99e11b3e by Holger Levsen at 2023-05-16T13:43:08+02:00
djm: refactoring
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
2 changed files:
- TODO
- bin/djm
Changes:
=====================================
TODO
=====================================
@@ -33,8 +33,8 @@ See link:https://jenkins.debian.net/userContent/about.html["about jenkins.debian
* split TODO in TODO and TODO.legacy?
* djm:
** also log an id, so that one command effecting several hosts is counted as on action
-** ACTION: ff - fix future
** ACTION: c (or rc) - run command
+*** support: ./deploy_jdn all 'sudo apt autoremove ; sudo apt clean'
** get rif of deploy_jdn
*** and while at it, make actions triggering 'all' be only one entry in the djm logfile -> more sensible stats
** cleanup/backup logs on the first of the month
=====================================
bin/djm
=====================================
@@ -45,6 +45,18 @@ THREE_C="%42s %12s %12s\n"
TWO_C="%42s %12s\n"
ONE_C="%42s %12s\n"
+#
+# nodes running in the future
+#
+node_in_the_future () {
+ case "$1" in
+ ionos5-amd64*|ionos6-i386*|ionos15-amd64*|ionos16-i386*) true ;;
+ codethink9*|codethink11*|codethink13*|codethink15*) true ;;
+ osuosl2-amd64*) true ;;
+ *) false ;;
+ esac
+}
+
#
# parse parameters
#
@@ -97,8 +109,6 @@ else
MODE=djm
fi
-
-
show_help(){
echo
echo problem parsing parameters, eithers of these are possible:
@@ -108,7 +118,7 @@ show_help(){
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 " _j_enkins-ui, _b_ring-back or _f_fix-future."
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
@@ -124,6 +134,57 @@ show_help(){
echo
}
+verify_target_action_reason(){
+ #
+ # verify target, action & reason
+ #
+ TARGET=$1
+ ACTION=$2
+ REASON=$3
+ case $TARGET in
+ .) TARGET="."
+ ;;
+ all) TARGET="$(./nodes/list_nodes )"
+ ;;
+ *) TARGET="$(./nodes/list_nodes | grep -E $TARGET || true)"
+ ;;
+ esac
+ if [ -z "$TARGET" ] ; then
+ FAIL_REASON="${FAIL_REASON}Undefined target.\n"
+ fi
+ case $ACTION in
+ r|reboot) ACTION=reboot ; CONFIRM=true ;;
+ 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 ;;
+ *) 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" ;;
+ *) FAIL_REASON="${FAIL_REASON}Undefined reason.\n"
+ ;;
+ esac
+ #
+ # some targets only allow specific actions
+ #
+ if [ "$TARGET" = "." ] && [ "$ACTION" != "jenkins-ui" ] ; then
+ FAIL_REASON="${FAIL_REASON}Target '.' can only be used with action 'jenkins-ui'.\n"
+ elif [ "$TARGET" != "." ] && [ "$ACTION" = "jenkins-ui" ] ; then
+ FAIL_REASON="${FAIL_REASON}Action 'jenkins-ui' can only be used with target '.'.\n"
+ fi
+}
+
seperator() {
local CHAR="${1:--}"
@@ -292,56 +353,6 @@ EOF
xterm -T "$SHORTNODE / $ACTION ($FILE)" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "bash $FILE" &
}
-verify_target_action_reason(){
- #
- # verify target, action & reason
- #
- TARGET=$1
- ACTION=$2
- REASON=$3
- case $TARGET in
- .) TARGET="."
- ;;
- all) TARGET="$(./nodes/list_nodes )"
- ;;
- *) TARGET="$(./nodes/list_nodes | grep -E $TARGET || true)"
- ;;
- esac
- if [ -z "$TARGET" ] ; then
- FAIL_REASON="${FAIL_REASON}Undefined target.\n"
- fi
- case $ACTION in
- r|reboot) ACTION=reboot ; CONFIRM=true ;;
- 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 ;;
- *) 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" ;;
- *) FAIL_REASON="${FAIL_REASON}Undefined reason.\n"
- ;;
- esac
- #
- # some targets only allow specific actions
- #
- if [ "$TARGET" = "." ] && [ "$ACTION" != "jenkins-ui" ] ; then
- FAIL_REASON="${FAIL_REASON}Target '.' can only be used with action 'jenkins-ui'.\n"
- elif [ "$TARGET" != "." ] && [ "$ACTION" = "jenkins-ui" ] ; then
- FAIL_REASON="${FAIL_REASON}Action 'jenkins-ui' can only be used with target '.'.\n"
- fi
-}
-
djm_do() {
#
# make sure we have target, action & reason
@@ -410,7 +421,7 @@ djm_do() {
# action
#
case $ACTION in
- reboot) ( ssh $NODE "sudo reboot || read enter" || true ) & sleep 2
+ reboot) ( ssh $NODE "sudo reboot || ( echo press enter ; read a ) " || true ) & sleep 2
run_xterm2wait4node_comeback $NODE
;;
powercycle) case $SHORTNODE in
@@ -437,9 +448,9 @@ djm_do() {
esac
run_xterm2wait4node_comeback $NODE
;;
- autoremove) xterm -T "$SHORTNODE / autoremove" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh $NODE 'sudo apt-get autoremove || read enter; sudo apt-get clean || read enter'" &
+ autoremove) xterm -T "$SHORTNODE / $ACTION" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh $NODE 'sudo apt-get autoremove || ( echo press enter ; read a ) sudo apt-get clean || ( echo press enter ; read a )'" &
;;
- shell) xterm -T "$SHORTNODE / shell" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh $NODE" &
+ shell) xterm -T "$SHORTNODE / $ACTION" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh $NODE" &
;;
jenkins-ui) echo "Documenting one manual action in the jenkins-ui."
;;
@@ -447,6 +458,21 @@ djm_do() {
OFF_NODES=~jenkins/offline_nodes
echo "Trying to mark $SHORTNODE as online. This is the diff for $OFF_NODES on jenkins.debian.net:"
ssh jenkins.debian.net "grep -v $SHORTNODE $OFF_NODES > $TMPFILE ; diff $OFF_NODES $TMPFILE ; mv $TMPFILE $OFF_NODES ; chown jenkins:jenkins $OFF_NODES"
+ ;;
+ fix-future) case $SHORTNODE in
+ osuosl*) NTP_SERVER=time.osuosl.org ;;
+ *) NTP_SERVER=de.pool.ntp.org ;;
+ esac
+ COMMAND="date ; sudo ntpdate -b $NTP_SERVER"
+ if node_in_the_future "$SHORTNODE" ; then
+ COMMAND="$COMMAND && sudo date --set='+398 days +6 hours + 23 minutes'"
+ COMMAND="$COMMAND ; date -u ; echo press enter ; read a"
+ xterm -T "$SHORTNODE / $ACTION" -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh $NODE \"$COMMAND\"" &
+ else
+ echo "Skipping $SHORTNODE as it's not running in the future."
+ continue
+ fi
+
;;
*) echo unsupported action, sorry, please improve.
exit 1
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/c51432de52c1dde9eb2c374b0656ab8b58c4b9c3...99e11b3e933e850e04deb5e8c6fac2ea471de0dd
--
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/compare/c51432de52c1dde9eb2c374b0656ab8b58c4b9c3...99e11b3e933e850e04deb5e8c6fac2ea471de0dd
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/7101c6d0/attachment-0001.htm>
More information about the Qa-jenkins-scm
mailing list