feat(cli): add -A/--all-namespaces to get - #308
Draft
rogirun wants to merge 5 commits into
Draft
Conversation
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>
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Last of a five-PR stack. Adds
-A/--all-namespacestokarta get, so a fleet-wide question resolves in one call rather than one per namespace.Composes with the existing filters. The NAMESPACE column added earlier in the stack is what makes the output readable here.
Two details:
-Ais a usage error, not a search. A name identifies one object in one namespace, which is how kubectl treats it.-Amakes 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-sizestill bounds per-request pressure, and the help text is explicit that it does not bound total time.Related issue(s)
Refs #205
Stack
getcommand-A/--all-namespacesChecklist
git commit -s)make check)