mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-08-03 06:16:21 +00:00
update 1.2.4.1
This commit is contained in:
@@ -10048,7 +10048,12 @@ def _update_smart_cron():
|
|||||||
# scheduled tests in history" with no obvious clue why.
|
# scheduled tests in history" with no obvious clue why.
|
||||||
cmd = f'/usr/local/share/proxmenux/scripts/storage/smart-scheduled-test.sh --schedule-id {schedule_id} --test-type {test_type} --retention {retention}'
|
cmd = f'/usr/local/share/proxmenux/scripts/storage/smart-scheduled-test.sh --schedule-id {schedule_id} --test-type {test_type} --retention {retention}'
|
||||||
if disks != ['all']:
|
if disks != ['all']:
|
||||||
cmd += f" --disks '{','.join(disks)}'"
|
# Prepend /dev/ when the UI stored the disk as a basename
|
||||||
|
# (sdb, nvme0n1, …). The runner's `[[ -b "$disk" ]]` check
|
||||||
|
# only accepts full block-device paths, so basenames were
|
||||||
|
# silently skipped and no test ever ran.
|
||||||
|
disk_args = [d if d.startswith('/') else f'/dev/{d}' for d in disks]
|
||||||
|
cmd += f" --disks '{','.join(disk_args)}'"
|
||||||
|
|
||||||
cron_lines.append(f'{cron_time} root {cmd} >> /var/log/proxmenux/smart-schedule.log 2>&1')
|
cron_lines.append(f'{cron_time} root {cmd} >> /var/log/proxmenux/smart-schedule.log 2>&1')
|
||||||
|
|
||||||
|
|||||||
@@ -547,19 +547,54 @@ main() {
|
|||||||
# jobs keep whatever KEEP_* the .env has.
|
# jobs keep whatever KEEP_* the .env has.
|
||||||
_sb_hydrate_attached_retention
|
_sb_hydrate_attached_retention
|
||||||
|
|
||||||
local lock_file="${LOCK_DIR}/proxmenux-backup-${job_id}.lock"
|
# Create log_file and summary_file BEFORE the flock so any early
|
||||||
if command -v flock >/dev/null 2>&1; then
|
# failure (lock contention, missing tools, unreadable env) surfaces
|
||||||
exec 9>"$lock_file" || exit 1
|
# in the runner log the Monitor polls, instead of being lost to
|
||||||
if ! flock -n 9; then
|
# stderr/DEVNULL and leaving the UI stuck on "Waiting for runner
|
||||||
echo "Another run is active for job ${job_id}" >&2
|
# to start…" forever.
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
local ts log_file stage_root summary_file
|
local ts log_file stage_root summary_file
|
||||||
ts="$(date +%Y%m%d_%H%M%S)"
|
ts="$(date +%Y%m%d_%H%M%S)"
|
||||||
log_file="${LOG_DIR}/${job_id}-${ts}.log"
|
log_file="${LOG_DIR}/${job_id}-${ts}.log"
|
||||||
summary_file="${LOG_DIR}/${job_id}-last.status"
|
summary_file="${LOG_DIR}/${job_id}-last.status"
|
||||||
|
|
||||||
|
local lock_file="${LOCK_DIR}/proxmenux-backup-${job_id}.lock"
|
||||||
|
if command -v flock >/dev/null 2>&1; then
|
||||||
|
if ! exec 9>"$lock_file"; then
|
||||||
|
{
|
||||||
|
echo "=== Scheduled backup job ${job_id} aborted at $(date -Iseconds) ==="
|
||||||
|
echo "Cannot open lock file: $lock_file"
|
||||||
|
echo "Check that ${LOCK_DIR} exists and is writable by root."
|
||||||
|
} >"$log_file"
|
||||||
|
{
|
||||||
|
echo "JOB_ID=${job_id}"
|
||||||
|
echo "RUN_AT=$(date -Iseconds)"
|
||||||
|
echo "RESULT=failed"
|
||||||
|
echo "REASON=lock_open_failed"
|
||||||
|
} >"$summary_file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! flock -n 9; then
|
||||||
|
{
|
||||||
|
echo "=== Scheduled backup job ${job_id} aborted at $(date -Iseconds) ==="
|
||||||
|
echo "Another run is already active for this job (lock held: $lock_file)."
|
||||||
|
echo ""
|
||||||
|
echo "Possible causes:"
|
||||||
|
echo " - A previous run is still in progress (check with: ps auxf | grep run_scheduled_backup)."
|
||||||
|
echo " - A previous run hung and left the lock behind. Kill the stale"
|
||||||
|
echo " process (if any) and remove the lock: rm $lock_file"
|
||||||
|
echo ""
|
||||||
|
echo "This run did NOT execute a backup."
|
||||||
|
} >"$log_file"
|
||||||
|
{
|
||||||
|
echo "JOB_ID=${job_id}"
|
||||||
|
echo "RUN_AT=$(date -Iseconds)"
|
||||||
|
echo "RESULT=failed"
|
||||||
|
echo "REASON=another_run_active"
|
||||||
|
} >"$summary_file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
stage_root="$(mktemp -d /tmp/proxmenux-sched-stage.XXXXXX)"
|
stage_root="$(mktemp -d /tmp/proxmenux-sched-stage.XXXXXX)"
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -169,6 +169,13 @@ FAIL_COUNT=0
|
|||||||
log "Found $TOTAL_DISKS disk(s) to test"
|
log "Found $TOTAL_DISKS disk(s) to test"
|
||||||
|
|
||||||
for disk in $DISK_LIST; do
|
for disk in $DISK_LIST; do
|
||||||
|
# Accept both full paths and basenames. Older cron entries written
|
||||||
|
# before the Monitor prepended /dev/ passed disk names as bare
|
||||||
|
# basenames (sdb, nvme0n1), which then failed the block-device
|
||||||
|
# check below. Normalising here keeps those legacy entries working
|
||||||
|
# after the update without forcing the operator to recreate them.
|
||||||
|
[[ "$disk" != /* ]] && disk="/dev/$disk"
|
||||||
|
|
||||||
# Skip if disk doesn't exist
|
# Skip if disk doesn't exist
|
||||||
if [[ ! -b "$disk" ]]; then
|
if [[ ! -b "$disk" ]]; then
|
||||||
log "WARNING: Disk $disk not found, skipping"
|
log "WARNING: Disk $disk not found, skipping"
|
||||||
|
|||||||
Reference in New Issue
Block a user