Skip to content

Commit f788c60

Browse files
authored
Merge pull request #304 from harshad16/RHOAI-5025
create configmap and mount for the first workbench in NS
2 parents 5182222 + 91d4aa4 commit f788c60

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ var _ = Describe("The Openshift Notebook controller", func() {
165165

166166
By("By simulating the existence of odh-trusted-ca-bundle ConfigMap")
167167
// Create a ConfigMap similar to odh-trusted-ca-bundle for simulation
168+
workbenchTrustedCACertBundle := "workbench-trusted-ca-bundle"
168169
trustedCACertBundle := &corev1.ConfigMap{
169170
ObjectMeta: metav1.ObjectMeta{
170171
Name: "odh-trusted-ca-bundle",
@@ -219,7 +220,7 @@ var _ = Describe("The Openshift Notebook controller", func() {
219220
Name: "trusted-ca",
220221
VolumeSource: corev1.VolumeSource{
221222
ConfigMap: &corev1.ConfigMapVolumeSource{
222-
LocalObjectReference: corev1.LocalObjectReference{Name: trustedCACertBundle.Name},
223+
LocalObjectReference: corev1.LocalObjectReference{Name: workbenchTrustedCACertBundle},
223224
Optional: pointer.Bool(true),
224225
Items: []corev1.KeyToPath{
225226
{

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,24 @@ func CheckAndMountCACertBundle(ctx context.Context, cli client.Client, notebook
294294
workbenchConfigMap := &corev1.ConfigMap{}
295295
err := cli.Get(ctx, client.ObjectKey{Namespace: notebook.Namespace, Name: workbenchConfigMapName}, workbenchConfigMap)
296296
if err != nil {
297-
log.Info("workbench-trusted-ca-bundle ConfigMap is not present, skipping mounting of certificates.")
298-
return nil
297+
log.Info("workbench-trusted-ca-bundle ConfigMap is not present, start creating it...")
298+
// create the ConfigMap if it does not exist
299+
workbenchConfigMap = &corev1.ConfigMap{
300+
ObjectMeta: metav1.ObjectMeta{
301+
Name: workbenchConfigMapName,
302+
Namespace: notebook.Namespace,
303+
Labels: map[string]string{"opendatahub.io/managed-by": "workbenches"},
304+
},
305+
Data: map[string]string{
306+
"ca-bundle.crt": odhConfigMap.Data["ca-bundle.crt"],
307+
},
308+
}
309+
err = cli.Create(ctx, workbenchConfigMap)
310+
if err != nil {
311+
log.Info("Failed to create workbench-trusted-ca-bundle ConfigMap")
312+
return nil
313+
}
314+
log.Info("Created workbench-trusted-ca-bundle ConfigMap")
299315
}
300316

301317
cm := workbenchConfigMap

0 commit comments

Comments
 (0)