#312: Added delayed action execution to open source version
This commit is contained in:
@@ -22,7 +22,7 @@ require (
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/h2non/filetype v1.1.1
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/shuffle/shuffle-shared v0.1.72
|
||||
github.com/shuffle/shuffle-shared v0.1.73
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
||||
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
version: '3'
|
||||
services:
|
||||
frontend:
|
||||
#build: ./frontend
|
||||
build: ./frontend
|
||||
image: ghcr.io/frikky/shuffle-frontend:nightly
|
||||
container_name: shuffle-frontend
|
||||
hostname: shuffle-frontend
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
depends_on:
|
||||
- backend
|
||||
backend:
|
||||
#build: ./backend
|
||||
build: ./backend
|
||||
image: ghcr.io/frikky/shuffle-backend:nightly
|
||||
container_name: shuffle-backend
|
||||
hostname: ${BACKEND_HOSTNAME}
|
||||
|
||||
@@ -2410,7 +2410,7 @@ const ParsedAction = (props) => {
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{!isCloud ? null :
|
||||
{/*!isCloud ? null :*/}
|
||||
<div style={{flex: 1, marginLeft: 5,}}>
|
||||
<Tooltip
|
||||
color="primary"
|
||||
@@ -2442,7 +2442,7 @@ const ParsedAction = (props) => {
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
}
|
||||
{/**/}
|
||||
</div>
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -7783,7 +7783,6 @@ const AngularWorkflow = (defaultprops) => {
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{!isCloud ? null :
|
||||
<div style={{flex: 1, marginLeft: 5,}}>
|
||||
<Tooltip
|
||||
color="primary"
|
||||
@@ -7825,7 +7824,6 @@ const AngularWorkflow = (defaultprops) => {
|
||||
</span>
|
||||
</Tooltip>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<FormControlLabel
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
NAME=shuffle-orborus
|
||||
VERSION=0.9.46
|
||||
VERSION=0.9.48
|
||||
|
||||
echo "Running docker build with $NAME:$VERSION"
|
||||
#docker rmi frikky/shuffle:$NAME --force
|
||||
|
||||
@@ -8,5 +8,5 @@ require (
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/mackerelio/go-osstat v0.2.1
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/shuffle/shuffle-shared v0.1.30
|
||||
github.com/shuffle/shuffle-shared v0.1.73
|
||||
)
|
||||
|
||||
@@ -565,6 +565,8 @@ github.com/shuffle/shuffle-shared v0.1.26 h1:NlUlUrA/wNLwo49Id5SKhBlLhuizjy/T2rq
|
||||
github.com/shuffle/shuffle-shared v0.1.26/go.mod h1:0QrK51T12CpCj/be8hXduj/RtDnoeaZ3rfogELZE2IU=
|
||||
github.com/shuffle/shuffle-shared v0.1.30 h1:YFEVVw6ENl1GxN4hVndSrbLXeIVM9JtcPqoJKDyqYqM=
|
||||
github.com/shuffle/shuffle-shared v0.1.30/go.mod h1:0QrK51T12CpCj/be8hXduj/RtDnoeaZ3rfogELZE2IU=
|
||||
github.com/shuffle/shuffle-shared v0.1.73 h1:1rMOXAvxm/nDemwN/L8qWacswVMvdi6NjLfTTmptP4I=
|
||||
github.com/shuffle/shuffle-shared v0.1.73/go.mod h1:2ndjLm4ZOvY6arGFwOgGnkQ457Ke7gka9HDF/EkdIxQ=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
@@ -575,6 +577,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
NAME=shuffle-worker
|
||||
VERSION=0.9.47
|
||||
VERSION=0.9.48
|
||||
|
||||
echo "Running docker build with $NAME:$VERSION"
|
||||
#CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o worker.bin .
|
||||
|
||||
@@ -10,6 +10,6 @@ require (
|
||||
github.com/docker/go-connections v0.4.0 // indirect
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/shuffle/shuffle-shared v0.1.72
|
||||
github.com/shuffle/shuffle-shared v0.1.73
|
||||
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
|
||||
)
|
||||
|
||||
@@ -582,6 +582,10 @@ github.com/shuffle/shuffle-shared v0.1.60 h1:Jjb6TfE/KnVfCryIL2vtRHBnBX307slVlGB
|
||||
github.com/shuffle/shuffle-shared v0.1.60/go.mod h1:2ndjLm4ZOvY6arGFwOgGnkQ457Ke7gka9HDF/EkdIxQ=
|
||||
github.com/shuffle/shuffle-shared v0.1.68 h1:xneGx6ZBU9hgIPt3W6pMUIoTZDxNJbOX/cKhndoVu3Y=
|
||||
github.com/shuffle/shuffle-shared v0.1.68/go.mod h1:2ndjLm4ZOvY6arGFwOgGnkQ457Ke7gka9HDF/EkdIxQ=
|
||||
github.com/shuffle/shuffle-shared v0.1.72 h1:7KHpvml+96sMOINEw3PmSAN6WS22ovXGj6WgV7MW/k4=
|
||||
github.com/shuffle/shuffle-shared v0.1.72/go.mod h1:2ndjLm4ZOvY6arGFwOgGnkQ457Ke7gka9HDF/EkdIxQ=
|
||||
github.com/shuffle/shuffle-shared v0.1.73 h1:1rMOXAvxm/nDemwN/L8qWacswVMvdi6NjLfTTmptP4I=
|
||||
github.com/shuffle/shuffle-shared v0.1.73/go.mod h1:2ndjLm4ZOvY6arGFwOgGnkQ457Ke7gka9HDF/EkdIxQ=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
|
||||
|
||||
@@ -270,11 +270,25 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
||||
return err
|
||||
}
|
||||
|
||||
//log.Printf("[DEBUG][%s] Should run towards port %d for app %s", workflowExecution.ExecutionId, exposedPort, appName)
|
||||
err = sendAppRequest(baseUrl, appName, exposedPort, action, workflowExecution)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed sending request to app %s on port %d: %s", appName, exposedPort, err)
|
||||
return err
|
||||
log.Printf("[DEBUG][%s] Should run towards port %d for app %s. DELAY: %d", workflowExecution.ExecutionId, exposedPort, appName, action.ExecutionDelay)
|
||||
if action.ExecutionDelay > 0 {
|
||||
//log.Printf("[DEBUG] Running app %s with delay of %d", action.Name, action.ExecutionDelay)
|
||||
waitTime := time.Duration(action.ExecutionDelay) * time.Second
|
||||
|
||||
time.AfterFunc(waitTime, func() {
|
||||
err = sendAppRequest(baseUrl, appName, exposedPort, action, workflowExecution)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed sending SCHEDULED request to app %s on port %d: %s", appName, exposedPort, err)
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
//log.Printf("[DEBUG] Running app %s NORMALLY as there is no delay set", action.Name)
|
||||
err = sendAppRequest(baseUrl, appName, exposedPort, action, workflowExecution)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed sending request to app %s on port %d: %s", appName, exposedPort, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
//log.Printf("[DEBUG] Successfully ran request towards port %d for app %s", exposedPort, appName)
|
||||
@@ -337,6 +351,22 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
||||
Env: env,
|
||||
}
|
||||
|
||||
if action.ExecutionDelay > 0 {
|
||||
log.Printf("[DEBUG] Running app %s in docker with delay of %d", action.Name, action.ExecutionDelay)
|
||||
waitTime := time.Duration(action.ExecutionDelay) * time.Second
|
||||
|
||||
time.AfterFunc(waitTime, func() {
|
||||
DeployContainer(ctx, cli, config, hostConfig, identifier, workflowExecution)
|
||||
})
|
||||
} else {
|
||||
log.Printf("[DEBUG] Running app %s in docker NORMALLY as there is no delay set", action.Name)
|
||||
return DeployContainer(ctx, cli, config, hostConfig, identifier, workflowExecution)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeployContainer(ctx context.Context, cli *dockerclient.Client, config *container.Config, hostConfig *container.HostConfig, identifier string, workflowExecution shuffle.WorkflowExecution) error {
|
||||
cont, err := cli.ContainerCreate(
|
||||
ctx,
|
||||
config,
|
||||
@@ -420,74 +450,12 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
|
||||
if workflowExecution.ExecutionSource != "default" {
|
||||
log.Printf("[INFO] Handling NON-default execution source %s - NOT waiting or validating!", workflowExecution.ExecutionSource)
|
||||
} else if workflowExecution.ExecutionSource == "default" {
|
||||
/*
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
stats, err := cli.ContainerInspect(ctx, cont.ID)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed getting container stats for container %s: %s", cont.ID, err)
|
||||
} else {
|
||||
//log.Printf("[INFO] Info for container: %#v", stats)
|
||||
//log.Printf("%#v", stats.Config)
|
||||
//log.Printf("%#v", stats.ContainerJSONBase.State)
|
||||
log.Printf("[DEBUG] EXECUTION STATUS: %s", stats.ContainerJSONBase.State.Status)
|
||||
logOptions := types.ContainerLogsOptions{
|
||||
ShowStdout: true,
|
||||
}
|
||||
|
||||
exit := false
|
||||
out, err := cli.ContainerLogs(ctx, cont.ID, logOptions)
|
||||
if err != nil {
|
||||
log.Printf("[INFO] Failed getting logs: %s", err)
|
||||
} else {
|
||||
buf := new(strings.Builder)
|
||||
io.Copy(buf, out)
|
||||
logs := buf.String()
|
||||
|
||||
// FIXME: Re-add log tracking which can be sent to backend
|
||||
//allLogs[actionId] = logs
|
||||
|
||||
if stats.ContainerJSONBase.State.Status == "exited" && (!strings.Contains(logs, "Normal execution") && !strings.Contains(logs, "indicates microservices") && !strings.Contains(logs, "starting action result")) {
|
||||
if len(logs) > 10 {
|
||||
log.Printf("[ERROR] BAD Execution Logs for %s: %s", action.ID, logs)
|
||||
exit = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if exit {
|
||||
log.Printf("[DEBUG] ERROR IN CONTAINER DEPLOYMENT - ITS EXITED!")
|
||||
return errors.New(fmt.Sprintf(`{"success": false, "reason": "Container %s exited prematurely.","debug": "docker logs -f %s"}`, cont.ID, cont.ID))
|
||||
}
|
||||
}
|
||||
*/
|
||||
log.Printf("[INFO] Handling DEFAULT execution source %s - SKIPPING wait anyway due to exited issues!", workflowExecution.ExecutionSource)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Deployed container ID %s", cont.ID)
|
||||
|
||||
/*
|
||||
//log.Printf("%#v", stats.Config.Status)
|
||||
//ContainerJSONtoConfig(cj dockType.ContainerJSON) ContainerConfig {
|
||||
listOptions := types.ContainerListOptions{
|
||||
Filters: filters.Args{
|
||||
map[string][]string{"ancestor": {"<imagename>:<version>"}},
|
||||
},
|
||||
}
|
||||
containers, err := cli.ContainerList(ctx, listOptions)
|
||||
*/
|
||||
|
||||
//log.Printf("%#v", cont.Status)
|
||||
//config := ContainerJSONtoConfig(stats)
|
||||
//log.Printf("CONFIG: %#v", config)
|
||||
|
||||
/*
|
||||
logOptions := types.ContainerLogsOptions{
|
||||
ShowStdout: true,
|
||||
}
|
||||
*/
|
||||
|
||||
containerIds = append(containerIds, cont.ID)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -986,6 +954,7 @@ func handleExecutionResult(workflowExecution shuffle.WorkflowExecution) {
|
||||
}
|
||||
|
||||
// FIXME: Add startnode from frontend
|
||||
action.ExecutionDelay = trigger.ExecutionDelay
|
||||
action.Label = trigger.Label
|
||||
action.Parameters = []shuffle.WorkflowAppActionParameter{}
|
||||
for _, parameter := range trigger.Parameters {
|
||||
|
||||
Reference in New Issue
Block a user