fix(monitor): place the Secure Gateway template on an active storage

This commit is contained in:
MacRimi
2026-10-30 22:58:12 +01:00
parent dc823bc21b
commit aa4adc34a9
12 changed files with 234 additions and 259 deletions
+6 -24
View File
@@ -9,20 +9,17 @@
# Last Updated: 16/10/2026
# ==========================================================
# Description:
# Applies the automatic disk-read policy to LVM metadata scans in both
# Monitor readers. Excluded and idle disks receive no power-mode probe;
# every device built on them is excluded too, and the scan's own reads
# are not taken as activity. No eligible devices means no scan.
# Applies the disk exclusions to LVM metadata scans in both Monitor
# readers. Excluded disks receive no power-mode probe and a disk in
# standby is not woken; every device built on them is excluded too. No
# eligible devices means no scan.
# ==========================================================
import json
import re
import subprocess
import threading
_NAME = re.compile(r"[A-Za-z0-9._+-]+")
_scan_lock = threading.Lock()
_scanned_disks = set()
def _topology():
@@ -116,14 +113,11 @@ def lvm_device_args(standby_check):
excluded = excluded_disk_names()
blocked = set()
for disk in sorted(disks):
# Test policy first: even CHECK POWER MODE is forbidden for an
# excluded/idle disk. Some USB bridges do not honour -n standby.
# Test the exclusion first: even CHECK POWER MODE is forbidden
# for an excluded disk. Some USB bridges do not honour -n standby.
if disk_read_policy(disk, excluded) != "read" or standby_check(disk):
blocked.add(disk)
allowed = sorted(f"/dev/{name}" for name in volumes if not (_disks_under(name, parents) & blocked))
with _scan_lock:
_scanned_disks.clear()
_scanned_disks.update(disks - blocked)
if not blocked:
return []
filters = _lvm_filters()
@@ -140,15 +134,3 @@ def lvm_device_args(standby_check):
# Unavailable exclusions, topology or policy are not permission to
# open devices that may have been deliberately excluded.
return None
def settle_scan_reads():
"""The LVM scan reads the disks it is allowed to. Those reads are its
own, so they must not make an unused disk look busy at the next check."""
try:
from disk_temperature_history import settle_own_reads
with _scan_lock:
disks = set(_scanned_disks)
settle_own_reads(disks)
except Exception:
pass