Skip to content

Commit 09c0afa

Browse files
feat: add SlurmQos CRD for declarative QOS management
1 parent a1f1c4d commit 09c0afa

19 files changed

Lines changed: 1448 additions & 1 deletion

File tree

api/v1beta1/slurmqos_types.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
}

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 108 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/manager/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/SlinkyProject/slurm-operator/internal/controller/nodeset"
3333
"github.com/SlinkyProject/slurm-operator/internal/controller/restapi"
3434
"github.com/SlinkyProject/slurm-operator/internal/controller/slurmclient"
35+
"github.com/SlinkyProject/slurm-operator/internal/controller/slurmqos"
3536
"github.com/SlinkyProject/slurm-operator/internal/controller/token"
3637
// +kubebuilder:scaffold:imports
3738
)
@@ -178,6 +179,10 @@ func main() {
178179
setupLog.Error(err, "unable to create controller", "controller", "SlurmClient")
179180
os.Exit(1)
180181
}
182+
if err := slurmqos.NewReconciler(mgr.GetClient(), clientMap).SetupWithManager(mgr); err != nil {
183+
setupLog.Error(err, "unable to create controller", "controller", "SlurmQos")
184+
os.Exit(1)
185+
}
181186
if err := token.NewReconciler(mgr.GetClient()).SetupWithManager(mgr); err != nil {
182187
setupLog.Error(err, "unable to create controller", "controller", "Token")
183188
os.Exit(1)

cmd/webhook/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ func main() {
204204
setupLog.Error(err, "unable to create webhook", "webhook", "Token")
205205
os.Exit(1)
206206
}
207+
if err = (&slinkywebhook.SlurmQosWebhook{
208+
Client: mgr.GetClient(),
209+
}).SetupWebhookWithManager(mgr); err != nil {
210+
setupLog.Error(err, "unable to create webhook", "webhook", "SlurmQos")
211+
os.Exit(1)
212+
}
207213
if err = (&slinkywebhook.PodBindingWebhook{
208214
Client: mgr.GetClient(),
209215
}).SetupWebhookWithManager(mgr); err != nil {

0 commit comments

Comments
 (0)