Skip to content

Cluster health monitor consumes the CVS cluster file#163

Merged
speriaswamy-amd merged 3 commits into
mainfrom
surya/aimvt-174-cluster-health-cluster-file
May 19, 2026
Merged

Cluster health monitor consumes the CVS cluster file#163
speriaswamy-amd merged 3 commits into
mainfrom
surya/aimvt-174-cluster-health-cluster-file

Conversation

@speriaswamy-amd

Copy link
Copy Markdown
Contributor

Summary

The check_cluster_health monitor previously required an undocumented one-IP-per-line --hosts_file plus separate --username and --password/--key_file flags, which forced users to maintain a second source of truth alongside the cluster file already used by cvs run and cvs exec.

This PR makes the monitor a first-class consumer of the existing cluster JSON:

  • New --cluster_file <path> (recommended) — reads node_dict keys as the host list and username/priv_key_file as the SSH credentials, with {user-id} placeholders resolved via the existing utils_lib.resolve_cluster_config_placeholders helper. No new schema, same file cvs run/cvs exec already use.
  • Argparse mutually-exclusive group enforces "exactly one of --cluster_file or --hosts_file"; passing credential flags alongside --cluster_file is rejected.
  • --hosts_file kept as a deprecated fallback with a runtime WARNING, plus support for # comments and blank lines so existing host files keep working.
  • Refactor extracts load_cluster_file() and CheckClusterHealthMonitor._resolve_connection() so all argument-resolution logic is unit-testable in isolation; monitor() stays linear.
  • Docs: cvs/monitors/README.md and docs/how-to/run-cluster.rst updated to lead with --cluster_file and mark the legacy flags as deprecated.
  • Unit tests (cvs/monitors/unittests/test_check_cluster_health.py, 19 cases) cover the loader (happy path, {user-id} resolution, missing file, bad JSON, missing/empty fields), the argparse contract (cluster-only, hosts-only, both, neither), and _resolve_connection (credential rules for both code paths, comment/blank-line stripping).

Test plan

  • python3 -m unittest cvs.monitors.unittests.test_check_cluster_health — 19/19 pass
  • ruff check and ruff format --check clean on changed files
  • End-to-end run on a 4-node cluster (cvs monitor check_cluster_health --cluster_file cluster.json --iterations 2): authenticated against all nodes, completed both iterations, generated the expected 25-section HTML report, and correctly surfaced real amdgpu runlist warnings from one node's dmesg
  • Backward compatibility: legacy --hosts_file invocation still works and prints the deprecation warning

Made with Cursor

@speriaswamy-amd speriaswamy-amd changed the title AIMVT-174: cluster health monitor consumes the CVS cluster file Cluster health monitor consumes the CVS cluster file May 12, 2026
@speriaswamy-amd speriaswamy-amd requested a review from cijohnson May 12, 2026 20:03
speriaswamy-amd and others added 2 commits May 12, 2026 17:04
… exec/scp

Mirror the cluster-file resolution used by cvs exec and cvs scp so users
can `export CLUSTER_FILE=...` once and run any CVS command (exec, scp,
monitor) without repeating --cluster_file. Env var takes precedence over
the flag, matching the existing plugins.

- Drop argparse-level "exactly one source" requirement so the env var can
  satisfy --cluster_file; enforce the rule at runtime in
  _resolve_connection along with explicit rejection of CLUSTER_FILE +
  --hosts_file mixing.
- Update --cluster_file help, README, and run-cluster.rst to document the
  CLUSTER_FILE fallback and show the export-once usage pattern.
- Add 4 new unit tests (env supplies path, env wins over flag, env +
  --hosts_file aborts, no source aborts) and make TestResolveConnection
  hermetic by clearing CLUSTER_FILE in setUp. 23/23 pass.

Co-authored-by: Cursor <cursoragent@cursor.com>
… cluster commands

Per-review: an explicit --cluster_file should always take precedence over
the CLUSTER_FILE env var. The previous code (in cvs exec, cvs scp, and
the new check_cluster_health) had it inverted - env beat the flag - which
violates standard Unix tooling expectations and is surprising when a user
runs a one-off invocation against a different cluster after exporting
CLUSTER_FILE for the common case.

Flipped resolution order in all three places to:
    cluster_file = args.cluster_file or os.environ.get('CLUSTER_FILE')

so the env var becomes the fallback. Updated --cluster_file help text,
epilogs, README, and run-cluster.rst to describe the env var as a
fallback. The unit test that pinned the old precedence is renamed to
test_cluster_file_flag_takes_precedence_over_env_var and asserts the new
direction. 23/23 monitor tests + 23/23 cli_plugins tests pass; ruff
clean. Smoke-tested all three commands end-to-end with a wrong env path
and a real flag path - flag wins in every case.

Co-authored-by: Cursor <cursoragent@cursor.com>
@speriaswamy-amd speriaswamy-amd merged commit baa9877 into main May 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants