@@ -224,7 +224,7 @@ def run(self):
224224
225225 while True :
226226 time .sleep (1 )
227- logger .info ('KubeWatcher is connecting: ' + str ( ignored_namespaces ) )
227+ logger .info ('KubeWatcher is connecting...' )
228228 try :
229229 # Resource version is used to keep track of stream progress (in case of resume)
230230 self .stream = w .stream (func = v1 .list_pod_for_all_namespaces ,
@@ -239,7 +239,7 @@ def run(self):
239239
240240 # Skip Pods in ignored namespaces
241241 if event ['object' ].metadata .namespace in ignored_namespaces :
242- logger .info ('Skipping event in excluded namespace' )
242+ logger .debug ('Skipping event in excluded namespace' )
243243 continue
244244
245245 # Examine labels, ignore if not workbench app
@@ -362,8 +362,6 @@ def open_exec_userapp_interactive(user, ssid, ws):
362362 if resp .is_open ():
363363 resp .close ()
364364
365- logger .info ("Success! :D" )
366-
367365
368366def generate_random_password (length = 16 ):
369367 # choose from all lowercase letter
@@ -426,7 +424,7 @@ def initialize():
426424 logger .warning ('Failed to load any cluster config.. this might not work.' )
427425
428426 host = kubeconfig .kube_config .Configuration ().host
429- logging .info ("KUBE HOST INFO : {}" .format (host ))
427+ logging .info ("Connecting to Kubernetes API : {}" .format (host ))
430428
431429 if is_single_namespace ():
432430 logger .debug ("Starting in single-namespace mode: " + config .KUBE_WORKBENCH_NAMESPACE )
@@ -486,13 +484,12 @@ def create_userapp(username, userapp, spec_map):
486484 'workbench-app' : userapp_id
487485 }
488486
489- logger .info ("Map of specs: %s" % spec_map )
487+ # logger.debug ("Map of specs: %s" % spec_map)
490488 for stack_service in userapp ['services' ]:
491489 service_key = stack_service ['service' ]
492490 app_spec = spec_map .get (service_key , None )
493491 svc_labels = labels .copy ()
494492 svc_labels ['workbench-svc' ] = service_key
495- logger .info ("Created svc_labels: " + str (svc_labels ))
496493 if app_spec is None :
497494 logger .error ("Failed to find app_spec: %s" % service_key )
498495 raise AppSpecNotFoundError ("Failed to find app_spec: %s" % service_key )
@@ -523,7 +520,22 @@ def create_userapp(username, userapp, spec_map):
523520 volume_mounts = []
524521 if 'volumeMounts' in app_spec :
525522 for vol in app_spec ['volumeMounts' ]:
526- sub_path = vol ['defaultPath' ] if 'defaultPath' in vol else f'AppData/{ userapp_id } -{ service_key } '
523+ # If path is the root
524+ if 'defaultPath' in vol :
525+ if vol ['defaultPath' ] != '/' :
526+ # default path is not the root, use it as a relative path
527+ if str .startswith (vol ['defaultPath' ], '/' ):
528+ # Make path relative if given an absolute
529+ sub_path = vol ['defaultPath' ][1 :]
530+ else :
531+ # Path is relative, use as-is
532+ sub_path = vol ['defaultPath' ]
533+ else :
534+ # default path is the root - mount the whole volume (no sub_path)
535+ sub_path = ''
536+ else :
537+ # No default path specified, make a local folder
538+ sub_path = f'AppData/{ userapp_id } -{ service_key } '
527539 mount_path = vol ['mountPath' ]
528540 userapp_mounts [sub_path ] = mount_path
529541 volume_mounts .append (client .V1VolumeMount (
@@ -553,7 +565,6 @@ def create_userapp(username, userapp, spec_map):
553565 containers .append (container )
554566
555567 # Create one Kubernetes service per-stack service
556- logger .info ("Creating service with resource name: " + str (resource_name ))
557568 if len (service_ports ) > 0 :
558569 create_service (service_name = resource_name ,
559570 namespace = namespace , labels = svc_labels ,
@@ -654,7 +665,7 @@ def update_userapp(username, userapp_id, userapp):
654665 # Build up config from userapp env/config and appspec config
655666 configmap_data = svc ['config' ] if 'config' in svc else {}
656667
657- logger .info ("Saving configmap data: " + str (configmap_data ))
668+ logger .debug ("Saving configmap data: " + str (configmap_data ))
658669
659670 update_configmap (namespace = namespace , configmap_name = resource_name , configmap_data = configmap_data )
660671
@@ -770,7 +781,7 @@ def patch_scale_deployment(deployment_name, namespace, replicas) -> bool:
770781 # Query number of replicas
771782 result = client .AppsV1Api ().patch_namespaced_deployment_scale (namespace = namespace , name = deployment_name ,
772783 body = {'spec' : {'replicas' : replicas }})
773- logger .info ("Patch Result: " + str (result ))
784+ logger .debug ("Patch Result: " + str (result ))
774785 return result
775786
776787
@@ -1062,7 +1073,7 @@ def create_deployment(deployment_name, containers, labels, username, **kwargs):
10621073 )
10631074 )
10641075
1065- logger .info ("Creating deployment resource: %s" % str (body ))
1076+ logger .info ("Creating deployment resource: %s" % str (deployment_name ))
10661077 deployment = appv1 .create_namespaced_deployment (namespace = deployment_namespace , body = body )
10671078 logger .debug ("Created deployment resource: %s" % str (deployment ))
10681079 return deployment
@@ -1099,6 +1110,7 @@ def create_service(service_name, service_ports, labels, **kwargs):
10991110 service_annotations = kwargs ['annotations' ] if 'annotations' in kwargs else {}
11001111
11011112 try :
1113+ logger .info ("Creating service with resource name: " + str (service_name ))
11021114 service = v1 .create_namespaced_service (namespace = service_namespace , body = client .V1Service (
11031115 api_version = 'v1' ,
11041116 kind = 'Service' ,
0 commit comments