From 9445e7092b0d15bbf54b2918559c8b3ccb8ac66a Mon Sep 17 00:00:00 2001 From: frikky Date: Sun, 24 Oct 2021 01:23:22 +0200 Subject: [PATCH 1/3] Fixed issues with worker --- frontend/src/views/Apps.jsx | 9 +++++++-- frontend/src/views/Workflows.jsx | 2 +- functions/onprem/worker/go.mod | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Apps.jsx b/frontend/src/views/Apps.jsx index ec694c2b..ad85db41 100644 --- a/frontend/src/views/Apps.jsx +++ b/frontend/src/views/Apps.jsx @@ -370,8 +370,13 @@ const Apps = (props) => { }} /> var newAppname = data.name - newAppname = newAppname.charAt(0).toUpperCase()+newAppname.substring(1) - newAppname = newAppname.replaceAll("_", " ") + if (newAppname === undefined) { + newAppname = "Undefined" + } else { + newAppname = newAppname.charAt(0).toUpperCase()+newAppname.substring(1) + newAppname = newAppname.replaceAll("_", " ") + } + var sharing = "public" if (!data.sharing) { sharing = "private" diff --git a/frontend/src/views/Workflows.jsx b/frontend/src/views/Workflows.jsx index 7bf7df06..c2930ba3 100644 --- a/frontend/src/views/Workflows.jsx +++ b/frontend/src/views/Workflows.jsx @@ -1938,7 +1938,7 @@ const Workflows = (props) => { }} color="primary"> {submitLoading ? - + : "Submit" } diff --git a/functions/onprem/worker/go.mod b/functions/onprem/worker/go.mod index f60fa5a4..197e1404 100644 --- a/functions/onprem/worker/go.mod +++ b/functions/onprem/worker/go.mod @@ -8,6 +8,6 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/gorilla/mux v1.8.0 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/shuffle/shuffle-shared v0.1.19 + github.com/shuffle/shuffle-shared v0.1.20 go4.org v0.0.0-20201209231011-d4a079459e60 // indirect ) From 49cfb00a6c399600b6b6fe0458a6e9d123a43540 Mon Sep 17 00:00:00 2001 From: frikky Date: Mon, 25 Oct 2021 15:51:52 +0200 Subject: [PATCH 2/3] Added workflow priority search and orborus checkin IP --- backend/go-app/main.go | 2 +- backend/go-app/walkoff.go | 62 ++++++++++++++++++++++++-- frontend/src/views/Admin.jsx | 24 ++++++---- frontend/src/views/AngularWorkflow.jsx | 1 + frontend/src/views/Workflows.jsx | 8 ++-- 5 files changed, 81 insertions(+), 16 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 7bd0f90b..40904bc3 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -3846,7 +3846,7 @@ func runInitEs(ctx context.Context) { //} } else { - log.Printf("[DEBUG] There are %d org(s).", len(activeOrgs)) + log.Printf("[DEBUG] Found %d org(s) in total.", len(activeOrgs)) if len(activeOrgs) == 1 { if len(activeOrgs[0].Users) == 0 { diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index b72fcce9..365017a0 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -569,7 +569,7 @@ func handleGetWorkflowqueueConfirm(resp http.ResponseWriter, request *http.Reque // FIXME: Add authentication? id := request.Header.Get("Org-Id") if len(id) == 0 { - log.Printf("No Org-Id header set - confirm") + log.Printf("[ERROR] No Org-Id header set - confirm") resp.WriteHeader(401) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Specify the org-id header."}`))) return @@ -579,7 +579,7 @@ func handleGetWorkflowqueueConfirm(resp http.ResponseWriter, request *http.Reque ctx := context.Background() executionRequests, err := shuffle.GetWorkflowQueue(ctx, id) if err != nil { - log.Printf("(1) Failed reading body for workflowqueue: %s", err) + log.Printf("[WARNING] (1) Failed reading body for workflowqueue: %s", err) resp.WriteHeader(401) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Entity parsing error - confirm"}`))) return @@ -685,11 +685,65 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { return } + env, err := shuffle.GetEnvironment(ctx, id, "") + timeNow := time.Now().Unix() + if err == nil && len(env.Id) > 0 && len(env.Name) > 0 { + if time.Now().Unix() > env.Edited+60 { + log.Printf("[DEBUG] Updating env with IP %s!", request.RemoteAddr) + env.RunningIp = request.RemoteAddr + env.Checkin = timeNow + err = shuffle.SetEnvironment(ctx, env) + if err != nil { + log.Printf("[WARNING] Failed updating environment: %s", err) + } + } + } + + // Checking and updating the environment related to the first execution if len(executionRequests.Data) == 0 { executionRequests.Data = []shuffle.ExecutionRequest{} } else { - //log.Printf("[INFO] Executionrequests (%s): %d", id, len(executionRequests.Data)) - //log.Printf("IDS: %#v", executionRequests.Data[0].ExecutionId) + log.Printf("In workflowqueue with %d", len(executionRequests.Data)) + + // Try again :) + if len(env.Id) == 0 && len(env.Name) == 0 { + orgId := "" + for _, requestData := range executionRequests.Data { + execution, err := shuffle.GetWorkflowExecution(ctx, requestData.ExecutionId) + if err == nil { + if len(execution.ExecutionOrg) > 0 { + orgId = execution.ExecutionOrg + break + } + } + } + + if len(orgId) > 0 { + env, err := shuffle.GetEnvironment(ctx, id, orgId) + if err != nil { + log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", id, err) + //resp.WriteHeader(401) + //resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "No env found matching %s"}`, id))) + //return + } else { + log.Printf("Found Env: %#v", env) + if timeNow > env.Edited+60 { + log.Printf("Updating env with IP %s!", request.RemoteAddr) + env.RunningIp = request.RemoteAddr + env.Checkin = timeNow + err = shuffle.SetEnvironment(ctx, env) + if err != nil { + log.Printf("[WARNING] Failed updating environment: %s", err) + } + } + } + } + } + + if len(executionRequests.Data) > 10 { + executionRequests.Data = executionRequests.Data[0:9] + } + log.Printf("In workflowqueue with %d (2)", len(executionRequests.Data)) } newjson, err := json.Marshal(executionRequests) diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index 24bcef4d..1888e374 100644 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -2717,7 +2717,7 @@ const Admin = (props) => { style={{minWidth: 150, maxWidth: 150}} /> { primary="Archived" style={{minWidth: 150, maxWidth: 150}} /> + {environments === undefined || environments === null ? null : environments.map((environment, index)=> { if (!showArchived && environment.archived) { @@ -2747,19 +2751,19 @@ const Admin = (props) => { return null } - //var bgColor = "#27292d" - //if (index % 2 === 0) { - // bgColor = "#1f2023" - //} + var bgColor = "#27292d" + if (index % 2 === 0) { + bgColor = "#1f2023" + } return ( - + { style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}} primary={environment.archived.toString()} /> + ) })} @@ -2907,7 +2915,7 @@ const Admin = (props) => { style={{minWidth: 150, maxWidth: 150}} /> {