Preserve timely reboot evidence and document blocked original reconciliation
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -243,6 +243,30 @@ def legacy_helper_unit_metadata(payload):
|
||||
clock_query_filters=[line for line in lines if line in ('SystemCallFilter=adjtimex clock_adjtime','SystemCallFilter=adjtimex')])
|
||||
|
||||
|
||||
def start_helper_after_boot_clock(payload):
|
||||
"""Start the existing helper after its clock guard failed; never a job."""
|
||||
import contextlib
|
||||
import sqlite3
|
||||
unit=Path('/etc/systemd/system/rmm-helper-cloud.service')
|
||||
require(hashlib.sha256(unit.read_bytes()).hexdigest()==payload['unit_sha256']
|
||||
and hashlib.sha256(Path('/usr/local/libexec/rmm-privileged-helper').read_bytes()).hexdigest()==payload['helper_sha256'],'same qualified helper/unit')
|
||||
require(json.loads(Path('/var/lib/rmm-agent-remote/identity.json').read_text())['agent_id']==payload['agent_id'],'same device')
|
||||
boot=Path('/proc/sys/kernel/random/boot_id').read_text().strip()
|
||||
require(boot!=payload['old_boot_id'],'actual guest already rebooted; never request another reboot')
|
||||
with contextlib.closing(sqlite3.connect('file:/var/lib/rmm-helper/consumption.sqlite?mode=ro',uri=True)) as db:
|
||||
require(db.execute('PRAGMA integrity_check').fetchone()[0]=='ok' and
|
||||
db.execute('SELECT count(*) FROM helper_sync_meta WHERE fault IS NOT NULL').fetchone()[0]==0,'preserved healthy ledger')
|
||||
rows=db.execute('SELECT c.job,c.attempt,e.outcome FROM consumed c JOIN execution_evidence e USING(grant_id) WHERE c.result IS NULL').fetchall()
|
||||
require(len(rows)==1 and rows[0][:2]==(payload['job_id'],payload['attempt_id'])
|
||||
and json.loads(rows[0][2])['state']=='awaiting_reboot','only exact existing reboot may await reconciliation')
|
||||
before=subprocess.run(['systemctl','show','rmm-helper-cloud.service','-p','ActiveState','--value'],capture_output=True,check=True,timeout=10).stdout.strip()
|
||||
require(before==b'failed','known boot-start failure only')
|
||||
subprocess.run(['systemctl','start','rmm-helper-cloud.service'],capture_output=True,check=True,timeout=20)
|
||||
active=subprocess.run(['systemctl','show','rmm-helper-cloud.service','-p','ActiveState','--value'],capture_output=True,check=True,timeout=10).stdout.strip()==b'active'
|
||||
return dict(started_existing_helper=active,new_boot_id=boot,ledger_reset=False,
|
||||
jobs_created=False,grants_created=False,reboot_requested=False)
|
||||
|
||||
|
||||
def disable_legacy_helper_autostart(payload):
|
||||
"""Disable only the stopped historical dev helper; never stop/start a unit."""
|
||||
import contextlib
|
||||
|
||||
Reference in New Issue
Block a user