Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ccf496b
Skeleton grid_janitor service as outlined in milestone 8. Ported to `…
jonasbardino Sep 1, 2025
3adb087
Add missing grid_janitor daemon and fix copyritgh header.
jonasbardino Sep 1, 2025
55a82aa
Really commit the first functional version as stated in previous comm…
jonasbardino Sep 1, 2025
6be8809
Integrated automatic password reset acceptance and rejection dependin…
jonasbardino Sep 2, 2025
89110a8
Refactor management of trivial requests into its own function. Add re…
jonasbardino Sep 2, 2025
c349205
Add more invalid account request handling to automatically also reject:
jonasbardino Sep 4, 2025
6814718
Refactor grid_janitor to use new mig/lib/ for all helper functions an…
jonasbardino Sep 7, 2025
727024c
Move grid_janitor to the new ./sbin location for modern clean services.
jonasbardino Sep 7, 2025
2b35b47
Style and format only changes. Applied
jonasbardino Sep 7, 2025
eaf98d2
Minor polish in preparation for review and merge of the basic janitor
jonasbardino Sep 24, 2025
3de9b3a
Polish docstring for `early_validation_checks` and fix a inadvertent …
jonasbardino Sep 25, 2025
ca003c5
Add a simple interruptible sleep action for daemons to support the us…
jonasbardino Sep 25, 2025
879a633
Implement run handler and interruptible sleep in grid_janitor with th…
jonasbardino Sep 25, 2025
6fa47a5
And remove the TODO comment about the latest commit.
jonasbardino Sep 25, 2025
16a4820
Another minimal comment change.
jonasbardino Sep 25, 2025
7fa8c3b
Actually check assertion on funtion *call* rather than on the always …
jonasbardino Sep 26, 2025
34b75d8
Address a couple of important PR322 review comments. Thanks @rasmunk
jonasbardino Sep 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mig/install/MiGserver-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@ enable_notify = __ENABLE_NOTIFY__
enable_imnotify = __ENABLE_IMNOTIFY__
# Enable users to schedule tasks with a cron/at-like interface
enable_crontab = __ENABLE_CRONTAB__
# Enable janitor service to handle recurring tasks like clean up and cache updates
enable_janitor = __ENABLE_JANITOR__
# Enable 2FA for web access and IO services with any TOTP authenticator client
# IMPORTANT: Do NOT change this option manually here (requires Apache changes)!
# use generateconfs.py --enable_twofactor=True|False
Expand Down
63 changes: 61 additions & 2 deletions mig/install/migrid-init.d-deb-template
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ MIG_MONITOR=${MIG_CODE}/server/grid_monitor.py
MIG_SSHMUX=${MIG_CODE}/server/grid_sshmux.py
MIG_EVENTS=${MIG_CODE}/server/grid_events.py
MIG_CRON=${MIG_CODE}/server/grid_cron.py
MIG_JANITOR=${MIG_CODE}/server/grid_janitor.py
MIG_TRANSFERS=${MIG_CODE}/server/grid_transfers.py
MIG_OPENID=${MIG_CODE}/server/grid_openid.py
MIG_SFTP=${MIG_CODE}/server/grid_sftp.py
Expand All @@ -67,7 +68,7 @@ MIG_CHKSIDROOT=${MIG_CODE}/server/chksidroot.py
show_usage() {
echo "Usage: migrid {start|stop|status|restart|reload}[daemon DAEMON]"
echo "where daemon is left out for all or given along with DAEMON as one of the following"
echo "(script|monitor|sshmux|events|cron|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)"
echo "(script|monitor|sshmux|events|cron|janitor|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)"
}

check_enabled() {
Expand Down Expand Up @@ -154,6 +155,19 @@ start_cron() {
log_end_msg 1 || true
fi
}
start_janitor() {
check_enabled "janitor" || return 0
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
# NOTE: janitor tasks can be quite heavy so we lower sched prio a bit
log_daemon_msg "Starting MiG janitor daemon" ${SHORT_NAME} || true
if start-stop-daemon --start --quiet --oknodo --pidfile ${PID_FILE} --make-pidfile --user ${MIG_USER} --chuid ${MIG_USER} --nicelevel 10 --background --name ${SHORT_NAME} --startas ${DAEMON_PATH} ; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
}
start_transfers() {
check_enabled "transfers" || return 0
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -267,6 +281,7 @@ start_all() {
start_sshmux
start_events
start_cron
start_janitor
start_transfers
start_openid
start_sftp
Expand Down Expand Up @@ -374,6 +389,28 @@ stop_cron() {
log_end_msg 1 || true
fi
}
stop_janitor() {
check_enabled "janitor" || return 0
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
log_daemon_msg "Stopping MiG janitor" ${SHORT_NAME} || true
# Try graceful shutdown so that state is properly saved
start-stop-daemon --stop --signal INT --quiet --oknodo --pidfile ${PID_FILE}
for delay in 1 2 3; do
status_of_proc -p ${PID_FILE} ${DAEMON_PATH} ${SHORT_NAME} || break
sleep $delay
done
# Force kill if still running
status_of_proc -p ${PID_FILE} ${DAEMON_PATH} ${SHORT_NAME} && \
start-stop-daemon --stop --quiet --oknodo --pidfile ${PID_FILE}
if ! status_of_proc -p ${PID_FILE} ${DAEMON_PATH} ${SHORT_NAME}; then
rm -f ${PID_FILE}
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
}
stop_transfers() {
check_enabled "transfers" || return 0
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -515,6 +552,7 @@ stop_all() {
stop_sshmux
stop_events
stop_cron
stop_janitor
stop_transfers
stop_openid
stop_sftp
Expand Down Expand Up @@ -589,6 +627,18 @@ reload_cron() {
log_end_msg 1 || true
fi
}
reload_janitor() {
check_enabled "janitor" || return 0
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
log_daemon_msg "Reloading MiG janitor" ${SHORT_NAME} || true
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile ${PID_FILE} ; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
}
reload_transfers() {
check_enabled "transfers" || return 0
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -726,6 +776,7 @@ reload_all() {
reload_sshmux
reload_events
reload_cron
reload_janitor
reload_transfers
reload_openid
reload_sftp
Expand Down Expand Up @@ -777,6 +828,13 @@ status_cron() {
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
status_of_proc -p ${PID_FILE} ${DAEMON_PATH} ${SHORT_NAME}
}
status_janitor() {
check_enabled "janitor" || return 0
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
status_of_proc -p ${PID_FILE} ${DAEMON_PATH} ${SHORT_NAME}
}
status_transfers() {
check_enabled "transfers" || return 0
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -860,6 +918,7 @@ status_all() {
status_sshmux
status_events
status_cron
status_janitor
status_transfers
status_openid
status_sftp
Expand All @@ -881,7 +940,7 @@ test -f ${MIG_SCRIPT} || exit 0

# Force valid target
case "$2" in
script|monitor|sshmux|events|cron|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)
script|monitor|sshmux|events|cron|janitor|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)
TARGET="$2"
;;
'')
Expand Down
58 changes: 56 additions & 2 deletions mig/install/migrid-init.d-rh-template
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# processname: grid_sshmux.py
# processname: grid_events.py
# processname: grid_cron.py
# processname: grid_janitor.py
# processname: grid_transfers.py
# processname: grid_openid.py
# processname: grid_sftp.py
Expand Down Expand Up @@ -81,6 +82,7 @@ MIG_MONITOR=${MIG_CODE}/server/grid_monitor.py
MIG_SSHMUX=${MIG_CODE}/server/grid_sshmux.py
MIG_EVENTS=${MIG_CODE}/server/grid_events.py
MIG_CRON=${MIG_CODE}/server/grid_cron.py
MIG_JANITOR=${MIG_CODE}/server/grid_janitor.py
MIG_TRANSFERS=${MIG_CODE}/server/grid_transfers.py
MIG_OPENID=${MIG_CODE}/server/grid_openid.py
MIG_SFTP=${MIG_CODE}/server/grid_sftp.py
Expand All @@ -97,7 +99,7 @@ MIG_CHKSIDROOT=${MIG_CODE}/server/chksidroot.py
show_usage() {
echo "Usage: migrid {start|stop|status|restart|reload}[daemon DAEMON]"
echo "where daemon is left out for all or given along with DAEMON as one of the following"
echo "(script|monitor|sshmux|events|cron|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)"
echo "(script|monitor|sshmux|events|cron|janitor|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)"
}

check_enabled() {
Expand Down Expand Up @@ -215,6 +217,22 @@ start_cron() {
[ $RET2 -ne 0 ] && echo "Warning: cron not started."
echo
}
start_janitor() {
check_enabled "janitor" || return
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
# NOTE: janitor tasks can be quite heavy so we lower sched prio a bit
echo -n "Starting MiG janitor daemon: $SHORT_NAME"
daemon +10 --user ${MIG_USER} --pidfile ${PID_FILE} \
"${DAEMON_PATH} >> ${MIG_LOG}/janitor.out 2>&1 &"
fallback_save_pid "$DAEMON_PATH" "$PID_FILE" "$!"
RET2=$?
[ $RET2 ] && success
echo
[ $RET2 ] || echo "Warning: janitor not started."
echo
}
start_transfers() {
check_enabled "transfers" || return
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -356,6 +374,7 @@ start_all() {
start_sshmux
start_events
start_cron
start_janitor
start_transfers
start_openid
start_sftp
Expand All @@ -369,6 +388,7 @@ start_all() {
return 0
}

# TODO: should we use PID_FILE in all stop_X handlers like in deb version?
stop_script() {
check_enabled "jobs" || return
DAEMON_PATH=${MIG_SCRIPT}
Expand Down Expand Up @@ -432,6 +452,21 @@ stop_cron() {
echo
status ${DAEMON_PATH} && killproc ${DAEMON_PATH}
}
stop_janitor() {
check_enabled "janitor" || return
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PID_FILE doesn't appear to be used here?

Copy link
Contributor Author

@jonasbardino jonasbardino Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that looks true.
It's a simple copy/paste of what we do for all the other migrid service daemons, and AFAICT the PID_FILE is only directly used in the corresponding deb (Debian/Ubuntu) template. It should perhaps be used on rh (RHEL/Rocky), too, but that would be something to handle and test thoroughly in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a TODO about it in the template.

echo -n "Shutting down MiG janitor: $SHORT_NAME "
# Try graceful shutdown so that state is properly saved
killproc ${DAEMON_PATH} -INT
for delay in 1 2 3; do
status ${DAEMON_PATH} || break
sleep $delay
done
echo
status ${DAEMON_PATH} && killproc ${DAEMON_PATH}
}
stop_transfers() {
check_enabled "transfers" || return
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -542,6 +577,7 @@ stop_all() {
stop_sshmux
stop_events
stop_cron
stop_janitor
stop_transfers
stop_openid
stop_sftp
Expand Down Expand Up @@ -600,6 +636,15 @@ reload_cron() {
killproc ${DAEMON_PATH} -HUP
echo
}
reload_janitor() {
check_enabled "janitor" || return
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
echo -n "Reloading MiG janitor: $SHORT_NAME "
killproc ${DAEMON_PATH} -HUP
echo
}
reload_transfers() {
check_enabled "transfers" || return
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -717,6 +762,7 @@ reload_all() {
reload_sshmux
reload_events
reload_cron
reload_janitor
reload_transfers
reload_openid
reload_sftp
Expand Down Expand Up @@ -768,6 +814,13 @@ status_cron() {
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
status ${DAEMON_PATH}
}
status_janitor() {
check_enabled "janitor" || return
DAEMON_PATH=${MIG_JANITOR}
SHORT_NAME=$(basename ${DAEMON_PATH})
PID_FILE="$PID_DIR/${SHORT_NAME}.pid"
status ${DAEMON_PATH}
}
status_transfers() {
check_enabled "transfers" || return
DAEMON_PATH=${MIG_TRANSFERS}
Expand Down Expand Up @@ -852,6 +905,7 @@ status_all() {
status_sshmux
status_events
status_cron
status_janitor
status_transfers
status_openid
status_sftp
Expand All @@ -873,7 +927,7 @@ test -f ${MIG_SCRIPT} || exit 0

# Force valid target
case "$2" in
script|monitor|sshmux|events|cron|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)
script|monitor|sshmux|events|cron|janitor|transfers|openid|sftp|sftpsubsys|webdavs|ftps|notify|imnotify|vmproxy|all)
TARGET="$2"
;;
'')
Expand Down
Loading