diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index ad9d40b5..d43f805c 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index f1c7ff7c..64eabd79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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} diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index c66db8f2..d164cffc 100644 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -2410,7 +2410,7 @@ const ParsedAction = (props) => { }} /> - {!isCloud ? null : + {/*!isCloud ? null :*/}
{
- } + {/**/} )} diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 3996d622..349c7598 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -7783,7 +7783,6 @@ const AngularWorkflow = (defaultprops) => { />
- {!isCloud ? null :
{
- }
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": {":"}}, - }, - } - 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 {