[VPEX][10] Add --cluster-name target flag#5961
Conversation
Per the [P0] CLI Changes spec, add --cluster-name as a compute target: it resolves the cluster name to an ID via the Clusters API and then behaves identically to --cluster-id (source=cluster, env key from the resolved cluster's spark_version). - ComputeClient gains GetClusterByName; sdkCompute implements it via the SDK's Clusters.GetByClusterName, which errors on an unknown or ambiguous name (two clusters sharing it) — surfaced as an actionable E_RESOLVE. - --cluster-name joins the mutually-exclusive target group and the bundle-fallback guard. - Unit tests for success, ambiguity, and cluster-id/-name exclusivity; acceptance tests cluster-name-check (happy path) and cluster-name-ambiguous (E_RESOLVE), plus the help golden. Co-authored-by: Isaac
--cluster-name target flag--cluster-name target flag
Integration test reportCommit: 08c5535
8 interesting tests: 4 RECOVERED, 4 SKIP
Top 10 slowest tests (at least 2 minutes):
|
…--cluster-name in no-target guidance Review of #5961 (isaac major + codex P3): - GetClusterByName no longer uses the SDK's GetByClusterName, which lists clusters in every state and errors on any name collision — a terminated cluster sharing a name with a live one would spuriously block resolution. List only non-terminated clusters (ListClustersFilterBy) and match by name; a name still ambiguous among active clusters, or matching none, is a genuine E_RESOLVE. - noTargetMessage now includes --cluster-name so the no-target guidance lists every valid target flag. - Acceptance: cluster-name-ambiguous now models two RUNNING clusters (genuine ambiguity) with the clearer error; no-target and json-error goldens updated. Co-authored-by: Isaac
anton-107
left a comment
There was a problem hiding this comment.
Reviewed as part of the full stack (#5960–#5965). The --cluster-name path resolves correctly (name→ID→env key, source=cluster), and it joins both the Cobra exclusion group and the library-path ValidateTargetFlags/bundle-fallback guards. Approving.
Findings to consider (none blocking):
-
[low] Error leaks an internal Go type name to end users. The ambiguous/unknown-name errors surface the raw SDK message verbatim, e.g.
there are 2 instances of ClusterDetails named 'dup'(see goldenacceptance/localenv/cluster-name-ambiguous/output.txt:2).ClusterDetailsis an SDK struct name; a user-facing CLI shouldn't expose it. Consider rewrapping, e.g. "2 clusters are named 'dup'; pass --cluster-id to disambiguate". -
[low]
GetByClusterNameloads all clusters and misses long-terminated ones. The SDK'sClusters.GetByClusterNamecallsListAll(paginates every cluster into memory), and the backing List API omits clusters terminated >30 days — so a valid-but-long-terminated cluster name yields "does not exist". This is inherent to name resolution (there's no get-by-name endpoint; names aren't unique), so impact is low, but a one-line comment onGetClusterByNamenoting the >30-day caveat would help the next reader. -
[low] Test coverage: only the ambiguous path is exercised.
TestResolveClusterNameFlagErrorand the acceptance dir cover the ambiguous error; the unknown-name branch (ClusterDetails named 'X' does not exist) has no unit or acceptance case, though the description says both failure modes are covered. Worth one more case since the two share a single wrapping branch. -
[nit] Stale precedence comment.
ResolveTarget's doc comment (libs/localenv/target.go:64) still lists precedence as--cluster-id → --serverless-version → --job-id → bundle, omitting the--cluster-namebranch this PR inserts between cluster-id and serverless. Harmless to correctness (flags are mutually exclusive) but misleads a reader. (#5964 updated the siblingTargetInfodoc for "five flag sources" but left this one.)
Reviewed with AI assistance (build + unit tests + adversarial verification against the checked-out top of stack).
Stacked on #5960 (flag renames), which is stacked on #5959 (command rename).
What
Adds
--cluster-nameas a compute target forenvironments setup-local, per the[P0] CLI Changesspec. It resolves the cluster name to an ID via the Clusters API, then resolves identically to--cluster-id(source=cluster, env key from the resolved cluster'sspark_version).Changes
ComputeClientgainsGetClusterByName;sdkComputeimplements it via the SDK'sClusters.GetByClusterName, which errors on an unknown or ambiguous name (two clusters sharing it) — both surfaced as an actionableE_RESOLVE.--cluster-namejoins the mutually-exclusive target group (--cluster-id/--cluster-name/--serverless-version/--job-id) and the bundle-fallback guard.ResolveTargetprecedence branch after--cluster-id.Testing
E_RESOLVE, and--cluster-id/--cluster-namemutual exclusivity.cluster-name-check(happy path, stubbedclusters/list) andcluster-name-ambiguous(E_RESOLVE); help golden updated.go build ./..., lint (0 issues), deadcode clean, unit + acceptance green.This pull request and its description were written by Isaac.