From 7cd2aa5146fb19aae50c2052eb6664c0e52d9091 Mon Sep 17 00:00:00 2001 From: Frikky Date: Thu, 24 Oct 2024 12:20:37 +0200 Subject: [PATCH] Added update_file() function to sdk --- backend/app_sdk/app_base.py | 19 +++++++++++++++++++ functions/onprem/orborus/orborus.go | 2 ++ 2 files changed, 21 insertions(+) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 7ce2da6c..680cfb0e 100755 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -1645,6 +1645,25 @@ class AppBase: #return value.json() return {"success": False} + def update_file(self, file_id, content): + full_execution = self.full_execution + workflow_id = full_execution["workflow"]["id"] + org_id = full_execution["workflow"]["execution_org"]["id"] + + new_headers = { + "Authorization": f"Bearer {self.authorization}", + "User-Agent": "Shuffle 1.1.0", + } + + upload_path = "/api/v1/files/%s/edit?execution_id=%s" % (file_id, full_execution["execution_id"]) + + files={"shuffle_file": ("filename", content)} + + ret = requests.put("%s%s" % (self.url, upload_path), files=files, headers=new_headers, verify=False, proxies=self.proxy_config) + print(ret.status_code) + return ret.json() + + # Wrapper for set_files def set_file(self, infiles): return self.set_files(infiles) diff --git a/functions/onprem/orborus/orborus.go b/functions/onprem/orborus/orborus.go index a97f3279..3246fb4a 100755 --- a/functions/onprem/orborus/orborus.go +++ b/functions/onprem/orborus/orborus.go @@ -3726,7 +3726,9 @@ func sendWorkerRequest(workflowExecution shuffle.ExecutionRequest, image string, newresp, err := client.Do(req) if err != nil { + // Connection refused? log.Printf("[ERROR] Error running worker request to %s (1): %s", streamUrl, err) + if strings.Contains(fmt.Sprintf("%s", err), "connection refused") || strings.Contains(fmt.Sprintf("%s", err), "EOF") { workerImage := fmt.Sprintf("%s/%s/shuffle-worker:%s", baseimageregistry, baseimagename, workerVersion)