feat: verify native Windows client probe and preserve unknown APT outcome
Rust development slice / linux (push) Failing after 7s
Rust development slice / linux (push) Failing after 7s
This commit is contained in:
@@ -58,6 +58,40 @@ def upgrade_agent(payload):
|
||||
return dict(binary_sha256=payload['sha256'], state_preserved_before_start=True, package_effects=False, backup=str(backup))
|
||||
|
||||
|
||||
def stored_attempt_evidence(payload):
|
||||
"""Read only already persisted evidence; no live collector/package command."""
|
||||
import sqlite3
|
||||
import re
|
||||
base = Path('/var/lib/rmm-apt-transaction'); active = base/'active'
|
||||
context = json.loads((active/'context.json').read_text())
|
||||
require(context['job_id'] == payload['job_id'] and context['attempt_id'] == payload['attempt_id'], 'exact stored attempt required')
|
||||
result = dict(files={}, records={}, context=context)
|
||||
for name in ('hook-armed.json','native-prechecks.json','sandbox-ready.json','sandbox-result.json','launch.json'):
|
||||
path = active/name
|
||||
result['files'][name] = dict(exists=path.exists(), symlink=path.is_symlink())
|
||||
if path.is_file() and not path.is_symlink(): result['records'][name] = json.loads(path.read_text())
|
||||
for name in ('bootstrap-attempt-rmm-apt-fixture-install-1.0.json','bootstrap-retry-rmm-apt-fixture-install-1.0.json',
|
||||
'acceptance-rmm-apt-fixture-install-1.0.json','pending-acceptance-rmm-apt-fixture-install-1.0.json'):
|
||||
path = base/name
|
||||
result['files'][name] = dict(exists=path.exists(), symlink=path.is_symlink(), sha256=hashlib.sha256(path.read_bytes()).hexdigest() if path.is_file() else None)
|
||||
with sqlite3.connect('file:/var/lib/rmm-helper/consumption.sqlite?mode=ro', uri=True) as db:
|
||||
row = db.execute('SELECT c.result,e.outcome FROM consumed c JOIN execution_evidence e USING(grant_id) WHERE c.grant_id=?', (context['grant_id'],)).fetchone()
|
||||
result['ledger'] = dict(result=json.loads(row[0]) if row[0] else None, outcome=json.loads(row[1]) if row[1] else None,
|
||||
consumed=db.execute('SELECT count(*) FROM consumed').fetchone()[0], unresolved=db.execute('SELECT count(*) FROM consumed WHERE result IS NULL').fetchone()[0])
|
||||
result['logs'] = {}
|
||||
for name in ('dpkg.log','term.log','history.log'):
|
||||
path = base/'log'/name
|
||||
if path.is_file() and not path.is_symlink():
|
||||
raw = path.read_bytes(); require(len(raw) <= 1024*1024, 'bounded stored log')
|
||||
text = raw.decode('utf-8', errors='replace')
|
||||
result['logs'][name] = dict(sha256=hashlib.sha256(raw).hexdigest(), size=len(raw),
|
||||
fixture_states=re.findall(r'\bstatus (not-installed|half-installed|unpacked|half-configured|installed|triggers-pending|triggers-awaited) rmm-mvp-test(?::all)? (1\.[01])\b', text),
|
||||
configure_record=bool(re.search(r'\bconfigure rmm-mvp-test(?::all)?\b', text)),
|
||||
setup_message='Setting up rmm-mvp-test (1.0)' in text,
|
||||
dpkg_error='dpkg: error' in text)
|
||||
return result
|
||||
|
||||
|
||||
def switch_endpoint(payload):
|
||||
import sqlite3
|
||||
os.umask(0o077)
|
||||
|
||||
Reference in New Issue
Block a user