Reduced execution bytesize

This commit is contained in:
frikky
2021-01-17 15:38:58 +01:00
parent 3b6501c56c
commit 38b454bc38
8 changed files with 94 additions and 16 deletions
+1 -1
View File
@@ -3535,7 +3535,7 @@ func handleWebhookCallback(resp http.ResponseWriter, request *http.Request) {
} }
for _, item := range hook.Workflows { for _, item := range hook.Workflows {
log.Printf("Running webhook for workflow %s with startnode %s", item, hook.Start) //log.Printf("Running webhook for workflow %s with startnode %s", item, hook.Start)
workflow := Workflow{ workflow := Workflow{
ID: "", ID: "",
} }
+12
View File
@@ -1727,6 +1727,7 @@ func setNewWorkflow(resp http.ResponseWriter, request *http.Request) {
action.IsValid = true action.IsValid = true
} }
action.LargeImage = ""
newActions = append(newActions, action) newActions = append(newActions, action)
} }
@@ -2797,7 +2798,18 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
if len(workflow.Actions) == 0 { if len(workflow.Actions) == 0 {
workflow.Actions = []Action{} workflow.Actions = []Action{}
} else {
newactions := []Action{}
for _, action := range workflow.Actions {
action.LargeImage = ""
action.SmallImage = ""
newactions = append(newactions, action)
log.Printf("ACTION: %#v", action)
}
workflow.Actions = newactions
} }
if len(workflow.Branches) == 0 { if len(workflow.Branches) == 0 {
workflow.Branches = []Branch{} workflow.Branches = []Branch{}
} }
+2 -2
View File
@@ -1,8 +1,8 @@
version: '3' version: '3'
services: services:
frontend: frontend:
build: ./frontend #build: ./frontend
image: ghcr.io/frikky/shuffle-frontend:0.8.52 image: ghcr.io/frikky/shuffle-frontend:0.8.51
container_name: shuffle-frontend container_name: shuffle-frontend
hostname: shuffle-frontend hostname: shuffle-frontend
ports: ports:
+22 -7
View File
@@ -4479,10 +4479,14 @@ const AngularWorkflow = (props) => {
setDestinationValue({}) setDestinationValue({})
}} }}
> >
<span style={{position: "absolute", bottom: 10, left: 10, color: "rgba(255,255,255,0.6)",}}>
Conditions can't be used for loops [ .# ] <a target="_blank" href="https://shuffler.io/docs/workflows#conditions" style={{textDecoration: "none", color: "#f85a3e"}}>Learn more</a>
</span>
<FormControl> <FormControl>
<DialogTitle><span style={{color:"white"}}>Condition</span> <DialogTitle><span style={{color:"white"}}>Condition</span>
</DialogTitle> </DialogTitle>
<DialogContent style={{}}> <DialogContent style={{}}>
<div style={{display: "flex"}}> <div style={{display: "flex"}}>
<Tooltip color="primary" title={conditionValue.configuration ? "Negated" : "Default"} placement="top"> <Tooltip color="primary" title={conditionValue.configuration ? "Negated" : "Default"} placement="top">
<Button color="primary" variant={conditionValue.configuration ? "contained" : "outlined"} style={{margin: "auto", height: 50, marginBottom: "auto", marginTop: "auto", marginRight: 5}} onClick={(e) => { <Button color="primary" variant={conditionValue.configuration ? "contained" : "outlined"} style={{margin: "auto", height: 50, marginBottom: "auto", marginTop: "auto", marginRight: 5}} onClick={(e) => {
@@ -4567,9 +4571,6 @@ const AngularWorkflow = (props) => {
</div> </div>
</div> </div>
<span style={{marginTop: 15}}>
Conditions can't be used for loops [ .# ]. <a target="_blank" href="https://shuffler.io/docs/conditions" style={{textDecoration: "none", color: "#f85a3e"}}>Learn more</a>
</span>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<Button <Button
@@ -6246,7 +6247,12 @@ const AngularWorkflow = (props) => {
if (validate.valid) { if (validate.valid) {
if (typeof(validate.result) === "string") { if (typeof(validate.result) === "string") {
validate.result = JSON.parse(validate.result) try {
validate.result = JSON.parse(validate.result)
} catch(e) {
console.log("Error: ", e)
validate.valid = false
}
} }
return ( return (
@@ -6514,10 +6520,19 @@ const AngularWorkflow = (props) => {
const curapp = apps.find(a => a.name === data.action.app_name && a.app_version === data.action.app_version) const curapp = apps.find(a => a.name === data.action.app_name && a.app_version === data.action.app_version)
const imgsize = 50 const imgsize = 50
const statusColor = data.status === "FINISHED" || data.status === "SUCCESS" ? "green" : data.status === "ABORTED" || data.status === "FAILURE" ? "red" : "orange" const statusColor = data.status === "FINISHED" || data.status === "SUCCESS" ? "green" : data.status === "ABORTED" || data.status === "FAILURE" ? "red" : "orange"
var imgSrc = curapp === undefined ? "" : curapp.large_image
if (imgSrc.length === 0) {
// Look for the node in the workflow
const action = workflow.actions.find(action => action.id === data.action.id)
if (action !== undefined && action !== null) {
imgSrc = action.large_image
}
}
var actionimg = curapp === null ? var actionimg = curapp === null ?
null : null :
<img alt={data.action.app_name} src={curapp === undefined ? "" : curapp.large_image} style={{marginRight: 20, width: imgsize, height: imgsize, border: `2px solid ${statusColor}`}} /> <img alt={data.action.app_name} src={imgSrc} style={{marginRight: 20, width: imgsize, height: imgsize, border: `2px solid ${statusColor}`}} />
if (triggers.length > 2) { if (triggers.length > 2) {
if (data.action.app_name === "shuffle-subflow") { if (data.action.app_name === "shuffle-subflow") {
@@ -7047,8 +7062,8 @@ const AngularWorkflow = (props) => {
console.log("FIELDS: ", newFields) console.log("FIELDS: ", newFields)
newAuthOption.fields = newFields newAuthOption.fields = newFields
setNewAppAuth(newAuthOption) setNewAppAuth(newAuthOption)
appAuthentication.push(newAuthOption) //appAuthentication.push(newAuthOption)
setAppAuthentication(appAuthentication) //setAppAuthentication(appAuthentication)
getAppAuthentication() getAppAuthentication()
setUpdate(authenticationOption.id) setUpdate(authenticationOption.id)
+1
View File
@@ -68,6 +68,7 @@ export const validateJson = (showResult) => {
} }
const result = jsonvalid ? JSON.parse(showResult) : showResult const result = jsonvalid ? JSON.parse(showResult) : showResult
//console.log("VALID: ", jsonvalid, result)
return { return {
"valid": jsonvalid, "valid": jsonvalid,
"result": result, "result": result,
@@ -0,0 +1,9 @@
GOOS=linux go build main.go
zip function.zip main
aws lambda update-function-code \
--function-name shuffler-forwarder \
--runtime go1.* \
--zip-file fileb://function.zip \
--handler main \
--role arn:aws:iam::123456789012:role/execution_role
+39
View File
@@ -25,6 +25,8 @@ import (
"github.com/satori/go.uuid" "github.com/satori/go.uuid"
//network "github.com/docker/docker/api/types/network" //network "github.com/docker/docker/api/types/network"
//natting "github.com/docker/go-connections/nat" //natting "github.com/docker/go-connections/nat"
"github.com/mackerelio/go-osstat/cpu"
"github.com/mackerelio/go-osstat/memory"
) )
// Starts jobs in bulk, so this could be increased // Starts jobs in bulk, so this could be increased
@@ -297,6 +299,41 @@ func initializeImages() {
} }
} }
// Will be used for checking if there's enough to deploy based on a threshold
// E.g. having maximum CPU and maxmimum RAM
// Does this work containerized?
func getStats() {
fmt.Printf("\n")
memory, err := memory.Get()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
return
}
fmt.Printf("[INFO] memory total: %d bytes\n", memory.Total)
fmt.Printf("[INFO] memory used: %d bytes\n", memory.Used)
before, err := cpu.Get()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
return
}
time.Sleep(time.Duration(500) * time.Millisecond)
after, err := cpu.Get()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
return
}
total := float64(after.Total - before.Total)
fmt.Printf("[INFO] cpu used : %f%%\n", float64(after.User-before.User)/total*100)
fmt.Printf("[INFO] cpu system: %f%%\n", float64(after.System-before.System)/total*100)
fmt.Printf("[INFO] cpu idle : %f%%\n", float64(after.Idle-before.Idle)/total*100)
fmt.Printf("\n")
}
// Initial loop etc // Initial loop etc
func main() { func main() {
log.Println("[INFO] Setting up execution environment") log.Println("[INFO] Setting up execution environment")
@@ -371,6 +408,8 @@ func main() {
}, },
} }
getStats()
if (len(httpProxy) > 0 || len(httpsProxy) > 0) && baseUrl != "http://shuffle-backend:5001" { if (len(httpProxy) > 0 || len(httpsProxy) > 0) && baseUrl != "http://shuffle-backend:5001" {
client = &http.Client{} client = &http.Client{}
} else { } else {
+8 -6
View File
@@ -839,9 +839,10 @@ func shutdown(executionId, workflowId string) {
log.Printf("[INFO] Failed abort request: %s", err) log.Printf("[INFO] Failed abort request: %s", err)
} }
log.Printf("[INFO] Finished shutdown (after 15 seconds).") sleepDuration := 0
log.Printf("[INFO] Finished shutdown (after %d seconds).", sleepDuration)
// Allows everything to finish in subprocesses // Allows everything to finish in subprocesses
time.Sleep(time.Duration(15) * time.Second) time.Sleep(time.Duration(sleepDuration) * time.Second)
os.Exit(3) os.Exit(3)
} }
@@ -862,9 +863,10 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
log.Printf("[WARNING] Empty self container id, continue without NetworkMode") log.Printf("[WARNING] Empty self container id, continue without NetworkMode")
} }
if cleanupEnv == "true" { // Removing because log extraction should happen first
hostConfig.AutoRemove = true //if cleanupEnv == "true" {
} // hostConfig.AutoRemove = true
//}
config := &container.Config{ config := &container.Config{
Image: image, Image: image,
@@ -892,7 +894,7 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
return err return err
} }
log.Printf("[INFO] Container %s is created for %s", cont.ID, identifier) log.Printf("[INFO] Container %s was created for %s", cont.ID, identifier)
containerIds = append(containerIds, cont.ID) containerIds = append(containerIds, cont.ID)
return nil return nil
} }