Fixed more issues with worker grabbing logs

This commit is contained in:
frikky
2021-11-09 01:14:06 +01:00
parent f9d63a385f
commit 3ef121ab00
6 changed files with 40 additions and 34 deletions
+2 -1
View File
@@ -2879,7 +2879,8 @@ class AppBase:
logging.basicConfig(format="{asctime} - {name} - {levelname}:{message}", style='{')
logger = logging.getLogger(f"{cls.__name__}")
logger.setLevel(logging.DEBUG)
logger.info("[DEBUG] Normal execution.")
##############################################
+1 -1
View File
@@ -3,7 +3,7 @@
### DEFAULT
NAME=shuffle-app_sdk
VERSION=0.9.31
VERSION=0.9.32
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION -t ghcr.io/frikky/$NAME:nightly
+1 -1
View File
@@ -47,7 +47,7 @@ services:
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- SHUFFLE_WORKER_VERSION=0.9.25
- SHUFFLE_WORKER_VERSION=nightly
- ORG_ID=${ORG_ID}
- ENVIRONMENT_NAME=${ENVIRONMENT_NAME}
- BASE_URL=http://${OUTER_HOSTNAME}:${BACKEND_PORT}
+2 -1
View File
@@ -225,13 +225,14 @@ func deployServiceWorkers(image string) {
replicas := uint64(2)
scaleReplicas := os.Getenv("SHUFFLE_SCALE_REPLICAS")
if len(scaleReplicas) > 0 {
log.Printf("[DEBUG] SHUFFLE_SCALE_REPLICAS set to value %#v. Trying to overwrite default (2/node)", scaleReplicas)
tmpInt, err := strconv.Atoi(scaleReplicas)
if err != nil {
log.Printf("[ERROR] %s is not a valid number for replication", scaleReplicas)
} else {
replicas = uint64(tmpInt)
}
log.Printf("[DEBUG] SHUFFLE_SCALE_REPLICAS set to value %#v. Trying to overwrite default (%d/node)", scaleReplicas, replicas)
}
innerContainerName := fmt.Sprintf("shuffle-workers")
+2
View File
@@ -570,6 +570,8 @@ github.com/shuffle/shuffle-shared v0.1.31 h1:+7OCH8G2fcg0Emqw3AR4iRZ9aFOEshi83HT
github.com/shuffle/shuffle-shared v0.1.31/go.mod h1:0QrK51T12CpCj/be8hXduj/RtDnoeaZ3rfogELZE2IU=
github.com/shuffle/shuffle-shared v0.1.32 h1:VzYecAkUbydIe5ufe5z6T+3PaaKWJASVznhUdxoBe3M=
github.com/shuffle/shuffle-shared v0.1.32/go.mod h1:0QrK51T12CpCj/be8hXduj/RtDnoeaZ3rfogELZE2IU=
github.com/shuffle/shuffle-shared v0.1.33 h1:1U0yKWNfW7K7EKOj2aqSmd20UIA+nJeIurGEfx29ffU=
github.com/shuffle/shuffle-shared v0.1.33/go.mod h1:0QrK51T12CpCj/be8hXduj/RtDnoeaZ3rfogELZE2IU=
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=
+32 -30
View File
@@ -401,46 +401,48 @@ 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)
/*
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)
stats, err := cli.ContainerInspect(ctx, cont.ID)
if err != nil {
log.Printf("[INFO] Failed getting logs: %s", err)
log.Printf("[ERROR] Failed getting container stats for container %s: %s", cont.ID, err)
} else {
buf := new(strings.Builder)
io.Copy(buf, out)
logs := buf.String()
//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,
}
// FIXME: Re-add log tracking which can be sent to backend
//allLogs[actionId] = logs
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()
if stats.ContainerJSONBase.State.Status == "exited" && (!strings.Contains(logs, "Normal execution.") && !strings.Contains(logs, "indicates microservices")) {
// FIXME: Re-add log tracking which can be sent to backend
//allLogs[actionId] = logs
if len(logs) > 10 {
log.Printf("[ERROR] BAD Execution Logs for %s: %s", action.ID, logs)
exit = true
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))
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)