Skip to content

feat(cli): kli usability improvements (completion, warnings, component limit, GVK output) #411

Closed

Description

@rogirun

What you would like to be added?

Five usability changes to kli:

  1. Shell completion for workload types and names.
    get and describe (cli/cmd/get.go, cli/cmd/describe.go) have no
    ValidArgsFunction. Only the -o and --phase flags complete today
    (cli/cmd/flags.go). Complete the TYPE argument from the known Karta definitions,
    and complete NAME (in both the TYPE NAME and TYPE/NAME forms) from the
    workloads of that type in the current namespace.

  2. Print warnings after the command output.
    get, describe, and definitions call printWarnings (cli/cmd/warnings.go)
    before they render, so warning: lines show up above the table or tree and are
    easy to miss. Print them after the output. They stay on stderr.

  3. Add a component limit to kli describe.
    Add a --component-limit <n> flag that caps the components shown under each
    parent in the describe tree, and print a "N more" note when some are hidden.
    The default is 0, which shows every component, as --pod-limit does. Keep
    unhealthy components first when some are hidden. Follow the existing
    --pod-limit handling (cli/cmd/describe.go, cli/pkg/generator/describe.go):
    reject negative values with a usage error.

  4. Print a plain GVK in kli validate output.
    The success line is
    OK: <file> is a valid Karta definition (maps kubeflow.org/v1, Kind=PyTorchJob).
    This is the apimachinery schema.GroupVersionKind.String() format
    (cli/cmd/validate.go, and definitionFilter.String in cli/cmd/definitions.go).
    Print group/version/Kind instead, for example kubeflow.org/v1/PyTorchJob, and use
    the same format wherever the CLI prints a GVK. In the validate line, label it
    GVK: instead of maps.

  5. Limit the components listed by kli definitions, with the same flag.
    The COMPONENTS column (cli/cmd/definitions.go) lists every component, so a
    definition such as Milvus, with 18 child components, produces a very long row.
    List the root and at most 3 child components, then +N more. The root only
    repeats the kind, so it does not count toward the limit. --component-limit <n>
    changes the cap, 0 lists every component, and a negative value is a usage error.
    json and yaml output keep the full definitions.

Why is this needed?

  • Completion saves typing long workload names and CRD types, and catches typos
    before a request goes to the cluster.
  • A warning printed above a long table or tree scrolls out of view. Printed last,
    it is the first thing the user sees.
  • Workloads with many components produce a long describe tree. The flag lets the
    user cap it, while the default still shows every component.
  • maps kubeflow.org/v1, Kind=PyTorchJob reads like an internal Go format. A single
    GVK token is shorter and easier to copy.
  • One definition with many components widens the whole kli definitions table.
    Capping the column keeps every row on one line.

Examples

Warnings after the output

kli get jobset, before:

warning: the Karta CRD is not installed in this cluster; showing catalog definitions only
NAME         NAMESPACE   PHASE     AGE
preprocess   ml-team     Running   2h
train        ml-team     Running   5m

After:

NAME         NAMESPACE   PHASE     AGE
preprocess   ml-team     Running   2h
train        ml-team     Running   5m
warning: the Karta CRD is not installed in this cluster; showing catalog definitions only

When the command fails, the error stays the last line:

warning: the Karta CRD is not installed in this cluster; showing catalog definitions only
error: no Karta definition covers "flinkdeployment"

Component limit

kli describe jobset/llama-train --component-limit 3 on a JobSet with 6 shards, where shard-4 is unschedulable. The unhealthy component keeps its row:

`-- llama-train         5/6 ready                 gpu: 48
    |-- shard-0         1/1 ready                 gpu: 8
    |   `-- shard-0-0   Running                             node-00
    |-- shard-1         1/1 ready                 gpu: 8
    |   `-- shard-1-0   Running                             node-01
    |-- shard-4         0/1 ready                 gpu: 8
    |   `-- shard-4-0   Pending (Unschedulable)             <none>
    `-- ...             and 3 more components

kli describe jobset/llama-train shows every component by default, the same as --component-limit 0:

`-- llama-train         5/6 ready                 gpu: 48
    |-- shard-0         1/1 ready                 gpu: 8
    |   `-- shard-0-0   Running                             node-00
    |-- shard-1         1/1 ready                 gpu: 8
    |   `-- shard-1-0   Running                             node-01
    |-- shard-2         1/1 ready                 gpu: 8
    |   `-- shard-2-0   Running                             node-02
    |-- shard-3         1/1 ready                 gpu: 8
    |   `-- shard-3-0   Running                             node-03
    |-- shard-4         0/1 ready                 gpu: 8
    |   `-- shard-4-0   Pending (Unschedulable)             <none>
    `-- shard-5         1/1 ready                 gpu: 8
        `-- shard-5-0   Running                             node-05

The Resources table keeps every component in both cases, so its rows still sum to TOTAL.

GVK in kli validate

Before:

OK: my-karta.yaml is a valid Karta definition (maps kubeflow.org/v1, Kind=PyTorchJob)

After:

OK: my-karta.yaml is a valid Karta definition (GVK: kubeflow.org/v1/PyTorchJob)

Component limit in kli definitions

kli definitions, before:

NAME                                         KIND             ORIGIN   COMPONENTS
kubeflow-org-pytorchjob-v1                   PyTorchJob       catalog  pytorchjob, master, worker
leaderworkerset-x-k8s-io-leaderworkerset-v1  LeaderWorkerSet  catalog  leaderworkerset, group, leader, worker
milvus-io-milvus-v1beta1                     Milvus           catalog  milvus, standalone, proxy, mixcoord, datanode, querynode, streamingnode, indexnode, rootcoord, datacoord, querycoord, indexcoord, cdc, etcd, minio, pulsar-zookeeper, pulsar-bookkeeper, pulsar-broker, pulsar-proxy

After:

NAME                                         KIND             ORIGIN   COMPONENTS
kubeflow-org-pytorchjob-v1                   PyTorchJob       catalog  pytorchjob, master, worker
leaderworkerset-x-k8s-io-leaderworkerset-v1  LeaderWorkerSet  catalog  leaderworkerset, group, leader, worker
milvus-io-milvus-v1beta1                     Milvus           catalog  milvus, standalone, proxy, mixcoord, +15 more

kli definitions --component-limit 0 prints the full list, as before.

Metadata

Metadata

Assignees

Labels

enhancement

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions