From 6047a560ce5995db171131693420d95b2e8a5236 Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Tue, 6 Aug 2024 19:11:34 -0400 Subject: [PATCH] fix: status UI fails to show task cells for workers Signed-off-by: Nick Mitchell --- pkg/be/kubernetes/updates.go | 10 +++++++++- pkg/observe/qstat/stream.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/be/kubernetes/updates.go b/pkg/be/kubernetes/updates.go index cb710d58..f11c6c32 100644 --- a/pkg/be/kubernetes/updates.go +++ b/pkg/be/kubernetes/updates.go @@ -70,6 +70,11 @@ func updateFromPod(pod *v1.Pod, what watch.EventType, cc chan events.ComponentUp return fmt.Errorf("Worker without component label %s\n", pod.Name) } + runname, exists := pod.Labels["app.kubernetes.io/instance"] + if !exists { + return fmt.Errorf("Worker without instance/runname label %s\n", pod.Name) + } + name := pod.Name if component == string(comp.WorkersComponent) { @@ -78,7 +83,9 @@ func updateFromPod(pod *v1.Pod, what watch.EventType, cc chan events.ComponentUp return fmt.Errorf("Worker without pool name label %s\n", pod.Name) } - // see watcher.sh remote=... TODO avoid these disparate hacks + poolname = strings.Replace(poolname, runname+"-", "", 1) + + // see worker-watcher main.go getPodNameSuffix() TODO avoid these disparate hacks lastDashIdx := strings.LastIndex(pod.Name, "-") suffix := pod.Name[lastDashIdx+1:] name = fmt.Sprintf("%s.%s", poolname, suffix) @@ -118,6 +125,7 @@ func updateFromPod(pod *v1.Pod, what watch.EventType, cc chan events.ComponentUp poolName, exists := pod.Labels["app.kubernetes.io/name"] if exists { + poolName = strings.Replace(poolName, runname+"-", "", 1) cc <- events.WorkerUpdate(name, pod.Namespace, poolName, platform.Kubernetes, workerStatus, what) } } diff --git a/pkg/observe/qstat/stream.go b/pkg/observe/qstat/stream.go index d4894303..04a973f1 100644 --- a/pkg/observe/qstat/stream.go +++ b/pkg/observe/qstat/stream.go @@ -142,7 +142,7 @@ func streamModel(runname, namespace string, follow bool, tail int64, quiet bool, } func poolName(worker Worker) string { - // test7f-pool1.w0.w96bh -> test7f-pool1 + // test7f-pool1.w96bh -> test7f-pool1 if idx := strings.Index(worker.Name, "."); idx < 0 { // TODO error handling here. what do we want to do? return "INVALID: " + worker.Name