Skip to content

Commit e544f8b

Browse files
Merge main into v1.10-branch with known resolved conflicts
2 parents c81d8f7 + 1db185b commit e544f8b

File tree

10 files changed

+207
-117
lines changed

10 files changed

+207
-117
lines changed

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://editorconfig.org/
2+
3+
root = true
4+
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
trim_trailing_whitespace = true
9+
10+
[*.{js,py,go,sh}]
11+
charset = utf-8
12+
13+
[*.py]
14+
indent_style = space
15+
indent_size = 4
16+
17+
[*.{yaml,yml,md}]
18+
indent_style = space
19+
indent_size = 2
20+
21+
[*.md]
22+
trim_trailing_whitespace = false
23+
[Makefile]
24+
indent_style = tab
25+
26+
[*.go]
27+
indent_style = tab

OWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ approvers:
33
- atheo89
44
- caponetto
55
- harshad16
6+
- jesuino
67
- jiridanek
78
- jstourac
89
- paulovmr
@@ -13,6 +14,7 @@ reviewers:
1314
- caponetto
1415
- dibryant
1516
- harshad16
17+
- jesuino
1618
- jiridanek
1719
- jstourac
1820
- paulovmr

components/notebook-controller/controllers/notebook_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ func generateStatefulSet(instance *v1beta1.Notebook, isGenerateName bool) *appsv
439439
ssObjectMeta := metav1.ObjectMeta{
440440
Name: instance.Name,
441441
Namespace: instance.Namespace,
442+
Labels: map[string]string{},
442443
}
443444
if isGenerateName {
444445
ssObjectMeta = metav1.ObjectMeta{
@@ -470,6 +471,11 @@ func generateStatefulSet(instance *v1beta1.Notebook, isGenerateName bool) *appsv
470471
},
471472
}
472473

474+
sl := &ss.Labels
475+
for k, v := range instance.Labels {
476+
(*sl)[k] = v
477+
}
478+
473479
// copy all of the Notebook labels to the pod including poddefault related labels
474480
l := &ss.Spec.Template.ObjectMeta.Labels
475481
for k, v := range instance.ObjectMeta.Labels {

components/notebook-controller/controllers/notebook_controller_bdd_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ var _ = Describe("Notebook controller", func() {
3737
Namespace = "default"
3838
timeout = time.Second * 10
3939
interval = time.Millisecond * 250
40+
41+
testLabelName = "testLabel"
42+
testLabelValue = "testLabelValue"
4043
)
4144

4245
Context("When validating the notebook controller", func() {
@@ -47,6 +50,9 @@ var _ = Describe("Notebook controller", func() {
4750
ObjectMeta: metav1.ObjectMeta{
4851
Name: Name,
4952
Namespace: Namespace,
53+
Labels: map[string]string{
54+
testLabelName: testLabelValue,
55+
},
5056
},
5157
Spec: nbv1beta1.NotebookSpec{
5258
Template: nbv1beta1.NotebookTemplateSpec{
@@ -62,10 +68,7 @@ var _ = Describe("Notebook controller", func() {
6268

6369
Eventually(func() bool {
6470
err := k8sClient.Get(ctx, notebookLookupKey, createdNotebook)
65-
if err != nil {
66-
return false
67-
}
68-
return true
71+
return err == nil
6972
}, timeout, interval).Should(BeTrue())
7073
/*
7174
Checking for the underlying statefulset.
@@ -82,6 +85,10 @@ var _ = Describe("Notebook controller", func() {
8285
if err != nil {
8386
return false, err
8487
}
88+
89+
By("By checking that the StatefulSet has identical Labels as the Notebook")
90+
Expect(sts.GetLabels()).To(Equal(notebook.GetLabels()))
91+
8592
return true, nil
8693
}, timeout, interval).Should(BeTrue())
8794
})

components/odh-notebook-controller/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ vet: ## Run go vet against code.
9393
test: test-with-rbac-false test-with-rbac-true
9494
test-with-rbac-false: manifests generate fmt vet envtest ## Run tests.
9595
export SET_PIPELINE_RBAC=false && \
96-
ACK_GINKGO_DEPRECATIONS=1.16.5 \
9796
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \
9897
go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover-rbac-false.out
9998
test-with-rbac-true: manifests generate fmt vet envtest ## Run tests.
10099
export SET_PIPELINE_RBAC=true && \
101-
ACK_GINKGO_DEPRECATIONS=1.16.5 \
102100
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \
103101
go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover-rbac-true.out
104102

components/odh-notebook-controller/controllers/notebook_controller_test.go

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
9393
route := &routev1.Route{}
9494

9595
It("Should create a Route to expose the traffic externally", func() {
96-
ctx := context.Background()
97-
9896
By("By creating a new Notebook")
9997
Expect(cli.Create(ctx, notebook)).Should(Succeed())
10098

@@ -185,8 +183,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
185183
})
186184

187185
It("Should create a RoleBinding when the referenced Role exists", func() {
188-
ctx := context.Background()
189-
190186
By("Creating a Notebook and ensuring the Role exists")
191187
Expect(cli.Create(ctx, notebook)).Should(Succeed())
192188
time.Sleep(interval)
@@ -217,8 +213,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
217213
})
218214

219215
It("Should delete the RoleBinding when the Notebook is deleted", func() {
220-
ctx := context.Background()
221-
222216
By("Ensuring the RoleBinding exists")
223217
roleBinding := &rbacv1.RoleBinding{}
224218
Eventually(func() error {
@@ -244,7 +238,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
244238
)
245239

246240
It("Should mount a trusted-ca when it exists on the given namespace", func() {
247-
ctx := context.Background()
248241
logger := logr.Discard()
249242

250243
By("By simulating the existence of odh-trusted-ca-bundle ConfigMap")
@@ -381,8 +374,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
381374
route := &routev1.Route{}
382375

383376
It("Should create a Route to expose the traffic externally", func() {
384-
ctx := context.Background()
385-
386377
By("By creating a new Notebook")
387378
Expect(cli.Create(ctx, notebook)).Should(Succeed())
388379
time.Sleep(interval)
@@ -471,8 +462,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
471462
notebook := createNotebook(Name, Namespace)
472463

473464
It("Should update the Notebook specification", func() {
474-
ctx := context.Background()
475-
476465
By("By creating a new Notebook")
477466
Expect(cli.Create(ctx, notebook)).Should(Succeed())
478467

@@ -492,7 +481,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
492481
})
493482

494483
It("When notebook CR is updated, should mount a trusted-ca if it exists on the given namespace", func() {
495-
ctx := context.Background()
496484
logger := logr.Discard()
497485

498486
By("By simulating the existence of odh-trusted-ca-bundle ConfigMap")
@@ -622,8 +610,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
622610
notebookOAuthNetworkPolicy := &netv1.NetworkPolicy{}
623611

624612
It("Should create network policies to restrict undesired traffic", func() {
625-
ctx := context.Background()
626-
627613
By("By creating a new Notebook")
628614
Expect(cli.Create(ctx, notebook)).Should(Succeed())
629615

@@ -803,8 +789,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
803789
}
804790

805791
It("Should inject the OAuth proxy as a sidecar container", func() {
806-
ctx := context.Background()
807-
808792
By("By creating a new Notebook")
809793
Expect(cli.Create(ctx, notebook)).Should(Succeed())
810794

@@ -1045,7 +1029,6 @@ var _ = Describe("The Openshift Notebook controller", func() {
10451029
It("Should not add OAuth sidecar", func() {
10461030
notebook := createNotebook(name, namespace)
10471031
notebook.SetAnnotations(map[string]string{AnnotationServiceMesh: "true"})
1048-
ctx := context.Background()
10491032
Expect(cli.Create(ctx, notebook)).Should(Succeed())
10501033

10511034
actualNotebook := &nbv1.Notebook{}
@@ -1060,7 +1043,7 @@ var _ = Describe("The Openshift Notebook controller", func() {
10601043
It("Should not define OAuth network policy", func() {
10611044
policies := &netv1.NetworkPolicyList{}
10621045
Eventually(func() error {
1063-
return cli.List(context.Background(), policies, client.InNamespace(namespace))
1046+
return cli.List(ctx, policies, client.InNamespace(namespace))
10641047
}, duration, interval).Should(Succeed())
10651048

10661049
Expect(policies.Items).To(Not(ContainElement(notebookOAuthNetworkPolicy)))
@@ -1069,7 +1052,7 @@ var _ = Describe("The Openshift Notebook controller", func() {
10691052
It("Should not create routes", func() {
10701053
routes := &routev1.RouteList{}
10711054
Eventually(func() error {
1072-
return cli.List(context.Background(), routes, client.InNamespace(namespace))
1055+
return cli.List(ctx, routes, client.InNamespace(namespace))
10731056
}, duration, interval).Should(Succeed())
10741057

10751058
Expect(routes.Items).To(BeEmpty())
@@ -1080,7 +1063,7 @@ var _ = Describe("The Openshift Notebook controller", func() {
10801063

10811064
serviceAccounts := &corev1.ServiceAccountList{}
10821065
Eventually(func() error {
1083-
return cli.List(context.Background(), serviceAccounts, client.InNamespace(namespace))
1066+
return cli.List(ctx, serviceAccounts, client.InNamespace(namespace))
10841067
}, duration, interval).Should(Succeed())
10851068

10861069
Expect(serviceAccounts.Items).ToNot(ContainElement(oauthServiceAccount))
@@ -1094,7 +1077,7 @@ var _ = Describe("The Openshift Notebook controller", func() {
10941077
},
10951078
}
10961079
Eventually(func() error {
1097-
return cli.List(context.Background(), secrets, client.InNamespace(namespace))
1080+
return cli.List(ctx, secrets, client.InNamespace(namespace))
10981081
}, duration, interval).Should(Succeed())
10991082

11001083
Expect(secrets.Items).To(BeEmpty())

components/odh-notebook-controller/controllers/notebook_runtime.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"reflect"
7+
"regexp"
78
"strings"
89

910
"github.com/go-logr/logr"
@@ -182,9 +183,12 @@ func extractDisplayName(metadata string) string {
182183
return displayName
183184
}
184185

186+
var multiDash = regexp.MustCompile(`-+`)
187+
185188
func formatKeyName(displayName string) string {
186-
replacer := strings.NewReplacer(" ", "-", "(", "", ")", "")
187-
return strings.ToLower(replacer.Replace(displayName)) + ".json"
189+
s := strings.NewReplacer(" ", "-", "(", "", ")", "", "|", "").Replace(displayName)
190+
s = multiDash.ReplaceAllString(strings.ToLower(s), "-")
191+
return strings.Trim(s, "-") + ".json"
188192
}
189193

190194
// parseRuntimeImageMetadata extracts the first object from the JSON array

components/odh-notebook-controller/controllers/notebook_runtime_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package controllers
22

33
import (
4-
"context"
54
"fmt"
65
"time"
76

@@ -27,8 +26,6 @@ const (
2726
)
2827

2928
var _ = Describe("Runtime images ConfigMap should be mounted", func() {
30-
ctx := context.Background()
31-
3229
When("Empty ConfigMap for runtime images", func() {
3330

3431
BeforeEach(func() {

0 commit comments

Comments
 (0)