RPF-WP-0015: verify installed ops-warden against accepted published revision; list drill PVC in review check
Round-2 owner review follow-ups (railiance-infra, railiance-cluster, railiance-platform). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 680842@bnt-lap001 Assistant-Session: 54eb9e8e-7d6b-4f0c-b7a6-a6db62075883
This commit is contained in:
parent
ce8286dff9
commit
6152aa9e86
6 changed files with 110 additions and 7 deletions
|
|
@ -638,6 +638,49 @@ def validate_ops_warden_receipt(path: Path) -> dict[str, Any]:
|
|||
return {"path": str(path), "accepted_revision": revision, "verified": True}
|
||||
|
||||
|
||||
OPS_WARDEN_REPO = Path("/home/worsch/ops-warden")
|
||||
|
||||
|
||||
def installed_warden_package(tool_python: Path) -> Path:
|
||||
"""Package directory of the warden actually on PATH (uv tool environment)."""
|
||||
completed = subprocess.run(
|
||||
[str(tool_python), "-I", "-c", "import os, warden; print(os.path.dirname(warden.__file__))"],
|
||||
text=True, capture_output=True, check=False,
|
||||
)
|
||||
if completed.returncode != 0 or not completed.stdout.strip():
|
||||
raise PreflightError("installed warden package could not be located")
|
||||
return Path(completed.stdout.strip())
|
||||
|
||||
|
||||
def verify_installed_warden(package: Path, repo: Path, revision: str) -> dict[str, Any]:
|
||||
"""Prove the installed warden equals the accepted, published ops-warden revision.
|
||||
|
||||
The uv tool is a non-editable directory install that records no revision, so
|
||||
compare every installed module byte-for-byte with that revision's tree.
|
||||
"""
|
||||
def git(*args: str) -> subprocess.CompletedProcess[bytes]:
|
||||
return subprocess.run(["git", "-C", str(repo), *args], capture_output=True, check=False)
|
||||
|
||||
if git("merge-base", "--is-ancestor", revision, "origin/main").returncode != 0:
|
||||
raise PreflightError("accepted ops-warden revision is not published on origin/main")
|
||||
listed = git("ls-tree", "-r", "--name-only", revision, "src/warden/")
|
||||
if listed.returncode != 0:
|
||||
raise PreflightError("accepted ops-warden revision is not available locally")
|
||||
expected = {
|
||||
name.removeprefix("src/warden/")
|
||||
for name in listed.stdout.decode().splitlines()
|
||||
if name.endswith(".py")
|
||||
}
|
||||
installed = {path.relative_to(package).as_posix() for path in package.rglob("*.py")}
|
||||
if installed != expected:
|
||||
raise PreflightError("installed warden module set differs from the accepted revision")
|
||||
for name in sorted(expected):
|
||||
blob = git("show", f"{revision}:src/warden/{name}")
|
||||
if blob.returncode != 0 or blob.stdout != (package / name).read_bytes():
|
||||
raise PreflightError("installed warden differs from the accepted revision")
|
||||
return {"installed_revision_matches": True, "modules_compared": len(expected)}
|
||||
|
||||
|
||||
CONSOLE_RECEIPT_ID = re.compile(r"^RAIL01-CONSOLE-(\d{8})T\d{6}Z$")
|
||||
|
||||
|
||||
|
|
@ -830,6 +873,13 @@ def reboot_preflight(remote: Remote, args: argparse.Namespace) -> dict[str, Any]
|
|||
warden_receipt = None
|
||||
try:
|
||||
warden_receipt = validate_ops_warden_receipt(Path(args.ops_warden_acceptance_receipt))
|
||||
warden_receipt.update(
|
||||
verify_installed_warden(
|
||||
installed_warden_package(Path(args.warden_tool_python)),
|
||||
OPS_WARDEN_REPO,
|
||||
warden_receipt["accepted_revision"],
|
||||
)
|
||||
)
|
||||
except PreflightError as exc:
|
||||
receipt_errors["ops_warden_acceptance_receipt"] = str(exc)
|
||||
console_receipt = None
|
||||
|
|
@ -918,6 +968,11 @@ def main() -> int:
|
|||
parser.add_argument("--scenario-id", help="new scenario id; consumed drill ids are denied")
|
||||
parser.add_argument("--human-decision-id", help="fresh human GO decision id")
|
||||
parser.add_argument("--ops-warden-acceptance-receipt", default=OPS_WARDEN_RECEIPT)
|
||||
parser.add_argument(
|
||||
"--warden-tool-python",
|
||||
default=str(Path.home() / ".local/share/uv/tools/ops-warden/bin/python"),
|
||||
help="Python of the uv tool environment that provides `warden` on PATH",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--accept-terminating-pvc", action="append",
|
||||
help="namespace/name of a pre-existing Terminating PVC accepted for the window",
|
||||
|
|
|
|||
|
|
@ -152,7 +152,15 @@ def check_command(check_id: str) -> list[str]:
|
|||
if check_id == "database-lease-preflight":
|
||||
return [sys.executable, "scripts/audit-core-recovery-preflight.py", "database-lease"]
|
||||
if check_id == "node-reboot-preflight":
|
||||
return [sys.executable, "scripts/audit-core-recovery-preflight.py", "node-reboot"]
|
||||
# Procedure review lists the known stuck drill PVC explicitly; resolving it
|
||||
# stays a rapp-postgres pre-window gate in the reboot runbook.
|
||||
return [
|
||||
sys.executable,
|
||||
"scripts/audit-core-recovery-preflight.py",
|
||||
"node-reboot",
|
||||
"--accept-terminating-pvc",
|
||||
"platform-pg-drill/platform-pg-drill-1",
|
||||
]
|
||||
raise ReviewError(f"unknown check id: {check_id}")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue