From cbae9f2d631e854558daeb08d0d2ebbde94c32d7 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 8 Jan 2026 15:04:53 +0530 Subject: [PATCH] check worker deployment in k8s before deploying --- functions/onprem/orborus/orborus.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index 9a70a774..3efdbdc6 100755 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -1448,6 +1448,19 @@ func deployK8sWorker(image string, identifier string, env []string) error { } } + existing, err := clientset.AppsV1().Deployments(kubernetesNamespace).List(ctx, metav1.ListOptions{ + LabelSelector: "app.kubernetes.io/name=shuffle-worker", + }) + if err != nil { + log.Printf("[ERROR] Failed listing existing deployments: %v", err) + return err + } + + if len(existing.Items) > 0 { + log.Printf("[INFO] Found existing deployments, skipping creation") + return nil + } + replicaNumberInt32 := int32(replicaNumber) // worker makes authenticated requests to the k8s api to create app deployments. // Therefore, it needs to have access to the service account token.