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