Skip to content

Commit cb2862d

Browse files
Merge branch 'skyler/slurm-v44' into 'main'
Use Slurm v44 API Closes #123 See merge request SchedMD/slinky-dev/slurm-operator!240
2 parents 5102a97 + afe628f commit cb2862d

File tree

14 files changed

+525
-524
lines changed

14 files changed

+525
-524
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.25.0
55
toolchain go1.25.3
66

77
require (
8-
github.com/SlinkyProject/slurm-client v0.4.1-20251006172405-5f88a047678e
8+
github.com/SlinkyProject/slurm-client v0.4.0-20250912114233-d75113f34f05.0.20251105180332-9c4dc495e409
99
github.com/golang-jwt/jwt/v5 v5.3.0
1010
github.com/google/go-cmp v0.7.0
1111
github.com/onsi/ginkgo/v2 v2.23.4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lpr
1111
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1212
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
1313
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
14-
github.com/SlinkyProject/slurm-client v0.4.1-20251006172405-5f88a047678e h1:sKyP9OsqZrgIm/9X5xGn3Fuxxgf+G/stLIaH9+4Xj6c=
15-
github.com/SlinkyProject/slurm-client v0.4.1-20251006172405-5f88a047678e/go.mod h1:LAQssuaFj9hLjSKoICTZUYVCzkjXUcB5m50JmloutAc=
14+
github.com/SlinkyProject/slurm-client v0.4.0-20250912114233-d75113f34f05.0.20251105180332-9c4dc495e409 h1:2YcGKsGfmL2vM4EMHY/QPBnOK97S5vqWdilip5S5ujE=
15+
github.com/SlinkyProject/slurm-client v0.4.0-20250912114233-d75113f34f05.0.20251105180332-9c4dc495e409/go.mod h1:DnzthV/igby0Rx6xzDwhH+bX//BCXQPHSnjIGhnbS5U=
1616
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
1717
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
1818
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=

internal/controller/accounting/accounting_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ var _ = Describe("Accounting controller", func() {
4949
accountingKey := client.ObjectKeyFromObject(accounting)
5050
Eventually(func(g Gomega) {
5151
g.Expect(k8sClient.Get(ctx, accountingKey, createdAccounting)).To(Succeed())
52-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
52+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
5353

5454
By("Expecting Accounting CR Service")
5555
serviceKey := accounting.ServiceKey()
5656
service := &corev1.Service{}
5757
Eventually(func(g Gomega) {
5858
g.Expect(k8sClient.Get(ctx, serviceKey, service)).To(Succeed())
59-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
59+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
6060

6161
By("Expecting Accounting CR Statefulset")
6262
statefulsetKey := accounting.Key()
6363
statefulset := &appsv1.StatefulSet{}
6464
Eventually(func(g Gomega) {
6565
g.Expect(k8sClient.Get(ctx, statefulsetKey, statefulset)).To(Succeed())
66-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
66+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
6767
}, SpecTimeout(testutils.Timeout))
6868
})
6969
})

internal/controller/controller/controller_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ var _ = Describe("Slurm Controller", func() {
4545
controllerKey := client.ObjectKeyFromObject(controller)
4646
Eventually(func(g Gomega) {
4747
g.Expect(k8sClient.Get(ctx, controllerKey, createdController)).To(Succeed())
48-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
48+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
4949

5050
By("Expecting Controller CR service")
5151
serviceKey := controller.ServiceKey()
5252
service := &corev1.Service{}
5353
Eventually(func(g Gomega) {
5454
g.Expect(k8sClient.Get(ctx, serviceKey, service)).To(Succeed())
55-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
55+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
5656

5757
By("Expecting Controller CR statefulset")
5858
statefulsetKey := controller.Key()
5959
statefulset := &appsv1.StatefulSet{}
6060
Eventually(func(g Gomega) {
6161
g.Expect(k8sClient.Get(ctx, statefulsetKey, statefulset)).To(Succeed())
62-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
62+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
6363
}, SpecTimeout(testutils.Timeout))
6464
})
6565
})

internal/controller/loginset/loginset_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ var _ = Describe("LoginSet Controller", func() {
5454
loginsetKey := client.ObjectKeyFromObject(controller)
5555
Eventually(func(g Gomega) {
5656
g.Expect(k8sClient.Get(ctx, loginsetKey, createdLoginset)).To(Succeed())
57-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
57+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
5858

5959
By("Creating LoginSet CR Service")
6060
serviceKey := loginset.ServiceKey()
6161
service := &corev1.Service{}
6262
Eventually(func(g Gomega) {
6363
g.Expect(k8sClient.Get(ctx, serviceKey, service)).To(Succeed())
64-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
64+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
6565

6666
By("Creating LoginSet CR Deployment")
6767
deploymentKey := loginset.Key()
6868
deployment := &appsv1.Deployment{}
6969
Eventually(func(g Gomega) {
7070
g.Expect(k8sClient.Get(ctx, deploymentKey, deployment)).To(Succeed())
71-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
71+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
7272
}, SpecTimeout(testutils.Timeout))
7373
})
7474
})

internal/controller/nodeset/eventhandler/eventhandler_pod.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ func (e *PodEventHandler) getPodNodeSets(ctx context.Context, pod *corev1.Pod) [
333333
// SetEventHandler is a helper function to make slurm node updates propagate to
334334
// the nodeset controller via configured event channel.
335335
func SetEventHandler(client slurmclient.Client, eventCh chan event.GenericEvent) {
336-
informer := client.GetInformer(slurmtypes.ObjectTypeV0043Node)
336+
informer := client.GetInformer(slurmtypes.ObjectTypeV0044Node)
337337
informer.SetEventHandler(cache.ResourceEventHandlerFuncs{
338338
AddFunc: func(obj interface{}) {
339-
node, ok := obj.(*slurmtypes.V0043Node)
339+
node, ok := obj.(*slurmtypes.V0044Node)
340340
if !ok {
341341
return
342342
}
@@ -345,11 +345,11 @@ func SetEventHandler(client slurmclient.Client, eventCh chan event.GenericEvent)
345345
eventCh <- podEvent(podInfo)
346346
},
347347
UpdateFunc: func(oldObj, newObj interface{}) {
348-
oldNode, ok := oldObj.(*slurmtypes.V0043Node)
348+
oldNode, ok := oldObj.(*slurmtypes.V0044Node)
349349
if !ok {
350350
return
351351
}
352-
newNode, ok := newObj.(*slurmtypes.V0043Node)
352+
newNode, ok := newObj.(*slurmtypes.V0044Node)
353353
if !ok {
354354
return
355355
}
@@ -361,7 +361,7 @@ func SetEventHandler(client slurmclient.Client, eventCh chan event.GenericEvent)
361361
eventCh <- podEvent(podInfo)
362362
},
363363
DeleteFunc: func(obj interface{}) {
364-
node, ok := obj.(*slurmtypes.V0043Node)
364+
node, ok := obj.(*slurmtypes.V0044Node)
365365
if !ok {
366366
return
367367
}

internal/controller/nodeset/nodeset_controller_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"k8s.io/utils/set"
1616
k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
1717

18-
api "github.com/SlinkyProject/slurm-client/api/v0043"
18+
slurmapi "github.com/SlinkyProject/slurm-client/api/v0044"
1919
slurmclient "github.com/SlinkyProject/slurm-client/pkg/client"
2020
"github.com/SlinkyProject/slurm-client/pkg/client/fake"
2121
"github.com/SlinkyProject/slurm-client/pkg/client/interceptor"
@@ -30,19 +30,19 @@ import (
3030
func newFakeClientList(interceptorFuncs interceptor.Funcs, initObjLists ...object.ObjectList) slurmclient.Client {
3131
updateFn := func(_ context.Context, obj object.Object, req any, opts ...slurmclient.UpdateOption) error {
3232
switch o := obj.(type) {
33-
case *slurmtypes.V0043Node:
34-
r, ok := req.(api.V0043UpdateNodeMsg)
33+
case *slurmtypes.V0044Node:
34+
r, ok := req.(slurmapi.V0044UpdateNodeMsg)
3535
if !ok {
3636
return errors.New("failed to cast request object")
3737
}
38-
stateSet := set.New(ptr.Deref(o.State, []api.V0043NodeState{})...)
39-
statesReq := ptr.Deref(r.State, []api.V0043UpdateNodeMsgState{})
38+
stateSet := set.New(ptr.Deref(o.State, []slurmapi.V0044NodeState{})...)
39+
statesReq := ptr.Deref(r.State, []slurmapi.V0044UpdateNodeMsgState{})
4040
for _, stateReq := range statesReq {
4141
switch stateReq {
42-
case api.V0043UpdateNodeMsgStateUNDRAIN:
43-
stateSet.Delete(api.V0043NodeStateDRAIN)
42+
case slurmapi.V0044UpdateNodeMsgStateUNDRAIN:
43+
stateSet.Delete(slurmapi.V0044NodeStateDRAIN)
4444
default:
45-
stateSet.Insert(api.V0043NodeState(stateReq))
45+
stateSet.Insert(slurmapi.V0044NodeState(stateReq))
4646
}
4747
}
4848
o.State = ptr.To(stateSet.UnsortedList())
@@ -95,7 +95,7 @@ var _ = Describe("Slurm NodeSet", func() {
9595
nodesetKey := k8sclient.ObjectKeyFromObject(nodeset)
9696
Eventually(func(g Gomega) {
9797
g.Expect(k8sClient.Get(ctx, nodesetKey, createdNodeset)).To(Succeed())
98-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
98+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
9999

100100
By("Waiting for N replicas")
101101
podList := &corev1.PodList{}
@@ -106,7 +106,7 @@ var _ = Describe("Slurm NodeSet", func() {
106106
Eventually(func(g Gomega) {
107107
g.Expect(k8sClient.List(ctx, podList, optsList)).To(Succeed())
108108
g.Expect(len(podList.Items)).Should(Equal(replicas))
109-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
109+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
110110

111111
}, SpecTimeout(testutils.Timeout))
112112
})
@@ -151,7 +151,7 @@ var _ = Describe("Slurm NodeSet", func() {
151151
Eventually(func(g Gomega) {
152152
g.Expect(k8sClient.List(ctx, podList, optsList)).To(Succeed())
153153
g.Expect(len(podList.Items)).Should(Equal(replicas))
154-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
154+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
155155

156156
clientMap.Add(controllerKey, newFakeClientList(interceptor.Funcs{}))
157157

@@ -162,13 +162,13 @@ var _ = Describe("Slurm NodeSet", func() {
162162
g.Expect(k8sClient.Update(ctx, nodeset)).To(Succeed())
163163
replicas := int(ptr.Deref(nodeset.Spec.Replicas, 0))
164164
g.Expect(replicas).Should(Equal(0))
165-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
165+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
166166

167167
By("Verifying pods were deleted")
168168
Eventually(func(g Gomega) {
169169
g.Expect(k8sClient.List(ctx, podList, optsList)).To(Succeed())
170170
g.Expect(len(podList.Items)).Should(Equal(0))
171-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
171+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
172172
}, SpecTimeout(testutils.Timeout))
173173
})
174174

@@ -212,22 +212,22 @@ var _ = Describe("Slurm NodeSet", func() {
212212
Eventually(func(g Gomega) {
213213
g.Expect(k8sClient.List(ctx, podList, optsList)).To(Succeed())
214214
g.Expect(len(podList.Items)).Should(Equal(replicas))
215-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
215+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
216216

217217
By("Simulating Slurm functionality")
218-
slurmNodes := make([]slurmtypes.V0043Node, 0)
218+
slurmNodes := make([]slurmtypes.V0044Node, 0)
219219
for _, pod := range podList.Items {
220220
// Register Slurm node for pod
221-
node := slurmtypes.V0043Node{
222-
V0043Node: api.V0043Node{
221+
node := slurmtypes.V0044Node{
222+
V0044Node: slurmapi.V0044Node{
223223
Name: ptr.To(nodesetutils.GetNodeName(&pod)),
224-
State: ptr.To([]api.V0043NodeState{api.V0043NodeStateIDLE}),
224+
State: ptr.To([]slurmapi.V0044NodeState{slurmapi.V0044NodeStateIDLE}),
225225
},
226226
}
227227
slurmNodes = append(slurmNodes, node)
228228
}
229229
clientMap.Add(controllerKey,
230-
newFakeClientList(interceptor.Funcs{}, &slurmtypes.V0043NodeList{
230+
newFakeClientList(interceptor.Funcs{}, &slurmtypes.V0044NodeList{
231231
Items: slurmNodes,
232232
}),
233233
)
@@ -251,23 +251,23 @@ var _ = Describe("Slurm NodeSet", func() {
251251
g.Expect(k8sClient.Update(ctx, nodeset)).To(Succeed())
252252
replicas := int(ptr.Deref(nodeset.Spec.Replicas, 0))
253253
g.Expect(replicas).Should(Equal(0))
254-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
254+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
255255

256256
By("Verifying Slurm nodes were drained first")
257257
slurmClient := clientMap.Get(controllerKey)
258258
Eventually(func(g Gomega) {
259-
slurmNodes := &slurmtypes.V0043NodeList{}
259+
slurmNodes := &slurmtypes.V0044NodeList{}
260260
g.Expect(slurmClient.List(ctx, slurmNodes)).To(Succeed())
261261
for _, node := range slurmNodes.Items {
262-
g.Expect(node.GetStateAsSet().Has(api.V0043NodeStateDRAIN)).Should(BeTrue())
262+
g.Expect(node.GetStateAsSet().Has(slurmapi.V0044NodeStateDRAIN)).Should(BeTrue())
263263
}
264-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
264+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
265265

266266
By("Verifying pods were deleted")
267267
Eventually(func(g Gomega) {
268268
g.Expect(k8sClient.List(ctx, podList, optsList)).To(Succeed())
269269
g.Expect(len(podList.Items)).Should(Equal(0))
270-
}, testutils.Timeout, testutils.Internal).Should(Succeed())
270+
}, testutils.Timeout, testutils.Interval).Should(Succeed())
271271

272272
By("Simulating Slurm nodes being unregistered")
273273
clientMap.Add(controllerKey, newFakeClientList(interceptor.Funcs{}))

internal/controller/nodeset/nodeset_sync_status_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func TestNodeSetReconciler_syncStatus(t *testing.T) {
7676
},
7777
}
7878
c := fake.NewClientBuilder().WithRuntimeObjects(nodeset, podList, revision).WithStatusSubresource(nodeset).Build()
79-
slurmNodeList := &slurmtypes.V0043NodeList{
80-
Items: func(pods []*corev1.Pod) []slurmtypes.V0043Node {
81-
nodeList := make([]slurmtypes.V0043Node, 0, len(pods))
79+
slurmNodeList := &slurmtypes.V0044NodeList{
80+
Items: func(pods []*corev1.Pod) []slurmtypes.V0044Node {
81+
nodeList := make([]slurmtypes.V0044Node, 0, len(pods))
8282
for _, pod := range pods {
8383
slurmNode := newNodeSetPodSlurmNode(pod)
8484
nodeList = append(nodeList, *slurmNode)
@@ -126,9 +126,9 @@ func TestNodeSetReconciler_syncStatus(t *testing.T) {
126126
},
127127
}
128128
c := fake.NewClientBuilder().WithRuntimeObjects(nodeset, podList, revision).WithStatusSubresource(nodeset).Build()
129-
slurmNodeList := &slurmtypes.V0043NodeList{
130-
Items: func(pods []*corev1.Pod) []slurmtypes.V0043Node {
131-
nodeList := make([]slurmtypes.V0043Node, 0, len(pods))
129+
slurmNodeList := &slurmtypes.V0044NodeList{
130+
Items: func(pods []*corev1.Pod) []slurmtypes.V0044Node {
131+
nodeList := make([]slurmtypes.V0044Node, 0, len(pods))
132132
for _, pod := range pods {
133133
slurmNode := newNodeSetPodSlurmNode(pod)
134134
nodeList = append(nodeList, *slurmNode)
@@ -202,9 +202,9 @@ func TestNodeSetReconciler_syncSlurmStatus(t *testing.T) {
202202
Items: structutils.DereferenceList(pods),
203203
}
204204
c := fake.NewClientBuilder().WithRuntimeObjects(nodeset, podList).WithStatusSubresource(nodeset).Build()
205-
slurmNodeList := &slurmtypes.V0043NodeList{
206-
Items: func(pods []*corev1.Pod) []slurmtypes.V0043Node {
207-
nodeList := make([]slurmtypes.V0043Node, 0, len(pods))
205+
slurmNodeList := &slurmtypes.V0044NodeList{
206+
Items: func(pods []*corev1.Pod) []slurmtypes.V0044Node {
207+
nodeList := make([]slurmtypes.V0044Node, 0, len(pods))
208208
for _, pod := range pods {
209209
slurmNode := newNodeSetPodSlurmNode(pod)
210210
nodeList = append(nodeList, *slurmNode)
@@ -287,9 +287,9 @@ func TestNodeSetReconciler_syncNodeSetStatus(t *testing.T) {
287287
},
288288
}
289289
c := fake.NewClientBuilder().WithRuntimeObjects(nodeset, podList, revision).WithStatusSubresource(nodeset).Build()
290-
slurmNodeList := &slurmtypes.V0043NodeList{
291-
Items: func(pods []*corev1.Pod) []slurmtypes.V0043Node {
292-
nodeList := make([]slurmtypes.V0043Node, 0, len(pods))
290+
slurmNodeList := &slurmtypes.V0044NodeList{
291+
Items: func(pods []*corev1.Pod) []slurmtypes.V0044Node {
292+
nodeList := make([]slurmtypes.V0044Node, 0, len(pods))
293293
for _, pod := range pods {
294294
slurmNode := newNodeSetPodSlurmNode(pod)
295295
nodeList = append(nodeList, *slurmNode)
@@ -347,9 +347,9 @@ func TestNodeSetReconciler_syncNodeSetStatus(t *testing.T) {
347347
},
348348
}
349349
c := fake.NewClientBuilder().WithRuntimeObjects(nodeset, podList, revision).WithStatusSubresource(nodeset).Build()
350-
slurmNodeList := &slurmtypes.V0043NodeList{
351-
Items: func(pods []*corev1.Pod) []slurmtypes.V0043Node {
352-
nodeList := make([]slurmtypes.V0043Node, 0, len(pods))
350+
slurmNodeList := &slurmtypes.V0044NodeList{
351+
Items: func(pods []*corev1.Pod) []slurmtypes.V0044Node {
352+
nodeList := make([]slurmtypes.V0044Node, 0, len(pods))
353353
for _, pod := range pods {
354354
slurmNode := newNodeSetPodSlurmNode(pod)
355355
nodeList = append(nodeList, *slurmNode)

0 commit comments

Comments
 (0)