From 1aef4d2dbb1e869e7a26e1eaa186c6f0eac3da78 Mon Sep 17 00:00:00 2001 From: Frikky Date: Wed, 6 Dec 2023 17:11:42 +0100 Subject: [PATCH] Appbase change to handle exits when retries and timeouts happen, as these are expected from worker -> app --- backend/app_sdk/app_base.py | 11 +++++++++++ backend/go-app/main.go | 5 ++++- functions/onprem/orborus/orborus.go | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index a5467f76..291f3d22 100755 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -528,6 +528,17 @@ class AppBase: self.logger.info(f"[DEBUG] Request problem: {e}") time.sleep(sleeptime) + # Check if we have a read timeout. If we do, exit as we most likely sent the result without getting a good result + if "Read timed out" in str(e): + self.logger.warning(f"[WARNING] Read timed out: {e}") + finished = True + break + + if "Max retries exceeded with url" in str(e): + self.logger.warning(f"[WARNING] Max retries exceeded with url: {e}") + finished = True + break + #time.sleep(5) continue except TimeoutError as e: diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 9717d6d3..0d0f2f0f 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -3660,7 +3660,6 @@ func runInitEs(ctx context.Context) { log.Printf("Successfully updated org to have users!") } } - } } } @@ -3693,6 +3692,10 @@ func runInitEs(ctx context.Context) { orgId = activeOrgs[0].Id } + if len(schedule.Org) == 36 { + orgId = schedule.Org + } + _, _, err := handleExecution(schedule.WorkflowId, shuffle.Workflow{}, request, orgId) if err != nil { log.Printf("[WARNING] Failed to execute %s: %s", schedule.WorkflowId, err) diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index b47d11e9..25023273 100755 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -1406,7 +1406,7 @@ func main() { // Should find data to send (memory etc.) // Create timeout of max 4 seconds just in case - ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() // Marshal and set body