feat(deploy,xceadmin): standalone xceadmin packaging + deploy-ha usability (bug-1566)

Three related enhancements to make /xce-deploy-ha's output a
self-contained, directly-usable cluster for manual testing:

- xceadmin now builds an installable wheel (meson-build.sh) with
  correct dependencies (click/pycapnp/PyYAML/jsonschema, verified
  against actual imports -- pyproject.toml was missing several).
- deploy-ha.sh resolves the deploy environment's own bash
  ($BASH_BIN, baked into every generated script's shebang -- this
  environment's deploy-ha.sh had drifted to #!/bin/sh while still
  using bash-only syntax) and generates scripts/start-worker.sh /
  scripts/start-scheduler.sh sharing the controllers' --peers, plus
  a standalone xceadmin install (wheel extracted directly, resolved
  $PYTHONPATH baked into a wrapper script -- nix devShell packages
  are $PYTHONPATH entries, not merged into python3's own
  site-packages, so a --system-site-packages venv can't see them).
- bug-1566: xceadmin's --controller option had no relationship to a
  deployment's actual peers (hardcoded localhost:9991 default) --
  every command required an explicit --controller or silently tried
  the wrong port. Fixed via a $XCEADMIN_CONTROLLER envvar fallback
  (click precedence: explicit flag > envvar > bare default),
  exported by deploy-ha.sh's generated scripts/xceadmin wrapper.

Fixed/validated via TDD + live reproduction against a real deployed
cluster in a fully stripped environment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-17 10:20:52 +00:00
parent 1c943e98fe
commit 0f1df4998e
Signed by: rshen
SSH key fingerprint: SHA256:8Vf2pZ3h6rJa7EhGK+WaAQ9Mta/apZvteW6g9U/WKKk
5 changed files with 266 additions and 12 deletions

View file

@ -498,6 +498,55 @@ def test_scheduler_record_start_passes_filename_and_controller_arguments(monkeyp
assert captured["filename"] == "myfile.replay"
# ---------------------------------------------------------------------------
# --controller falls back to $XCEADMIN_CONTROLLER, not the hardcoded
# _DEFAULT_CONTROLLER, when the env var is set (a deployment whose cluster
# doesn't happen to use localhost:9991 -- e.g. /xce-deploy-ha's
# scripts/xceadmin wrapper exports this to the actual first --peers
# candidate -- must not silently point at the wrong port). Explicit
# --controller on the command line still wins over the env var (click's
# built-in precedence: CLI flag > envvar > default).
# ---------------------------------------------------------------------------
def test_controller_option_falls_back_to_xceadmin_controller_env_var(monkeypatch) -> None:
captured = {}
def _fake_record_status(controller):
captured["controller"] = controller
return RecordResult(recording=False, file="", event_count=0, started_at=0)
monkeypatch.setattr(cli_module, "record_status", _fake_record_status)
runner = CliRunner()
result = runner.invoke(
cli, ["scheduler", "record", "status"], env={"XCEADMIN_CONTROLLER": "localhost:9901"}
)
assert result.exit_code == 0, result.output
assert captured["controller"] == "localhost:9901"
def test_controller_flag_overrides_xceadmin_controller_env_var(monkeypatch) -> None:
captured = {}
def _fake_record_status(controller):
captured["controller"] = controller
return RecordResult(recording=False, file="", event_count=0, started_at=0)
monkeypatch.setattr(cli_module, "record_status", _fake_record_status)
runner = CliRunner()
result = runner.invoke(
cli,
["scheduler", "record", "status", "--controller", "127.0.0.1:9999"],
env={"XCEADMIN_CONTROLLER": "localhost:9901"},
)
assert result.exit_code == 0, result.output
assert captured["controller"] == "127.0.0.1:9999"
def test_scheduler_record_stop_success_prints_formatted_result(monkeypatch) -> None:
def _fake_record_stop(controller):
return RecordResult(recording=False, file="final.replay", event_count=14273, started_at=1000)