@@ -174,8 +174,17 @@ func (r *CullingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
174
174
Message : "Failed to fetch service name for workspace" ,
175
175
}, nil , nil )
176
176
}
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 )
179
188
180
189
lastActivity , err , probeMessage , probeResult := fetchLastActivityFromJupyterAPI (jupyterAPIEndpoint )
181
190
if err != nil {
@@ -211,6 +220,7 @@ func (r *CullingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
211
220
}, ptr .To (probeStartTime .Unix ()), ptr .To (lastActivity .Unix ()))
212
221
}
213
222
223
+ // Check if Bash probing is enabled
214
224
if workspaceKind .Spec .PodTemplate .Culling .ActivityProbe .Exec != nil {
215
225
probeStartTime := time .Now ()
216
226
podName , err := r .getPodName (ctx , workspace )
@@ -369,6 +379,19 @@ func (r *CullingReconciler) getServiceName(ctx context.Context, workspace *kubef
369
379
return ownedServices .Items [0 ].Name , nil
370
380
}
371
381
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
+
372
395
func (r * CullingReconciler ) getPodName (ctx context.Context , workspace * kubefloworgv1beta1.Workspace ) (string , error ) {
373
396
var statefulSetName string
374
397
ownedStatefulSets := & appsv1.StatefulSetList {}
0 commit comments