fix: harden idempotent up reruns
Homelab Main / validate (push) Waiting to run Details
Homelab Main / running-update (push) Blocked by required conditions Details
Homelab Main / debian-ops (push) Blocked by required conditions Details

This commit is contained in:
juvenal.diaz 2026-10-07 13:54:45 -06:00
parent 81f6fd07c2
commit 2320a6ef81
2 changed files with 29 additions and 4 deletions

View File

@ -202,6 +202,8 @@ import sys
adlists_file = sys.argv[1]
print("PRAGMA busy_timeout = 30000;")
with open(adlists_file, encoding="utf-8") as handle:
addresses = [
line.strip()
@ -220,8 +222,17 @@ for address in addresses:
print(f"insert or ignore into adlist (address, enabled, comment) values ({quoted}, 1, 'homelab managed');")
print(f"update adlist set enabled = 1, comment = coalesce(nullif(comment, ''), 'homelab managed') where address = {quoted};")
PY
# shellcheck disable=SC2024
sudo docker exec -i "${pihole_container}" pihole-FTL sqlite3 /etc/pihole/gravity.db <"${sql_file}"
elapsed=0
until sudo docker exec -i "${pihole_container}" pihole-FTL sqlite3 /etc/pihole/gravity.db <"${sql_file}"; do
if ((elapsed >= 120)); then
echo "Timed out waiting for Pi-hole gravity database lock to clear." >&2
rm -f "${sql_file}"
return 1
fi
echo "Pi-hole gravity database is locked; retrying adlist sync in 5s..."
sleep 5
elapsed=$((elapsed + 5))
done
rm -f "${sql_file}"
sudo docker exec "${pihole_container}" pihole -g
}

View File

@ -2211,7 +2211,13 @@ ensure_pimox_pin_hookscript() {
printf '%s\n' ' my $pid_file = "/var/run/qemu-server/$vmid.pid";'
printf '%s\n' ' exit(0) unless -r $pid_file;'
printf '%s\n' ' chomp(my $pid = `cat $pid_file`);'
printf '%s\n' ' system("taskset -a -cp $cpus{$vmid} $pid");'
printf '%s\n' ' system("taskset -cp $cpus{$vmid} $pid >/dev/null 2>&1");'
printf '%s\n' ' open(my $threads, "-|", "ps -L -o tid= -p $pid 2>/dev/null") or exit(0);'
printf '%s\n' ' while (my $tid = <$threads>) {'
printf '%s\n' ' chomp($tid);'
printf '%s\n' ' next unless $tid =~ /^\d+$/;'
printf '%s\n' ' system("taskset -cp $cpus{$vmid} $tid >/dev/null 2>&1");'
printf '%s\n' ' }'
printf '%s\n' '}'
printf '%s\n' 'exit(0);'
} >"${local_tmp}"
@ -2243,7 +2249,15 @@ if sudo '${qm_bin}' status '${vmid}' >/dev/null 2>&1; then
fi
pid=\"\$(sudo cat \"\$pid_file\")\"
echo 'Applying Pimox KVM CPU affinity ${cpuset} to running VM ${vmid} pid' \"\$pid\"
sudo taskset -a -cp '${cpuset}' \"\$pid\" >/dev/null
sudo taskset -cp '${cpuset}' \"\$pid\" >/dev/null
if command -v ps >/dev/null 2>&1; then
ps -L -o tid= -p \"\$pid\" 2>/dev/null | while read -r tid; do
case \"\$tid\" in
''|*[!0-9]*) continue ;;
esac
sudo taskset -cp '${cpuset}' \"\$tid\" >/dev/null 2>&1 || true
done
fi
fi
fi"
done