Greatly increased execution speed

This commit is contained in:
frikky
2020-05-20 07:38:06 +02:00
parent 07237fb257
commit 5d092ddd41
7 changed files with 55 additions and 29 deletions
-1
View File
@@ -1790,7 +1790,6 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
}
if len(workflowExecution.ExecutionId) == 0 {
log.Println("Making new executionId!")
sessionToken := uuid.NewV4()
workflowExecution.ExecutionId = sessionToken.String()
} else {
+28 -9
View File
@@ -160,7 +160,7 @@ const AngularWorkflow = (props) => {
const [elements, setElements] = useState([])
const { start, stop } = useInterval({
duration: 5000,
duration: 2500,
startImmediate: false,
callback: () => {
fetchUpdates()
@@ -285,6 +285,7 @@ const AngularWorkflow = (props) => {
currentnode = currentnode[0]
const outgoingEdges = currentnode.outgoers('edge')
const incomingEdges = currentnode.incomers('edge')
console.log("NODE: ", currentnode)
//currentnode.removeClass('success-highlight failure-highlight executing-highlight')
switch (item.status) {
@@ -335,7 +336,19 @@ const AngularWorkflow = (props) => {
// FIXME - add outgoing nodes to executing
//const outgoingNodes = outgoingEdges.find().data().target
if (outgoingEdges.length > 0) {
outgoingEdges.addClass('success-highlight')
for (var i = 0; i < outgoingEdges.length; i++) {
const edge = outgoingEdges[i]
const targetnode = cy.getElementById(edge.data().target)
if (targetnode !== undefined && !targetnode.classes().includes("success-highlight") && !targetnode.classes().includes("failure-highlight")) {
targetnode.removeClass('not-executing-highlight')
targetnode.removeClass('success-highlight')
targetnode.removeClass('failure-highlight')
targetnode.removeClass('awaiting-data-highlight')
targetnode.addClass('executing-highlight')
}
}
// const outgoingEdges = currentnode.outgoers('edge')
}
break
case "FAILURE":
@@ -359,6 +372,7 @@ const AngularWorkflow = (props) => {
currentnode.addClass('awaiting-data-highlight')
break
default:
console.log("DEFAULT?")
break
}
}
@@ -501,6 +515,7 @@ const AngularWorkflow = (props) => {
cy.elements().removeClass('success-highlight failure-highlight executing-highlight')
firstnode[0].addClass('executing-highlight')
return true
}
@@ -730,8 +745,13 @@ const AngularWorkflow = (props) => {
}
const onEdgeSelect = (event) => {
setSelectedEdgeIndex(workflow.branches.findIndex(data => data.id === event.target.data()["id"]))
setSelectedEdge(event.target.data())
const triggercheck = workflow.triggers.find(trigger => trigger.id === event.target.data()["source"])
if (triggercheck === undefined) {
setSelectedEdgeIndex(workflow.branches.findIndex(data => data.id === event.target.data()["id"]))
setSelectedEdge(event.target.data())
} else {
alert.info("Can't edit branches from triggers")
}
}
const onNodeSelect = (event) => {
@@ -759,14 +779,13 @@ const AngularWorkflow = (props) => {
env = environments[0]
}
console.log(curapp)
console.log("Selected: ", data.id)
setRequiresAuthentication(curapp.authentication.required)
setSelectedApp(curapp)
setSelectedActionEnvironment(env)
setSelectedActionName(curaction.name)
setSelectedAction(curaction)
console.timeEnd("ACTIONSTART")
} else if (data.type === "TRIGGER") {
//console.log("Should handle trigger "+data.triggertype)
//console.log(data)
@@ -1626,6 +1645,8 @@ const AngularWorkflow = (props) => {
<img alt="" style={{width: "80px"}} />
:
<img alt="" src={trigger.large_image} style={{width: 80, height: 80}} />
const color = trigger.is_valid ? "green" : "orange"
return(
<Draggable
onDrag={(e) => {handleTriggerDrag(e, trigger)}}
@@ -1637,7 +1658,7 @@ const AngularWorkflow = (props) => {
}}
>
<Paper square style={paperAppStyle} onClick={() => {}}>
<div style={{marginLeft: "10px", marginTop: "5px", marginBottom: "5px", width: "2px", backgroundColor: "orange", marginRight: "5px"}}>
<div style={{marginLeft: "10px", marginTop: "5px", marginBottom: "5px", width: "2px", backgroundColor: color, marginRight: "5px"}}>
</div>
<Grid container style={{margin: "10px 10px 10px 10px", flex: "10"}}>
<Grid item>
@@ -2235,7 +2256,6 @@ const AngularWorkflow = (props) => {
// Remap data based on variant
if (data.variant === "STATIC_VALUE") {
staticcolor = "#f85a3e"
console.log("DATA IS STATIC")
} else if (data.variant === "ACTION_RESULT") {
// Gets the parents of the current node
var parents = getParents(selectedAction)
@@ -2706,7 +2726,6 @@ const AngularWorkflow = (props) => {
placeholder={placeholder}
onClick={() => {
console.log("CHANGE FIELD")
setMultiline(!multiline)
}}
onBlur={(e) => {
changeActionVariable(data.action_field, e.target.value)
+1
View File
@@ -39,6 +39,7 @@ import { positions, Provider } from "react-alert";
// Testing - localhost
//const globalUrl = "http://192.168.3.6:5001"
//console.log("HOST: ", process.env)
// Production - backend proxy forwarding in nginx
+3 -2
View File
@@ -114,8 +114,8 @@ const data = [{
{
selector: '.success-highlight',
css: {
'background-color': '#399645',
'border-color': '#399645',
'background-color': '#41dcab',
'border-color': '#41dcab',
'border-width': '5px',
'transition-property': 'background-color',
'transition-duration': '0.5s',
@@ -136,6 +136,7 @@ const data = [{
css: {
'background-color': 'grey',
'border-color': 'grey',
'border-width': '5px',
'transition-property': '#ffef47',
'transition-duration': '0.25s',
},
+5 -1
View File
@@ -29,6 +29,11 @@ var baseimagename = "frikky/shuffle"
var dockerApiVersion = os.Getenv("DOCKER_API_VERSION")
var environment = os.Getenv("ENVIRONMENT_NAME")
var orgId = os.Getenv("ORG_ID")
// Starts jobs in bulk, so this could be increased
var sleepTime = 3
// Timeout if somethinc rashes
var workerTimeout = 600
type ExecutionRequestWrapper struct {
@@ -173,7 +178,6 @@ func main() {
log.Printf("--- Finished configuring docker environment ---\n")
// FIXME - time limit
sleepTime := 10
client := &http.Client{}
fullUrl := fmt.Sprintf("%s/api/v1/workflows/queue", baseUrl)
Binary file not shown.
+18 -16
View File
@@ -22,6 +22,7 @@ import (
var environment = os.Getenv("ENVIRONMENT_NAME")
var baseUrl = os.Getenv("BASE_URL")
var baseimagename = "frikky/shuffle"
var sleepTime = 2
type Condition struct {
AppName string `json:"app_name"`
@@ -210,11 +211,11 @@ type WorkflowAppAction struct {
}
// removes every container except itself (worker)
func shutdown(executionId string) {
func shutdown(executionId, workflowId string) {
dockercli, err := dockerclient.NewEnvClient()
if err != nil {
log.Printf("Unable to create docker client: %s", err)
shutdown(executionId)
os.Exit(3)
}
containerOptions := types.ContainerListOptions{
@@ -243,9 +244,9 @@ func shutdown(executionId string) {
}
// FIXME: Add an API call to the backend
workflowid := "d0496ad4-d682-4506-bbf9-f926358a4b2a"
fullUrl := fmt.Sprintf("%s/api/v1/workflows/%s/executions/%s/abort", baseUrl, workflowid, executionId)
log.Printf("ShutdownURL: %s", fullUrl)
// fmt.Sprintf("AUTHORIZATION=%s", workflowExecution.Authorization),
fullUrl := fmt.Sprintf("%s/api/v1/workflows/%s/executions/%s/abort", baseUrl, workflowId, executionId)
req, err := http.NewRequest(
"GET",
fullUrl,
@@ -256,6 +257,8 @@ func shutdown(executionId string) {
log.Println("Failed building request: %s", err)
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", authorization)
client := &http.Client{}
_, err = client.Do(req)
if err != nil {
@@ -339,12 +342,11 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
dockercli, err := dockerclient.NewEnvClient()
if err != nil {
log.Printf("Unable to create docker client: %s", err)
shutdown(workflowExecution.ExecutionId)
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
onpremApps := []string{}
startAction := workflowExecution.Workflow.Start
sleepTime := 5
toExecuteOnprem := []string{}
parents := map[string][]string{}
children := map[string][]string{}
@@ -614,13 +616,13 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
if workflowExecution.Status == "FINISHED" || workflowExecution.Status == "SUCCESS" {
log.Printf("Workflow %s is finished. Exiting worker.", workflowExecution.ExecutionId)
shutdown(workflowExecution.ExecutionId)
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
log.Printf("Status: %s, Results: %d, actions: %d", workflowExecution.Status, len(workflowExecution.Results), len(workflowExecution.Workflow.Actions))
if workflowExecution.Status != "EXECUTING" {
log.Printf("Exiting as worker execution has status %s!", workflowExecution.Status)
shutdown(workflowExecution.ExecutionId)
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
if len(workflowExecution.Results) == len(workflowExecution.Workflow.Actions) {
@@ -689,7 +691,7 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
if shutdownCheck {
log.Println("BREAKING BECAUSE RESULTS IS SAME LENGTH AS ACTIONS. SHOULD CHECK ALL RESULTS FOR WHETHER THEY'RE DONE")
shutdown(workflowExecution.ExecutionId)
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
}
time.Sleep(time.Duration(sleepTime) * time.Second)
@@ -740,12 +742,12 @@ func main() {
if len(authorization) == 0 {
log.Println("No AUTHORIZATION key set in env")
shutdown(executionId)
shutdown(executionId, "")
}
if len(executionId) == 0 {
log.Println("No EXECUTIONID key set in env")
shutdown(executionId)
shutdown(executionId, "")
}
// FIXME - tmp
@@ -759,7 +761,7 @@ func main() {
if err != nil {
log.Println("Failed making request builder")
shutdown(executionId)
shutdown(executionId, "")
}
for {
@@ -793,7 +795,7 @@ func main() {
if workflowExecution.Status == "FINISHED" || workflowExecution.Status == "SUCCESS" {
log.Printf("Workflow %s is finished. Exiting worker.", workflowExecution.ExecutionId)
shutdown(executionId)
shutdown(executionId, workflowExecution.Workflow.ID)
}
if workflowExecution.Status == "EXECUTING" || workflowExecution.Status == "RUNNING" {
@@ -801,11 +803,11 @@ func main() {
err = handleExecution(client, req, workflowExecution)
if err != nil {
log.Printf("Workflow %s is finished: %s", workflowExecution.ExecutionId, err)
shutdown(executionId)
shutdown(executionId, workflowExecution.Workflow.ID)
}
} else {
log.Printf("Workflow %s has status %s. Exiting worker.", workflowExecution.ExecutionId, workflowExecution.Status)
shutdown(executionId)
shutdown(executionId, workflowExecution.Workflow.ID)
}
//log.Println(string(body))