Harden worker queue and restore drill defaults
This commit is contained in:
@@ -14,6 +14,7 @@ import sys
|
||||
import tempfile
|
||||
from collections.abc import Callable, Iterable
|
||||
from contextlib import contextmanager
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
@@ -65,6 +66,11 @@ def main() -> int:
|
||||
parser.add_argument("--runtime-root", type=Path, help="Directory for temporary drill runtimes. Defaults to a new temp directory.")
|
||||
parser.add_argument("--keep-runtime", action="store_true", help="Keep the temporary drill runtime after completion.")
|
||||
parser.add_argument("--format", choices=("json", "text"), default="text", help="Output format.")
|
||||
parser.add_argument(
|
||||
"--evidence-path",
|
||||
type=Path,
|
||||
help="Write an atomic machine-readable drill result for the Ops health surface.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
runtime_root = args.runtime_root or Path(tempfile.mkdtemp(prefix="govoplan-installer-drill-"))
|
||||
@@ -88,7 +94,14 @@ def main() -> int:
|
||||
if not args.keep_runtime and args.runtime_root is None:
|
||||
shutil.rmtree(runtime_root, ignore_errors=True)
|
||||
|
||||
payload = {"ok": ok, "runtime_root": str(runtime_root), "scenarios": results}
|
||||
payload = {
|
||||
"ok": ok,
|
||||
"completed_at": datetime.now(tz=UTC).isoformat(),
|
||||
"runtime_root": str(runtime_root),
|
||||
"scenarios": results,
|
||||
}
|
||||
if args.evidence_path:
|
||||
_write_evidence(args.evidence_path, payload)
|
||||
if args.format == "json":
|
||||
print(json.dumps(payload, indent=2, sort_keys=True))
|
||||
else:
|
||||
@@ -105,6 +118,18 @@ def main() -> int:
|
||||
return 0 if ok else 1
|
||||
|
||||
|
||||
def _write_evidence(path: Path, payload: dict[str, object]) -> None:
|
||||
path = path.expanduser()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
temporary = path.with_suffix(path.suffix + ".tmp")
|
||||
temporary.write_text(
|
||||
json.dumps(payload, indent=2, sort_keys=True) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
temporary.chmod(0o600)
|
||||
temporary.replace(path)
|
||||
|
||||
|
||||
def package_failure(root: Path) -> dict[str, object]:
|
||||
database_url, database = _sqlite_database(root)
|
||||
plan = _saved_install_plan(database, "package-failure-example")
|
||||
|
||||
Reference in New Issue
Block a user