|
| 1 | +// SPDX-FileCopyrightText: Copyright (C) SchedMD LLC. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package v1beta1 |
| 5 | + |
| 6 | +import ( |
| 7 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 8 | + "k8s.io/apimachinery/pkg/runtime" |
| 9 | +) |
| 10 | + |
| 11 | +const ( |
| 12 | + SlurmQosKind = "SlurmQos" |
| 13 | +) |
| 14 | + |
| 15 | +var ( |
| 16 | + SlurmQosGVK = GroupVersion.WithKind(SlurmQosKind) |
| 17 | + SlurmQosAPIVersion = GroupVersion.String() |
| 18 | +) |
| 19 | + |
| 20 | +// SlurmQosSpec defines the desired state of SlurmQos |
| 21 | +type SlurmQosSpec struct { |
| 22 | + // controllerRef is a reference to the Controller CR to which this has membership. |
| 23 | + // The referenced Controller must have accountingRef set (QOS requires accounting). |
| 24 | + // +required |
| 25 | + ControllerRef ObjectReference `json:"controllerRef"` |
| 26 | + |
| 27 | + // description is a human-readable description of the QOS. |
| 28 | + // +optional |
| 29 | + Description string `json:"description,omitempty"` |
| 30 | + |
| 31 | + // config is the raw QOS configuration passed to the Slurm REST API. |
| 32 | + // Keys map to V0044Qos JSON fields: priority, flags, limits, preempt, |
| 33 | + // usage_factor, usage_threshold, etc. |
| 34 | + // Ref: https://slurm.schedmd.com/rest_api.html |
| 35 | + // +optional |
| 36 | + // +kubebuilder:pruning:PreserveUnknownFields |
| 37 | + Config *runtime.RawExtension `json:"config,omitempty"` |
| 38 | +} |
| 39 | + |
| 40 | +// SlurmQosStatus defines the observed state of SlurmQos |
| 41 | +type SlurmQosStatus struct { |
| 42 | + // ready indicates whether the QOS exists and is synced in Slurm. |
| 43 | + // +optional |
| 44 | + Ready bool `json:"ready,omitempty"` |
| 45 | + |
| 46 | + // id is the Slurm-assigned QOS ID. |
| 47 | + // +optional |
| 48 | + ID *int32 `json:"id,omitempty"` |
| 49 | + |
| 50 | + // Represents the latest available observations of a SlurmQos's current state. |
| 51 | + // +optional |
| 52 | + // +patchMergeKey=type |
| 53 | + // +patchStrategy=merge |
| 54 | + // +listType=map |
| 55 | + // +listMapKey=type |
| 56 | + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` |
| 57 | +} |
| 58 | + |
| 59 | +// +kubebuilder:object:root=true |
| 60 | +// +kubebuilder:subresource:status |
| 61 | +// +kubebuilder:resource:shortName=slurmqos |
| 62 | +// +kubebuilder:printcolumn:name="READY",type="boolean",JSONPath=".status.ready",priority=0,description="Whether the QOS is synced in Slurm." |
| 63 | +// +kubebuilder:printcolumn:name="DESCRIPTION",type="string",JSONPath=".spec.description",priority=1,description="QOS description." |
| 64 | +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" |
| 65 | + |
| 66 | +// SlurmQos is the Schema for the slurmqos API |
| 67 | +type SlurmQos struct { |
| 68 | + metav1.TypeMeta `json:",inline"` |
| 69 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 70 | + |
| 71 | + Spec SlurmQosSpec `json:"spec,omitempty"` |
| 72 | + Status SlurmQosStatus `json:"status,omitempty"` |
| 73 | +} |
| 74 | + |
| 75 | +// +kubebuilder:object:root=true |
| 76 | + |
| 77 | +// SlurmQosList contains a list of SlurmQos |
| 78 | +type SlurmQosList struct { |
| 79 | + metav1.TypeMeta `json:",inline"` |
| 80 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 81 | + Items []SlurmQos `json:"items"` |
| 82 | +} |
| 83 | + |
| 84 | +func init() { |
| 85 | + SchemeBuilder.Register(&SlurmQos{}, &SlurmQosList{}) |
| 86 | +} |
0 commit comments