From 00ffd7bfa8aa2663da76d45ad260da60647afa99 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 26 Jun 2025 02:47:29 +0530 Subject: [PATCH 1/4] fixes some of the issue in 2.1.0-rc2 --- backend/go-app/walkoff.go | 4 ++-- functions/onprem/orborus/orborus.go | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 2331a273..729d100a 100755 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -280,7 +280,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { //log.Printf("[AUDIT] Get workflow queue for org %s, env %s, orborus label %s", orgId, environment, orborusLabel) ctx := shuffle.GetContext(request) - env, err := shuffle.GetEnvironment(ctx, orgId, "") + env, err := shuffle.GetEnvironment(ctx, "", orgId) if err != nil { log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err) } @@ -477,7 +477,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { } if len(orgId) > 0 { - env, err := shuffle.GetEnvironment(ctx, orgId, foundId) + env, err := shuffle.GetEnvironment(ctx, foundId, orgId) if err != nil { log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err) //resp.WriteHeader(401) diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index 9b5c87da..26f16017 100755 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -813,20 +813,20 @@ func handleBackendImageDownload(ctx context.Context, images string) error { newImages = append(newImages, curimage) // Force remove the current image to avoid cached layers - if swarmConfig == "run" || swarmConfig == "swarm" { - _, err := dockercli.ImageRemove(ctx, curimage, image.RemoveOptions{ - Force: true, - PruneChildren: true, - }) + // if swarmConfig == "run" || swarmConfig == "swarm" { + // _, err := dockercli.ImageRemove(ctx, curimage, image.RemoveOptions{ + // Force: true, + // PruneChildren: true, + // }) - if err != nil { - log.Printf("[ERROR] Failed removing image for re-download: %s", err) - } else { - log.Printf("[DEBUG] Removed image: %s", curimage) - } - } else { - //log.Printf("[DEBUG] Skipping image removal for %s as swarmConfig is not set to run or swarm. Value: %#v", curimage, swarmConfig) - } + // if err != nil { + // log.Printf("[ERROR] Failed removing image for re-download: %s", err) + // } else { + // log.Printf("[DEBUG] Removed image: %s", curimage) + // } + // } else { + // //log.Printf("[DEBUG] Skipping image removal for %s as swarmConfig is not set to run or swarm. Value: %#v", curimage, swarmConfig) + // } err := shuffle.DownloadDockerImageBackend(&http.Client{Timeout: imagedownloadTimeout}, curimage) if err != nil { @@ -874,6 +874,7 @@ func handleBackendImageDownload(ctx context.Context, images string) error { // Update the service to run with the new image //docker service update --image username/imagename:latest servicename --force serviceUpdateOptions := types.ServiceUpdateOptions{} + service.Spec.TaskTemplate.ForceUpdate++ resp, err := dockercli.ServiceUpdate( ctx, service.ID, From a08938735ce9b6d5f80ae779bb3077b1ad292d32 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 26 Jun 2025 14:17:38 +0530 Subject: [PATCH 2/4] get requested env for workflow --- backend/go-app/walkoff.go | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 729d100a..902384f3 100755 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -280,11 +280,33 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { //log.Printf("[AUDIT] Get workflow queue for org %s, env %s, orborus label %s", orgId, environment, orborusLabel) ctx := shuffle.GetContext(request) - env, err := shuffle.GetEnvironment(ctx, "", orgId) - if err != nil { + // Get all env and check the name? + envs, err := shuffle.GetEnvironments(ctx, orgId) + if err != nil || len(envs) == 0 { log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err) } + body, err := io.ReadAll(request.Body) + if err != nil { + log.Printf("[ERROR] Failed to read body of orborus workflow queue request") + return + } + + var envData shuffle.OrborusStats + err = json.Unmarshal(body, &envData) + if err != nil { + log.Printf("[ERROR] Failed to unmarshal orborus workflow queue request") + return + } + + var env *shuffle.Environment + for _, e := range envs { + if e.Name == envData.Environment { + env = &e + break + } + } + timeNow := time.Now().Unix() err = shuffle.HandleOrborusFailover(ctx, request, resp, env) if err != nil { From 78baecb25323ffe72bdeb279f9b2d4774bf28457 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 26 Jun 2025 19:27:10 +0530 Subject: [PATCH 3/4] sync up with cloud changes --- backend/go-app/walkoff.go | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 902384f3..b2c48011 100755 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -246,16 +246,16 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { } // This is really the environment's name - NOT org-id - orgId := request.Header.Get("Org-Id") - if len(orgId) == 0 { + environment := request.Header.Get("Org-Id") + if len(environment) == 0 { log.Printf("[AUDIT] No org-id header set") resp.WriteHeader(401) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Specify the org-id header."}`))) return } - environment := request.Header.Get("org") - if len(environment) == 0 { + orgId := request.Header.Get("org") + if len(orgId) == 0 { //log.Printf("[AUDIT] No 'org' header set (get workflow queue). ") /* resp.WriteHeader(403) @@ -281,27 +281,14 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { ctx := shuffle.GetContext(request) // Get all env and check the name? - envs, err := shuffle.GetEnvironments(ctx, orgId) + envs, err := shuffle.GetEnvironments(ctx, environment) if err != nil || len(envs) == 0 { - log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err) - } - - body, err := io.ReadAll(request.Body) - if err != nil { - log.Printf("[ERROR] Failed to read body of orborus workflow queue request") - return - } - - var envData shuffle.OrborusStats - err = json.Unmarshal(body, &envData) - if err != nil { - log.Printf("[ERROR] Failed to unmarshal orborus workflow queue request") - return + log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", environment, err) } var env *shuffle.Environment for _, e := range envs { - if e.Name == envData.Environment { + if e.Name == environment { env = &e break } @@ -319,7 +306,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { //log.Printf("Found env: %#v", env) if len(env.OrgId) > 0 { - environment = env.OrgId + orgId = env.OrgId } // FIXME: Workflow stats disabled for now @@ -360,7 +347,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { //if int(envData.CPUPercent) > percentageCheck { // Get cached data percentages := []float64{} - cacheKey := fmt.Sprintf("%s_%s_percent", orgId, strings.ToLower(environment)) + cacheKey := fmt.Sprintf("%s_%s_percent", environment , strings.ToLower(orgId)) // Marshal float list into []byte cacheData := []byte{} @@ -470,7 +457,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { } } - executionRequests, err := shuffle.GetWorkflowQueue(ctx, orgId, 100) + executionRequests, err := shuffle.GetWorkflowQueue(ctx, environment, 100) if err != nil { // Skipping as this comes up over and over //log.Printf("(2) Failed reading body for workflowqueue: %s", err) @@ -498,8 +485,8 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { } } - if len(orgId) > 0 { - env, err := shuffle.GetEnvironment(ctx, foundId, orgId) + if len(environment) > 0 { + env, err := shuffle.GetEnvironment(ctx, foundId, environment) if err != nil { log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err) //resp.WriteHeader(401) From c061dc37324bfd5b852a7ef0979d87d6da9f4672 Mon Sep 17 00:00:00 2001 From: yashsinghcodes Date: Thu, 26 Jun 2025 19:33:00 +0530 Subject: [PATCH 4/4] get env based on orgId --- backend/go-app/walkoff.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index b2c48011..d33cee2c 100755 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -281,7 +281,8 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { ctx := shuffle.GetContext(request) // Get all env and check the name? - envs, err := shuffle.GetEnvironments(ctx, environment) + envs, err := shuffle.GetEnvironments(ctx, orgId) + if err != nil || len(envs) == 0 { log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", environment, err) }