|
| 1 | +# Job Identifiers |
| 2 | + |
| 3 | +## Terminology |
| 4 | + |
| 5 | +In order to understand how jobq identifies jobs, it is important to understand the conceptual components of a workload: |
| 6 | +A jobs is composed of an abstract definition of the workload (as a [Kueue `Workload`](https://kueue.sigs.k8s.io/docs/concepts/workload/) custom resource) and a set of Kubernetes resources (for example a Kubernetes `Job`, or a custom resource like the [Kuberay](https://docs.ray.io/en/latest/cluster/kubernetes/index.html) `RayJob`) that make up the executable part of the workload. |
| 7 | + |
| 8 | +At first these similar-sounding names can be confusing, so let's establish some terminology: |
| 9 | + |
| 10 | +- A **workload** or **job** (lowercase "w"/"j") is a set of Kubernetes resources that make up the |
| 11 | + executable portion of a job. |
| 12 | +- A **Workload** (uppercase "W") refers to the Kueue `Workload` custom resource. |
| 13 | +- A **Job** (uppercase "J") refers to the Kubernetes `batch/v1/Job` resource (one way how code can be submitted through jobq). |
| 14 | + |
| 15 | +Kueue handles the `Workload` and updates its status to reflect the current state of the workload. |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +## Identifying workloads |
| 20 | + |
| 21 | +Every Workload (as managed by Kueue) carries by an automatically generated unique identifier (UID) as well as a human-readable name and namespace. |
| 22 | +Both these could serve as a unique identifier for a Workload. However, a name/namespace combination is not guaranteed to be unique over time (for example when deleting and recreating), whereas UIDs are. |
| 23 | +This makes UIDs a slightly better choice for identifying a given Workload resource. |
| 24 | + |
| 25 | +The concrete workload resource has the same identifiers, a UID and name/namespace combination. |
| 26 | + |
| 27 | +A given job references its associated Workload in a 1:1 fashion (through its `metadata.ownerReferences` field). |
| 28 | + |
| 29 | +This theoretically allows to identify a job in the cluster through two different identifiers: |
| 30 | + |
| 31 | +- the UID of the (concrete) _job_ resource. |
| 32 | +- the UID of the (abstract) _Workload_ resource. |
| 33 | + |
| 34 | +In practice, jobq always uses the **UID of the concrete workload** as the identifier for a job. |
| 35 | +All CLI operations return and accept the UID of the concrete workload. |
| 36 | + |
| 37 | +As an example, imagine the following resources in the cluster after submitting a job: |
| 38 | + |
| 39 | +```mermaid |
| 40 | +graph LR |
| 41 | +subgraph "Namespace example" |
| 42 | +direction LR |
| 43 | + A["`Workload **job-example** <pre>uid-1</pre>`"] --> B["`Job **example** <pre>uid-2</pre>`"] --> C[Pod] |
| 44 | +end |
| 45 | +``` |
| 46 | + |
| 47 | +If we want to query the logs of the job, we can do so by calling `jobq logs` with the UID of the concrete workload: |
| 48 | + |
| 49 | +```console |
| 50 | +$ jobq logs uid-2 |
| 51 | +[... log output ...] |
| 52 | +``` |
0 commit comments