@@ -174,8 +174,17 @@ func (r *CullingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
174174 Message : "Failed to fetch service name for workspace" ,
175175 }, nil , nil )
176176 }
177- port := "8888"
178- jupyterAPIEndpoint := fmt .Sprintf ("http://%s.%s.svc.%s:%s/workspace/%s/%s/jupyterlab/api/status" , serviceName , workspace .Namespace , defaultClusterDomain , port , workspace .Namespace , workspace .Name )
177+ port , err := r .getWorkspacePort (ctx , workspace , workspaceKind )
178+ if err != nil {
179+ log .Error (err , "Error fetching port for workspace" )
180+ return r .updateWorkspaceActivityStatus (ctx , log , workspace , & minRequeueAfter , & kubefloworgv1beta1.ProbeStatus {
181+ StartTimeMs : probeStartTime .UnixMilli (),
182+ EndTimeMs : time .Now ().UnixMilli (),
183+ Result : kubefloworgv1beta1 .ProbeResultFailure ,
184+ Message : "Failed to fetch port for workspace" ,
185+ }, nil , nil )
186+ }
187+ jupyterAPIEndpoint := fmt .Sprintf ("http://%s.%s.svc.%s:%d/workspace/%s/%s/jupyterlab/api/status" , serviceName , workspace .Namespace , defaultClusterDomain , port , workspace .Namespace , workspace .Name )
179188
180189 lastActivity , err , probeMessage , probeResult := fetchLastActivityFromJupyterAPI (jupyterAPIEndpoint )
181190 if err != nil {
@@ -211,6 +220,7 @@ func (r *CullingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
211220 }, ptr .To (probeStartTime .Unix ()), ptr .To (lastActivity .Unix ()))
212221 }
213222
223+ // Check if Bash probing is enabled
214224 if workspaceKind .Spec .PodTemplate .Culling .ActivityProbe .Exec != nil {
215225 probeStartTime := time .Now ()
216226 podName , err := r .getPodName (ctx , workspace )
@@ -369,6 +379,19 @@ func (r *CullingReconciler) getServiceName(ctx context.Context, workspace *kubef
369379 return ownedServices .Items [0 ].Name , nil
370380}
371381
382+ func (r * CullingReconciler ) getWorkspacePort (ctx context.Context , workspace * kubefloworgv1beta1.Workspace , workspaceKind * kubefloworgv1beta1.WorkspaceKind ) (int32 , error ) {
383+ for _ , imageConfigValue := range workspaceKind .Spec .PodTemplate .Options .ImageConfig .Values {
384+ if imageConfigValue .Id == workspace .Spec .PodTemplate .Options .ImageConfig {
385+ for _ , port := range imageConfigValue .Spec .Ports {
386+ if port .Id == workspaceKind .Spec .PodTemplate .Culling .ActivityProbe .Jupyter .PortId {
387+ return port .Port , nil
388+ }
389+ }
390+ }
391+ }
392+ return 0 , errors .New ("port not found" )
393+ }
394+
372395func (r * CullingReconciler ) getPodName (ctx context.Context , workspace * kubefloworgv1beta1.Workspace ) (string , error ) {
373396 var statefulSetName string
374397 ownedStatefulSets := & appsv1.StatefulSetList {}
0 commit comments