From b4fe1fe880aad00580aeb44d31ec6965e5b0b178 Mon Sep 17 00:00:00 2001 From: rohank07 Date: Wed, 29 Sep 2021 14:00:47 -0400 Subject: [PATCH] add prob volume label --- notebooks.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/notebooks.go b/notebooks.go index 24c66cec..338125bb 100644 --- a/notebooks.go +++ b/notebooks.go @@ -234,7 +234,7 @@ func (s *server) GetNotebooks(w http.ResponseWriter, r *http.Request) { func (s *server) handleVolume(ctx context.Context, req volumerequest, notebook *kubeflowv1.Notebook) error { var pvc = corev1.PersistentVolumeClaim{} if req.Type == VolumeTypeNew { - if notebook.GetObjectMeta().GetLabels()["notebook.statcan.gc.ca/protected-b"] == "true" { + if _, ok := notebook.GetObjectMeta().GetLabels()["notebook.statcan.gc.ca/protected-b"]; ok { pvc = corev1.PersistentVolumeClaim{ ObjectMeta: v1.ObjectMeta{ Name: req.Name, @@ -380,6 +380,17 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) { notebook.Spec.Template.Spec.Containers[0].Resources.Limits[corev1.ResourceMemory] = req.Memory } + // Add configuration items + if s.Config.SpawnerFormDefaults.Configurations.ReadOnly { + for _, config := range s.Config.SpawnerFormDefaults.Configurations.Value { + notebook.ObjectMeta.Labels[config] = "true" + } + } else { + for _, config := range req.Configurations { + notebook.ObjectMeta.Labels[config] = "true" + } + } + // Add workspace volume if s.Config.SpawnerFormDefaults.WorkspaceVolume.ReadOnly { size, err := resource.ParseQuantity(s.Config.SpawnerFormDefaults.WorkspaceVolume.Value.Size.Value) @@ -482,17 +493,6 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) { } } - // Add configuration items - if s.Config.SpawnerFormDefaults.Configurations.ReadOnly { - for _, config := range s.Config.SpawnerFormDefaults.Configurations.Value { - notebook.ObjectMeta.Labels[config] = "true" - } - } else { - for _, config := range req.Configurations { - notebook.ObjectMeta.Labels[config] = "true" - } - } - //Add Language //Validate that the language format is valid (language[_territory]) match, err := regexp.MatchString("^[[:alpha:]]{2}(_[[:alpha:]]{2})?$", req.Language)