Skip to content

Commit 4da8e98

Browse files
committed
enable kueue integration by ensuing that labels added to Notebooks are propogated to the underlying StatefulSet
Signed-off-by: Kevin Hannon <kehannon@redhat.com>
1 parent 669de15 commit 4da8e98

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

components/notebook-controller/controllers/notebook_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ func generateStatefulSet(instance *v1beta1.Notebook) *appsv1.StatefulSet {
368368
ObjectMeta: metav1.ObjectMeta{
369369
Name: instance.Name,
370370
Namespace: instance.Namespace,
371+
Labels: map[string]string{},
371372
},
372373
Spec: appsv1.StatefulSetSpec{
373374
Replicas: &replicas,
@@ -403,6 +404,12 @@ func generateStatefulSet(instance *v1beta1.Notebook) *appsv1.StatefulSet {
403404
}
404405
}
405406

407+
// copy all of the Notebook labels to the StatefulSet
408+
sl := &ss.Labels
409+
for k, v := range instance.Labels {
410+
(*sl)[k] = v
411+
}
412+
406413
podSpec := &ss.Spec.Template.Spec
407414
container := &podSpec.Containers[0]
408415
if container.WorkingDir == "" {

components/notebook-controller/controllers/notebook_controller_bdd_test.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ var _ = Describe("Notebook controller", func() {
3333

3434
// Define utility constants for object names and testing timeouts/durations and intervals.
3535
const (
36-
Name = "test-notebook"
37-
Namespace = "default"
38-
timeout = time.Second * 10
39-
interval = time.Millisecond * 250
36+
Name = "test-notebook"
37+
Namespace = "default"
38+
testLabelName = "testLabel"
39+
testLabelValue = "testLabelValue"
40+
timeout = time.Second * 10
41+
interval = time.Millisecond * 250
4042
)
4143

4244
Context("When validating the notebook controller", func() {
@@ -47,6 +49,9 @@ var _ = Describe("Notebook controller", func() {
4749
ObjectMeta: metav1.ObjectMeta{
4850
Name: Name,
4951
Namespace: Namespace,
52+
Labels: map[string]string{
53+
testLabelName: testLabelValue,
54+
},
5055
},
5156
Spec: nbv1beta1.NotebookSpec{
5257
Template: nbv1beta1.NotebookTemplateSpec{
@@ -73,8 +78,9 @@ var _ = Describe("Notebook controller", func() {
7378
Only the API server is running within envtest. So cannot check actual pods / replicas.
7479
*/
7580
By("By checking that the Notebook has statefulset")
81+
sts := &appsv1.StatefulSet{}
7682
Eventually(func() (bool, error) {
77-
sts := &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{
83+
sts = &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{
7884
Name: Name,
7985
Namespace: Namespace,
8086
}}
@@ -84,6 +90,8 @@ var _ = Describe("Notebook controller", func() {
8490
}
8591
return true, nil
8692
}, timeout, interval).Should(BeTrue())
93+
By("By checking that the StatefulSet has identical Labels as the Notebook")
94+
Expect(sts.GetLabels()).To(Equal(notebook.GetLabels()))
8795
})
8896
})
8997
})

0 commit comments

Comments
 (0)