Skip to content

feat(cli): add -A/--all-namespaces to get - #308

Draft
rogirun wants to merge 5 commits into
mainfrom
feat/cli-get-all-namespaces
Draft

feat(cli): add -A/--all-namespaces to get#308
rogirun wants to merge 5 commits into
mainfrom
feat/cli-get-all-namespaces

Conversation

@rogirun

@rogirun rogirun commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Last of a five-PR stack. Adds -A/--all-namespaces to karta get, so a fleet-wide question resolves in one call rather than one per namespace.

$ karta get pytorchjob -A
NAME              NAMESPACE   PHASE       COMPONENTS               GPU   AGE
llama-finetune    ml-team     Running     master(1), worker(4)     33    2h
sweep-7           research    Degraded    master(1), worker(8)     64    30m

Composes with the existing filters. The NAMESPACE column added earlier in the stack is what makes the output readable here.

Two details:

  • A name plus -A is a usage error, not a search. A name identifies one object in one namespace, which is how kubectl treats it.
  • Ties now break on namespace before name. -A makes that load-bearing: the same workload name routinely appears in several namespaces, and without it the ordering is unstable between runs.

Deliberately no guard on breadth. --chunk-size still bounds per-request pressure, and the help text is explicit that it does not bound total time.

Related issue(s)

Refs #205

Stack

  1. feat(cli): give failures distinguishable exit codes #304 - exit codes
  2. feat(cli): add the resolved workload view #305 - resolved workload view
  3. feat(cli): render workload views as a table, json or yaml #306 - renderer
  4. feat(cli): add the get command for workloads #307 - the get command
  5. this PR - -A/--all-namespaces

Checklist

  • All commits are signed off with DCO (git commit -s)
  • New/modified files have SPDX license and copyright headers
  • Documentation updated (if applicable)
  • Tests pass (make check)
  • No proprietary or internal information included

Every error exited 1, so a script could not tell an unknown type from an
unreachable cluster. Add an error that carries an exit code, and map usage
failures (invalid flag value, bad arguments, unrecognised command) to a
distinct code.

Cobra reports an unrecognised subcommand only for a non-runnable command and
before validating args, so the root becomes runnable to keep that case inside
the contract. Silencing Cobra's own reporting also silences its usage hint, so
main prints both the hint and the lowercase "error:" prefix the rest of the
CLI's diagnostics use.

Signed-off-by: Roee Gil <roee.gil@run.ai>
Turn a workload object into the view the CLI renders: identity, normalized
phase, the semantic component breakdown, and aggregate requested GPUs, read
through the Karta definition that covers its type. Resolution is spec-only, so
a consumer pays one list per kind and no pod reads.

The catalog forces several rules that are easy to get wrong, each covered by a
test against a real definition: the root carries the pod template for
Deployment and friends, which tree.Build omits; a component the workload does
not use still extracts a zero-valued spec, so emptiness is tested by value; a
component declaring only a minimum falls back to it; spec shapes are mutually
exclusive so a definition naming both a container and a resources path counts
GPUs once; child replicas are already absolute, so a cloned subtree is walked
once; and the GPU total follows the effective pod request Kubernetes schedules
against.

Signed-off-by: Roee Gil <roee.gil@run.ai>
Render a set of workload views in the format the -o flag selects. The table
uses the standard kubectl tab writer and elides a long COMPONENTS cell so the
later columns stay aligned; wide adds the origin of the resolving definition.

Machine output is always an array, including for a single workload, so a
consumer never branches on shape. The empty-result notice goes to stderr and is
suppressed entirely for json and yaml, so piping into jq does not choke on
empty input.

Signed-off-by: Roee Gil <roee.gil@run.ai>
karta get lists workloads of a type as one row per workload root, with a
normalized phase, the semantic component breakdown and aggregate requested
GPUs, all read through the Karta definition that covers the type.

Type matching follows kubectl: the RESTMapper resolves short names, plurals and
group-qualified forms against what the cluster serves, falling back to an exact
kind match so a type still resolves when its CRD is absent. A token several
definitions claim reports the qualified forms to retry with, or names the
colliding definitions when their root GVKs are identical.

Filters compose with AND semantics; the label selector goes server side while
the phase filter runs on the resolved view, which is what makes it work across
workload types. Listing follows continuation tokens so large result sets stay
bounded in memory.

This replaces the noun-first karta workload stub, which the verb-first grammar
supersedes.

Refs #205

Signed-off-by: Roee Gil <roee.gil@run.ai>
List workloads across every namespace, which composes with the existing filters
and is what makes get useful for a fleet-wide question rather than one team.

A name identifies one object in one namespace, so combining it with -A is a
usage error rather than a search, matching kubectl. Ties in the ordering now
break on namespace before name, which -A makes load-bearing: the same workload
name can appear in several namespaces.

Refs #205

Signed-off-by: Roee Gil <roee.gil@run.ai>
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.

1 participant