fix: M8 review findings (restore ownership, barrier tool, World0 claimRef, CI selection, drill verdicts)
P1: restore-world.sh claims its objects path (mkdir) and the database (a held session with a restore try-lock and the exclusive upgrade lock), and removes only what it created, so a losing restore never drops a winner's schema. P2: barrier Ready-pod selection via shared jsonpath helper with fixtures; barrier pod fsGroup; script-generated pods inspected by the policy check; World0 PV claim references protected; ci-paths.sh uses the event's real base and runs on uncertainty; fault-drill asserts RTO and needs positive quarantine evidence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,10 @@ environment-isolation or World0-protection invariant is broken:
|
||||
the digest already pinned in stage (promotion, never a fresh build);
|
||||
- scheduling (ADR-0076): every pod that mounts the node-local objects volume
|
||||
selects the store node; aevolution.io/compute is only ever preferred, never
|
||||
required; upgrade-rehearsal flags never appear in a deployed workload.
|
||||
required; upgrade-rehearsal flags never appear in a deployed workload;
|
||||
- the Pods the backup and barrier scripts generate (rendered with --print-manifest)
|
||||
keep the database-tool security contract: non-root 10001 with fsGroup 10001 so
|
||||
the 0440 Secret files are readable, no token, read-only root, no escalation.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
@@ -118,7 +121,9 @@ if policy and binding:
|
||||
text = yaml.safe_dump(spec)
|
||||
for needle in ("aevolution:world0-break-glass", "evolution-world0", "aevolution-world0",
|
||||
"aevolution-platform",
|
||||
"aevolution.io/protected", "Retain"):
|
||||
"aevolution.io/protected", "Retain",
|
||||
"has(object.spec.claimRef.namespace)",
|
||||
"object.spec.claimRef.name == oldObject.spec.claimRef.name"):
|
||||
check(needle in text, f'world0 policy must reference {needle}')
|
||||
|
||||
# Argo CD projects and applications.
|
||||
@@ -368,6 +373,47 @@ with tempfile.TemporaryDirectory() as empty:
|
||||
and 'kubectl' not in result.stderr,
|
||||
f'{tool} must refuse {bad!r} before kubectl (rc={result.returncode})')
|
||||
|
||||
# Script-generated Pods (review M8 P2): rendered offline and checked like manifests.
|
||||
retained_hex = next((v.get('value', '').split()[0] for d in manifests.get(
|
||||
'deploy/kubernetes/region/dev/region-values.yaml', [])
|
||||
for c in d['spec']['template']['spec']['containers'] for v in c.get('env', [])
|
||||
if v.get('name') == 'REGION_RETAINED' and v.get('value')), None)
|
||||
generators = [('tools/backup/cluster-backup.sh', ['dev', '--print-manifest'], 'backup')]
|
||||
if retained_hex:
|
||||
generators.append(('tools/ops/upgrade-barrier.sh',
|
||||
['dev', '--retire', retained_hex, '--print-manifest'], 'migrate'))
|
||||
else:
|
||||
check(False, 'dev REGION_RETAINED is empty: the barrier Pod cannot be rendered')
|
||||
egress = next((d for p, d in objects if d['kind'] == 'NetworkPolicy'
|
||||
and d['metadata']['name'] == 'aevolution-database-egress'), {})
|
||||
admitted = [v for e in egress.get('spec', {}).get('podSelector', {}).get('matchExpressions', [])
|
||||
for v in e.get('values', [])]
|
||||
for tool, args, component in generators:
|
||||
rendered = subprocess.run([shutil.which('bash') or '/bin/bash', os.path.join(ROOT, tool)] + args,
|
||||
capture_output=True, text=True)
|
||||
check(rendered.returncode == 0, f'{tool} --print-manifest failed: {rendered.stderr.strip()}')
|
||||
if rendered.returncode != 0:
|
||||
continue
|
||||
pod = yaml.safe_load(rendered.stdout)
|
||||
spec = pod['spec']
|
||||
context = spec.get('securityContext', {})
|
||||
check(context.get('runAsNonRoot') is True and context.get('runAsUser') == 10001
|
||||
and context.get('runAsGroup') == 10001 and context.get('fsGroup') == 10001,
|
||||
f'{tool}: the generated Pod must run as 10001 with fsGroup 10001 (Secret access)')
|
||||
check(spec.get('automountServiceAccountToken') is False, f'{tool}: the generated Pod mounts no token')
|
||||
for container in spec['containers']:
|
||||
sc = container.get('securityContext', {})
|
||||
check(sc.get('readOnlyRootFilesystem') is True and sc.get('allowPrivilegeEscalation') is False,
|
||||
f'{tool}: read-only root and no privilege escalation')
|
||||
for volume in spec.get('volumes', []):
|
||||
if 'secret' in volume:
|
||||
check(volume['secret'].get('defaultMode') == 0o440,
|
||||
f'{tool}: Secret files stay 0440 (never world-readable)')
|
||||
labels = pod['metadata'].get('labels', {})
|
||||
check(labels.get('app.kubernetes.io/component') == component and component in admitted,
|
||||
f'{tool}: component {component} must be admitted by the database egress policy')
|
||||
check(pod['metadata'].get('namespace') == 'evolution-dev', f'{tool}: renders into its environment')
|
||||
|
||||
for message in failures:
|
||||
print('FAIL', message)
|
||||
print(f'deploy policy: {len(objects)} objects in {len(manifests)} files, {len(failures)} failures')
|
||||
|
||||
Reference in New Issue
Block a user