From 0c6d4f77f0e1da0ed8269d49698320cfc81274d6 Mon Sep 17 00:00:00 2001 From: suguanYang Date: Tue, 1 Dec 2026 07:44:39 -0700 Subject: [PATCH] Stop deploy/opensearch/operator.py shadowing the stdlib operator module Scripts in deploy/opensearch run with that folder first on sys.path, so Python's own `import operator` (from collections, at startup) loaded the repository's operator.py and failed with a circular-import ImportError. It stayed hidden only because the shared package's editable-install .pth happens to import collections before the script folder is added. Rename the module to native_operator.py, the name workload_snapshot.py already loads it under, and update every reference. The launch-issuer kind stays `operator`, so installed backup services keep their command. Co-Authored-By: Claude Opus 5.5 --- deploy/opensearch/README.md | 12 ++++++------ deploy/opensearch/launch-issuer.py | 2 +- deploy/opensearch/manage.py | 2 +- .../opensearch/{operator.py => native_operator.py} | 0 deploy/opensearch/tests/test_execution.py | 6 +++--- deploy/opensearch/workload_snapshot.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) rename deploy/opensearch/{operator.py => native_operator.py} (100%) diff --git a/deploy/opensearch/README.md b/deploy/opensearch/README.md index 32a4d787d..2ae065b6e 100644 --- a/deploy/opensearch/README.md +++ b/deploy/opensearch/README.md @@ -357,24 +357,24 @@ does not prove that a native issuer stopped. recovery observes the old instance stopped before non-forced detach, waits for attach on the approved target, verifies filesystem and mount identity, and starts the pinned service. It never formats or provisions. -- Unresolved prior physical issuer: execute `operator.py fence-host` in its own +- Unresolved prior physical issuer: execute `native_operator.py fence-host` in its own physical unit. The plan binds the exact actual `old_issuer_receipt_path` and raw `old_issuer_receipt_sha256`, plus the old issuer identity fields. The source gate reserves one durable fencing intent before the SSM sends. It retains the actual command IDs and confirms the exact operator control group and native unit are stopped. If an acknowledgment is lost, - `operator.py reconcile-fence --fence-token ORIGINAL_UUID` observes existing + `native_operator.py reconcile-fence --fence-token ORIGINAL_UUID` observes existing tagged commands only; it never reissues them. Takeover requires the proven receipt and exact old-token CAS. No TTL frees unknown authority. - An interrupted first shadow pilot while PostgreSQL is serving can use - `operator.py release-empty-shadow` with the same old-issuer plan. The command + `native_operator.py release-empty-shadow` with the same old-issuer plan. The command observes the collected transient unit through SSM and checks the exact native identity, namespace inventory, and primary shard history. It records the release only before any migration attempt or native write. The shared native service stays online. Run the selected inputs through the read-only preflight under the pilot's temporary database role before retrying. - A shadow backfill that stopped after native writes while PostgreSQL is - serving can use `operator.py release-stopped-shadow` with the same + serving can use `native_operator.py release-stopped-shadow` with the same old-issuer plan. It observes the collected transient unit through SSM like `release-empty-shadow`, then releases only when no migration attempt is pending or running, no migration build is writing, no lease is unreleased, @@ -387,7 +387,7 @@ does not prove that a native issuer stopped. attempt, writing build or uncertain lease, and the command refuses; use `fence-host` then. Check each condition with read-only SQL before running it. - After a successful host restart, execute the source-owned - `operator.py reconcile-restart` against the same recovery operation UUID in + `native_operator.py reconcile-restart` against the same recovery operation UUID in a new physical invocation. The plan binds `inventory_path`, `inventory_sha256`, `host_recovery_receipt_path`, `transition_script_sha256`, `target_backend` and `maximum_step_seconds`. The restart inventory v1 contains @@ -515,7 +515,7 @@ of about 100 units each: limit keeps more namespaces warm and makes such bursts rarer. Use `launch-issuer.py --kind operator` with the `release` child command shown -by `operator.py --help`. Review separate plans for `phase:"prepare"`, +by `native_operator.py --help`. Review separate plans for `phase:"prepare"`, `"forward"` and `"rollback"`. Each plan binds `account_id`, exact source hash, transition script SHA, existing gate rule ARN, conditions SHA, original forward actions and a known fixed 503 response. The tool checks the actual route diff --git a/deploy/opensearch/launch-issuer.py b/deploy/opensearch/launch-issuer.py index 6959dc91b..ed1567ff9 100644 --- a/deploy/opensearch/launch-issuer.py +++ b/deploy/opensearch/launch-issuer.py @@ -12,7 +12,7 @@ _ROOT: Path = Path(__file__).resolve().parents[2] -_PROGRAMS: dict[str, Path] = {"operator": _ROOT / "deploy/opensearch/operator.py", +_PROGRAMS: dict[str, Path] = {"operator": _ROOT / "deploy/opensearch/native_operator.py", "recovery": _ROOT / "deploy/opensearch/recovery.py", "release-step": _ROOT / "deploy/opensearch/release.py", "workload": _ROOT / "scripts/probes/run-opensearch-workload.py"} diff --git a/deploy/opensearch/manage.py b/deploy/opensearch/manage.py index 980adf675..70ffc7fc5 100644 --- a/deploy/opensearch/manage.py +++ b/deploy/opensearch/manage.py @@ -348,7 +348,7 @@ def _main() -> int: result = OpenSearchOperations.planCost(_readJson(arguments.quote), _readJson(arguments.usage)) elif command == "backup-cycle": if arguments.execute: - raise ValueError("Run the authoritative operator.py backup command to snapshot and qualify data") + raise ValueError("Run the authoritative native_operator.py backup command to snapshot and qualify data") inventory: object = _readJson(arguments.inventory) boundaryDigest: str = sha256(arguments.boundary.read_bytes()).hexdigest() result = {"mode": "dry-run", "data_verified": False, "retention_authorized": False, diff --git a/deploy/opensearch/operator.py b/deploy/opensearch/native_operator.py similarity index 100% rename from deploy/opensearch/operator.py rename to deploy/opensearch/native_operator.py diff --git a/deploy/opensearch/tests/test_execution.py b/deploy/opensearch/tests/test_execution.py index b8ad246c0..c67edd7bf 100644 --- a/deploy/opensearch/tests/test_execution.py +++ b/deploy/opensearch/tests/test_execution.py @@ -92,10 +92,10 @@ def test_manifest_seed_is_an_explicit_fenced_operator_command(tmp_path: Path) -> assert launch.returncode == 0, launch.stderr launchPlan = json.loads(launch.stdout) assert launchPlan["resource_mutations_issued"] is False - assert launchPlan["command"][-len(arguments) - 4:] == [str(directory / "operator.py"), *arguments, + assert launchPlan["command"][-len(arguments) - 4:] == [str(directory / "native_operator.py"), *arguments, "--issuer-token", launchPlan["invocation_token"], "--execute"] - result: subprocess.CompletedProcess[str] = subprocess.run([sys.executable, str(directory / "operator.py"), *arguments], + result: subprocess.CompletedProcess[str] = subprocess.run([sys.executable, str(directory / "native_operator.py"), *arguments], capture_output=True, text=True, check=False) assert result.returncode == 0, result.stderr assert json.loads(result.stdout)["operation"] == "seed-manifests" @@ -106,7 +106,7 @@ def test_manifest_seed_is_an_explicit_fenced_operator_command(tmp_path: Path) -> def test_manifest_seed_requires_receipt_from_the_admitted_epoch( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, receiptEpoch: int, ) -> None: - path: Path = Path(__file__).parents[1] / "operator.py" + path: Path = Path(__file__).parents[1] / "native_operator.py" monkeypatch.syspath_prepend(str(path.parent)) specification = importlib.util.spec_from_file_location("native_operator", path) assert specification is not None and specification.loader is not None diff --git a/deploy/opensearch/workload_snapshot.py b/deploy/opensearch/workload_snapshot.py index 5f62b76a8..1bba4bbb0 100644 --- a/deploy/opensearch/workload_snapshot.py +++ b/deploy/opensearch/workload_snapshot.py @@ -49,7 +49,7 @@ def _run(configuration: dict[str, object], request: dict[str, object], *, should def persist(value: dict[str, object]) -> None: _writeJson(journal, {**value, "binding": binding}, replace=journal.exists()) - specification = importlib.util.spec_from_file_location("knowhere_native_operator", Path(__file__).with_name("operator.py")) + specification = importlib.util.spec_from_file_location("knowhere_native_operator", Path(__file__).with_name("native_operator.py")) if specification is None or specification.loader is None: raise ValueError("Authoritative backup implementation is unavailable") module = importlib.util.module_from_spec(specification)