diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index c1ddb498..473d2e1f 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -728,7 +728,6 @@ class AppBase: allvalues["value"] = parsedvalue except: print("Parsing of value as JSON failed") - return {"success": False} return allvalues except: @@ -1362,12 +1361,25 @@ class AppBase: appendresult += char actionname_lower = "exec" + elif actionname_lower.startswith("shuffle_cache "): + actionname_lower = "shuffle_cache" actionname_lower = actionname_lower.replace(" ", "_", -1) try: if actionname_lower == "exec" or actionname_lower == "webhook" or actionname_lower == "schedule" or actionname_lower == "userinput" or actionname_lower == "email_trigger" or actionname_lower == "trigger": baseresult = execution_data["execution_argument"] + elif actionname_lower == "shuffle_cache": + print("SHOULD GET CACHE KEY: %s" % parsersplit) + if len(parsersplit) > 1: + actual_key = parsersplit[1] + print("KEY: %s" % actual_key) + cachedata = self.get_cache(actual_key) + print("CACHE: %s" % cachedata) + parsersplit.pop(1) + baseresult = cachedata + + #returndata = str(baseresult)+str(appendresult) else: #print("Within execution data check. Execution data: %s", execution_data["results"]) if execution_data["results"] != None: diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index facd92e4..50c3f2da 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -24,7 +24,7 @@ require ( github.com/elastic/go-elasticsearch/v7 v7.12.0 // indirect github.com/elastic/go-elasticsearch/v8 v8.0.0-20210519083322-55daf7425ecb // indirect github.com/frikky/kin-openapi v0.39.0 - github.com/frikky/shuffle-shared v0.0.56 + github.com/frikky/shuffle-shared v0.0.57 github.com/fsouza/go-dockerclient v1.7.2 // indirect github.com/ghodss/yaml v1.0.0 github.com/go-git/go-billy/v5 v5.0.0 diff --git a/backend/go-app/go.sum b/backend/go-app/go.sum index a2728936..712aabf3 100644 --- a/backend/go-app/go.sum +++ b/backend/go-app/go.sum @@ -169,6 +169,8 @@ github.com/frikky/shuffle-shared v0.0.54 h1:rc8JcavY6uDxaIkXFwLVotfv3/epXUzuCWzR github.com/frikky/shuffle-shared v0.0.54/go.mod h1:BknTfpun3qte5bumR3OqQHf9XWPIsyj8woiXCjIlbBc= github.com/frikky/shuffle-shared v0.0.56 h1:stC793SdQeBh98yJqCL74aXFo9YYhVIg8CQJ7hm4d6o= github.com/frikky/shuffle-shared v0.0.56/go.mod h1:BknTfpun3qte5bumR3OqQHf9XWPIsyj8woiXCjIlbBc= +github.com/frikky/shuffle-shared v0.0.57 h1:YDlOVjg8bUBcinehcmorxzOoV5O55oUfG8q7TOiBOeU= +github.com/frikky/shuffle-shared v0.0.57/go.mod h1:BknTfpun3qte5bumR3OqQHf9XWPIsyj8woiXCjIlbBc= github.com/fsouza/go-dockerclient v1.7.2 h1:bBEAcqLTkpq205jooP5RVroUKiVEWgGecHyeZc4OFjo= github.com/fsouza/go-dockerclient v1.7.2/go.mod h1:+ugtMCVRwnPfY7d8/baCzZ3uwB0BrG5DB8OzbtxaRz8= github.com/getkin/kin-openapi v0.8.0 h1:a6TQjTqwkyscC4/hShJX7WhCVE+4bi9lzw61XHQW5hE= diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index 899e40d5..480ea228 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -971,7 +971,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl } //log.Printf("BASE LENGTH: %d", len(workflowExecution.Results)) - workflowExecution, dbSave, err := shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult) + workflowExecution, dbSave, err := shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult, false) if err != nil { log.Printf("[ERROR] Failed execution of parsedexecution: %s", err) resp.WriteHeader(401) diff --git a/functions/onprem/worker/go.mod b/functions/onprem/worker/go.mod index ba5bbeea..31879e60 100644 --- a/functions/onprem/worker/go.mod +++ b/functions/onprem/worker/go.mod @@ -13,7 +13,7 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect github.com/elastic/go-elasticsearch/v8 v8.0.0-20210531084204-f01628963386 // indirect - github.com/frikky/shuffle-shared v0.0.56 + github.com/frikky/shuffle-shared v0.0.59 github.com/fsouza/go-dockerclient v1.7.2 github.com/go-git/go-billy/v5 v5.3.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -23,6 +23,5 @@ require ( github.com/opencontainers/image-spec v1.0.1 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect google.golang.org/grpc v1.37.1 // indirect ) diff --git a/functions/onprem/worker/worker.go b/functions/onprem/worker/worker.go index 621035d9..862fcd54 100644 --- a/functions/onprem/worker/worker.go +++ b/functions/onprem/worker/worker.go @@ -518,7 +518,7 @@ func removeIndex(s []string, i int) []string { } func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) { - log.Printf("Inside execution results with %d / %d results", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)) + log.Printf("[INFO] Inside execution results with %d / %d results", len(workflowExecution.Results), len(workflowExecution.Workflow.Actions)) if len(startAction) == 0 { startAction = workflowExecution.Start if len(startAction) == 0 { @@ -567,7 +567,7 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) { if isSkipped { //log.Printf("Skipping %s as all parents are done", item.Action.Label) if !arrayContains(visited, item.Action.ID) { - log.Printf("[INFO] Adding visited (1): %s", item.Action.Label) + log.Printf("[INFO] Adding visited (1): %s\n", item.Action.Label) visited = append(visited, item.Action.ID) } } else { @@ -576,7 +576,7 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) { } } else { if item.Status == "FINISHED" { - log.Printf("[INFO] Adding visited (2): %s", item.Action.Label) + log.Printf("[INFO] Adding visited (2): %s\n", item.Action.Label) visited = append(visited, item.Action.ID) } } @@ -1100,7 +1100,7 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) { } } - log.Printf("[INFO] Adding visited (3): %s", action.Label) + log.Printf("[INFO] Adding visited (3): %s\n", action.Label) visited = append(visited, action.ID) executed = append(executed, action.ID) @@ -1553,12 +1553,36 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl resultLength := len(workflowExecution.Results) setExecution := true - workflowExecution, dbSave, err := shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult) + workflowExecution, dbSave, err := shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult, true) if err != nil { - log.Printf("[ERROR] Failed execution of parsedexecution: %s", err) - resp.WriteHeader(401) - resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed getting execution"}`))) - return + log.Printf("[DEBUG] Rerunning transaction? %s", err) + if strings.Contains(fmt.Sprintf("%s", err), "Rerun this transaction") { + workflowExecution, err := getWorkflowExecution(ctx, workflowExecutionId) + if err != nil { + log.Printf("[ERROR] Failed getting execution cache (2): %s", err) + resp.WriteHeader(401) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed getting execution (2)"}`))) + return + } + + resultLength = len(workflowExecution.Results) + setExecution = true + + workflowExecution, dbSave, err = shuffle.ParsedExecutionResult(ctx, *workflowExecution, actionResult, false) + if err != nil { + log.Printf("[ERROR] Failed execution of parsedexecution (2): %s", err) + resp.WriteHeader(401) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed getting execution (2)"}`))) + return + } else { + log.Printf("[DEBUG] Successfully got ParsedExecution with %d results!", len(workflowExecution.Results)) + } + } else { + log.Printf("[ERROR] Failed execution of parsedexecution: %s", err) + resp.WriteHeader(401) + resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Failed getting execution"}`))) + return + } } //log.Printf(`[INFO] Got result %s from %s`, actionResult.Status, actionResult.Action.ID) //dbSave := false