Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ func generateStatefulSet(instance *v1beta1.Notebook) *appsv1.StatefulSet {
ObjectMeta: metav1.ObjectMeta{
Name: instance.Name,
Namespace: instance.Namespace,
Labels: map[string]string{},
},
Spec: appsv1.StatefulSetSpec{
Replicas: &replicas,
Expand Down Expand Up @@ -403,6 +404,12 @@ func generateStatefulSet(instance *v1beta1.Notebook) *appsv1.StatefulSet {
}
}

// copy all of the Notebook labels to the StatefulSet
sl := &ss.Labels
for k, v := range instance.Labels {
(*sl)[k] = v
}

podSpec := &ss.Spec.Template.Spec
container := &podSpec.Containers[0]
if container.WorkingDir == "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ var _ = Describe("Notebook controller", func() {

// Define utility constants for object names and testing timeouts/durations and intervals.
const (
Name = "test-notebook"
Namespace = "default"
timeout = time.Second * 10
interval = time.Millisecond * 250
Name = "test-notebook"
Namespace = "default"
testLabelName = "testLabel"
testLabelValue = "testLabelValue"
timeout = time.Second * 10
interval = time.Millisecond * 250
)

Context("When validating the notebook controller", func() {
Expand All @@ -47,6 +49,9 @@ var _ = Describe("Notebook controller", func() {
ObjectMeta: metav1.ObjectMeta{
Name: Name,
Namespace: Namespace,
Labels: map[string]string{
testLabelName: testLabelValue,
},
},
Spec: nbv1beta1.NotebookSpec{
Template: nbv1beta1.NotebookTemplateSpec{
Expand All @@ -73,8 +78,9 @@ var _ = Describe("Notebook controller", func() {
Only the API server is running within envtest. So cannot check actual pods / replicas.
*/
By("By checking that the Notebook has statefulset")
sts := &appsv1.StatefulSet{}
Eventually(func() (bool, error) {
sts := &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{
sts = &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{
Name: Name,
Namespace: Namespace,
}}
Expand All @@ -84,6 +90,8 @@ var _ = Describe("Notebook controller", func() {
}
return true, nil
}, timeout, interval).Should(BeTrue())
By("By checking that the StatefulSet has identical Labels as the Notebook")
Expect(sts.GetLabels()).To(Equal(notebook.GetLabels()))
})
})
})
Loading