Reconcile recovered cleanup failures in pipeline API and portal
This commit is contained in:
parent
adf122a43b
commit
bef8835ae2
5 changed files with 110 additions and 20 deletions
17
STATUS.md
17
STATUS.md
|
|
@ -1,6 +1,21 @@
|
|||
# Infrastructure implementation status
|
||||
|
||||
Updated 2026-11-06. Architectural acceptance is separate from implementation.
|
||||
Updated 2026-11-07. Architectural acceptance is separate from implementation.
|
||||
|
||||
## Portal pipeline status recovery
|
||||
|
||||
Run `20261107T055158Z` published Core/GNOME and verified public downloads before
|
||||
failing to archive reused worker sources during cleanup (rsync exit 23). The
|
||||
archive-aware source fallback fixes that cause. `cleanup-recovery.json` records
|
||||
the subsequent verified cleanup; the original failure remains historical evidence.
|
||||
`pipeline/reconcile-cleanup.py --base /opt/archipelago --run 20261107T055158Z`
|
||||
reconciles only the latest published cleanup failure under the cycle lock, checks
|
||||
the recovery source hash and released artifact identities, preserves the original
|
||||
state in `state-before-recovery.json`, and writes `complete` with explicit manual
|
||||
recovery provenance. It relies on the operator's recorded cleanup evidence.
|
||||
The driver, systemd terminal hook and reconciliation share a status writer.
|
||||
The portal distinguishes post-publication failures from recovered completion.
|
||||
This does not rerun acceptance or establish an autonomous successful cycle.
|
||||
|
||||
## Latest scheduling instruction — D-090
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
spec = importlib.util.spec_from_file_location('cycle', Path(__file__).with_name('release-cycle.py'))
|
||||
|
|
@ -16,10 +17,6 @@ if latest.exists():
|
|||
state = json.loads(latest.read_text())
|
||||
if state.get('invocation_id') == os.environ.get('INVOCATION_ID') and state['state'] not in ('complete', 'failed'):
|
||||
state.update(failed_phase=state['state'], state='failed', stage_title='Ошибка',
|
||||
error='Coordinator terminated: ' + os.environ.get('SERVICE_RESULT', 'unknown'))
|
||||
cycle.atomic(parent / state['run'] / 'state.json', state)
|
||||
cycle.atomic(latest, state)
|
||||
cycle.atomic(base / 'data/public/pipeline.json', state)
|
||||
text = f"Прогон: {state['run']}\nЭтап: Ошибка\nПричина: {state['error']}\n"
|
||||
(parent / 'latest.txt.tmp').write_text(text)
|
||||
(parent / 'latest.txt.tmp').replace(parent / 'latest.txt')
|
||||
error='Coordinator terminated: ' + os.environ.get('SERVICE_RESULT', 'unknown'),
|
||||
updated=datetime.now(timezone.utc).isoformat())
|
||||
cycle.write_status(base, state)
|
||||
|
|
|
|||
59
pipeline/reconcile-cleanup.py
Normal file
59
pipeline/reconcile-cleanup.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Reconcile the latest published run after documented manual cleanup recovery."""
|
||||
import argparse
|
||||
from datetime import datetime, timezone
|
||||
import fcntl
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
spec = importlib.util.spec_from_file_location('cycle', Path(__file__).with_name('release-cycle.py'))
|
||||
cycle = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(cycle)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--base', type=Path, required=True)
|
||||
parser.add_argument('--run', required=True)
|
||||
args = parser.parse_args()
|
||||
parent = args.base / 'data/private/release-cycle'
|
||||
with (parent / 'cycle.lock').open('a') as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
state = json.loads((parent / 'latest.json').read_text())
|
||||
if state['run'] != args.run or state['state'] != 'failed' or not state.get('published') or state.get('failed_phase') != 'cleaning-worker':
|
||||
raise ValueError('Expected latest published run failed during cleanup')
|
||||
run = parent / state['run']
|
||||
run_state = json.loads((run / 'state.json').read_text())
|
||||
if any(run_state.get(key) != state.get(key) for key in ('run', 'state', 'published', 'failed_phase', 'error_details', 'releases')):
|
||||
raise ValueError('Latest and run states differ')
|
||||
state = run_state
|
||||
evidence = json.loads((run / 'cleanup-recovery.json').read_text())
|
||||
with Path(evidence['source_archive']).open('rb') as source:
|
||||
digest = hashlib.file_digest(source, 'sha256').hexdigest()
|
||||
if digest != evidence['source_sha256']:
|
||||
raise ValueError('Recovery source checksum mismatch')
|
||||
released = {(r['variant'], r['sha256']) for r in state['releases']}
|
||||
cleaned = {(r['variant'], r['sha256']) for r in evidence['cleaned']}
|
||||
if not cleaned or not cleaned <= released:
|
||||
raise ValueError('Recovery does not match published artifacts')
|
||||
# Keep the exact historical failure, including original exit diagnostics.
|
||||
original = run / 'state-before-recovery.json'
|
||||
if original.exists():
|
||||
if json.loads(original.read_text()) != state:
|
||||
raise ValueError('Existing recovery history differs')
|
||||
else:
|
||||
cycle.atomic(original, state)
|
||||
now = datetime.now(timezone.utc).isoformat()
|
||||
state['recovery'] = dict(kind='manual-cleanup', reconciled=now,
|
||||
evidence='cleanup-recovery.json', original_state='state-before-recovery.json')
|
||||
for key in ('error', 'error_details', 'failed_phase'):
|
||||
state.pop(key, None)
|
||||
state.update(state='complete', stage_title='Готово; очистка восстановлена', updated=now, finished=now)
|
||||
cycle.write_status(args.base, state)
|
||||
print(json.dumps(state, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -31,6 +31,27 @@ def atomic(path, value):
|
|||
temp.replace(path)
|
||||
|
||||
|
||||
def write_status(base, state):
|
||||
parent = base / 'data/private/release-cycle'
|
||||
run = parent / state['run']
|
||||
if state['state'] == 'failed' and state.get('published'):
|
||||
state['stage_title'] = ('Образы опубликованы; ошибка очистки' if state.get('failed_phase') == 'cleaning-worker'
|
||||
else 'Образы опубликованы; ошибка после публикации')
|
||||
atomic(run / 'state.json', state)
|
||||
atomic(parent / 'latest.json', state)
|
||||
atomic(base / 'data/public/pipeline.json', state)
|
||||
text = f"Прогон: {state['run']}\nСтенд: {state['worker']}\nЭтап: {state['stage_title']}\nОбновлено: {state['updated']}\nОпубликовано: {'да' if state['published'] else 'нет'}\n"
|
||||
if state.get('flatpak'):
|
||||
text += 'Flatpak: ' + state['flatpak']['state'] + '\n'
|
||||
if state.get('error'):
|
||||
text += 'Причина: ' + state['error'] + '\n'
|
||||
if state.get('recovery'):
|
||||
text += 'Восстановление: очистка завершена; исходная ошибка сохранена в state-before-recovery.json\n'
|
||||
text += f"Результаты и логи: {run}\n"
|
||||
(parent / 'latest.txt.tmp').write_text(text)
|
||||
(parent / 'latest.txt.tmp').replace(parent / 'latest.txt')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--config', default=os.environ.get('ARCHIPELAGO_CYCLE_CONFIG', '/etc/archipelago/release-cycle.json'))
|
||||
|
|
@ -90,17 +111,7 @@ def main():
|
|||
'kde-installed-acceptance': 'Приёмка KDE в VM'})
|
||||
def phase(name, **extra):
|
||||
state.update(state=name, stage_title=titles.get(name, name), updated=datetime.now(timezone.utc).isoformat(), **extra)
|
||||
atomic(run / 'state.json', state)
|
||||
atomic(parent / 'latest.json', state)
|
||||
atomic(base / 'data/public/pipeline.json', state)
|
||||
text = f"Прогон: {stamp}\nСтенд: {worker}\nЭтап: {state['stage_title']}\nОбновлено: {state['updated']}\nОпубликовано: {'да' if state['published'] else 'нет'}\n"
|
||||
if state.get('flatpak'):
|
||||
text += 'Flatpak: ' + state['flatpak']['state'] + '\n'
|
||||
if state.get('error'):
|
||||
text += 'Причина: ' + state['error'] + '\n'
|
||||
text += f"Логи сборки/проверок: {worker}:{remote_root}\nРезультаты: {run}\n"
|
||||
(parent / 'latest.txt.tmp').write_text(text)
|
||||
(parent / 'latest.txt.tmp').replace(parent / 'latest.txt')
|
||||
write_status(base, state)
|
||||
print(json.dumps(state), flush=True)
|
||||
def call(argv, timeout=14400):
|
||||
subprocess.run([str(x) for x in argv], check=True, timeout=timeout)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,15 @@
|
|||
'preparing-publication': 'Проверка свидетельств', 'signing-and-publishing': 'Подпись и публикация',
|
||||
'verifying-public-endpoints': 'Проверка скачивания', 'cleaning-worker': 'Очистка сборочного окружения',
|
||||
'complete': 'Цикл завершён', 'failed': 'Цикл завершился ошибкой'};
|
||||
label.textContent = `${names[status.state] || status.state} · ${status.run}`;
|
||||
let title = names[status.state] || status.stage_title || status.state;
|
||||
if (status.state === 'failed' && status.published) {
|
||||
title = status.failed_phase === 'cleaning-worker'
|
||||
? 'Образы опубликованы; ошибка очистки сборочного окружения'
|
||||
: 'Образы опубликованы; ошибка после публикации';
|
||||
} else if (status.state === 'complete' && status.recovery) {
|
||||
title = 'Образы опубликованы; очистка восстановлена, цикл завершён';
|
||||
}
|
||||
label.textContent = `${title} · ${status.run}`;
|
||||
} catch { label.textContent = 'Состояние временно недоступно.'; }
|
||||
})();
|
||||
(async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue