From f663969d5820caab09db5f51fb5f397054d07d54 Mon Sep 17 00:00:00 2001 From: frikky Date: Fri, 19 Feb 2021 18:43:22 +0100 Subject: [PATCH] #223: Added subflow tracking features --- backend/app_sdk/app_base.py | 8 +++++-- backend/go-app/walkoff.go | 33 ++++++++++++++++++++++---- frontend/src/views/AngularWorkflow.jsx | 24 ++++++++++++------- functions/onprem/orborus/orborus.go | 2 +- functions/onprem/worker/build.sh | 2 +- functions/onprem/worker/worker.go | 15 ++++++++++-- 6 files changed, 65 insertions(+), 19 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index ba35c635..3c39976a 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -8,6 +8,7 @@ import logging import requests import urllib.parse import http.client +import urllib3 class AppBase: __version__ = None @@ -66,7 +67,7 @@ class AppBase: self.logger.info(ret.text) except requests.exceptions.ConnectionError as e: #self.logger.exception("ConnectionError: %s" % e) - self.logger.exception("Expected ConnectionError happened") + self.logger.info("Expected ConnectionError happened") return except TypeError as e: #self.logger.exception(e) @@ -78,7 +79,10 @@ class AppBase: if ret.status_code != 200: self.logger.info(ret.text) except http.client.RemoteDisconnected as e: - self.logger.exception("Expected Remotedisconnect happened") + self.logger.info("Expected Remotedisconnect happened") + return + except urllib3.exceptions.ProtocolError as e: + self.logger.info("Expected ProtocolError happened") return async def cartesian_product(self, L): diff --git a/backend/go-app/walkoff.go b/backend/go-app/walkoff.go index f3103954..9efbcd66 100644 --- a/backend/go-app/walkoff.go +++ b/backend/go-app/walkoff.go @@ -270,6 +270,7 @@ type WorkflowExecution struct { ExecutionArgument string `json:"execution_argument" datastore:"execution_argument,noindex"` ExecutionId string `json:"execution_id" datastore:"execution_id"` ExecutionSource string `json:"execution_source" datastore:"execution_source"` + ExecutionParent string `json:"execution_parent" datastore:"execution_parent"` ExecutionOrg string `json:"execution_org" datastore:"execution_org"` WorkflowId string `json:"workflow_id" datastore:"workflow_id"` LastNode string `json:"last_node" datastore:"last_node"` @@ -2410,7 +2411,7 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) { workflow.Actions = newActions newTriggers := []Trigger{} for _, trigger := range workflow.Triggers { - log.Printf("Trigger %s: %s", trigger.TriggerType, trigger.Status) + log.Printf("[INFO] Trigger %s: %s", trigger.TriggerType, trigger.Status) // Check if it's actually running // FIXME: Do this for other triggers too @@ -3135,12 +3136,34 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf // This one doesn't really matter. log.Printf("[INFO] Running POST execution with body of length %d", len(string(body))) - if body[0] == 34 && body[len(body)-1] == 34 { - body = body[1 : len(body)-1] + + if len(body) >= 4 { + if body[0] == 34 && body[len(body)-1] == 34 { + body = body[1 : len(body)-1] + } + if body[0] == 34 && body[len(body)-1] == 34 { + body = body[1 : len(body)-1] + } } - if body[0] == 34 && body[len(body)-1] == 34 { - body = body[1 : len(body)-1] + + //workflowExecution.ExecutionSource = "default" + sourceWorkflow, sourceWorkflowOk := request.URL.Query()["source_workflow"] + if sourceWorkflowOk { + //log.Printf("Got source workflow %s", sourceWorkflow) + workflowExecution.ExecutionSource = sourceWorkflow[0] + } else { + //log.Printf("Did NOT get source workflow") + } + + sourceExecution, sourceExecutionOk := request.URL.Query()["source_execution"] + if sourceExecutionOk { + log.Printf("Got source execution%s", sourceExecution) + workflowExecution.ExecutionParent = sourceExecution[0] + } else { + //log.Printf("Did NOT get source execution") + } + if len(string(body)) < 50 { //log.Println(body) // String in string diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 715f8bb0..59cbd2ca 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -5175,7 +5175,7 @@ const AngularWorkflow = (props) => { })} } - {/*subworkflow === undefined || subworkflow === null || subworkflow.id === undefined || subworkflow.actions === null || subworkflow.actions === undefined || subworkflow.actions.length === 0 ? null : + {subworkflow === undefined || subworkflow === null || subworkflow.id === undefined || subworkflow.actions === null || subworkflow.actions === undefined || subworkflow.actions.length === 0 ? null : - */} - {workflow.triggers[selectedTriggerIndex].parameters[0].value.length === 0 ? null : Explore selected workflow} + } + {workflow.triggers[selectedTriggerIndex].parameters[0].value.length === 0 ? null : Explore selected workflow}
@@ -6400,6 +6400,9 @@ const AngularWorkflow = (props) => { return {"email"} trigger.trigger_type === "EMAIL").large_image} style={{width: size, height: size}} /> } + if (execution.execution_parent !== null && execution.execution_parent !== undefined && execution.execution_parent.length > 0) { + return {"parent trigger.trigger_type === "SUBFLOW").large_image} style={{width: size, height: size}} /> + } return ( {execution.execution_source} @@ -6564,7 +6567,7 @@ const AngularWorkflow = (props) => { - +

Executing Workflow

@@ -6580,19 +6583,23 @@ const AngularWorkflow = (props) => {
{executionData.status !== undefined && executionData.status.length > 0 ?
- Status: {executionData.status} + Status:   {executionData.status}
: null } {executionData.execution_source !== undefined && executionData.execution_source !== null && executionData.execution_source.length > 0 && executionData.execution_source !== "default" ?
- Source: {executionData.execution_source} + Source:   {executionData.execution_parent !== null && executionData.execution_parent !== undefined && executionData.execution_parent.length > 0 ? + Parent Workflow + : + executionData.execution_source + }
: null } {executionData.started_at !== undefined ?
- Started: {new Date(executionData.started_at*1000).toISOString()} + Started:  {new Date(executionData.started_at*1000).toISOString()}
: null } @@ -6602,10 +6609,11 @@ const AngularWorkflow = (props) => {
: null } +
{executionData.execution_argument !== undefined && executionData.execution_argument.length > 0 ? parsedExecutionArgument() : null } - + {executionData.results !== undefined && executionData.results !== null && executionData.results.length > 1 && executionData.results.find(result => result.status === "SKIPPED" || result.status === "FAILURE") ?