diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index af4b2f8b..82995baa 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -18,7 +18,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/h2non/filetype v1.1.3 github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.5.30 + github.com/shuffle/shuffle-shared v0.5.31 golang.org/x/crypto v0.14.0 google.golang.org/api v0.125.0 google.golang.org/grpc v1.55.0 diff --git a/backend/go-app/go.sum b/backend/go-app/go.sum index bea5b3c6..3f77bb07 100644 --- a/backend/go-app/go.sum +++ b/backend/go-app/go.sum @@ -422,6 +422,10 @@ github.com/shuffle/shuffle-shared v0.5.14 h1:d14u1e4k+qKgnf4Insq4x2S+0MMKlDqdyTT github.com/shuffle/shuffle-shared v0.5.14/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= github.com/shuffle/shuffle-shared v0.5.29 h1:n4vThl7v3mFVXbrIW71XREFdmZZo7mOBAWxnsdiNjDk= github.com/shuffle/shuffle-shared v0.5.29/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= +github.com/shuffle/shuffle-shared v0.5.30 h1:ORWjQU3UJhdZY5mRsAoR2hvftNcJmiEekNKjbaMo7K8= +github.com/shuffle/shuffle-shared v0.5.30/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= +github.com/shuffle/shuffle-shared v0.5.31 h1:OV4IIfKWWFW66WjGvyXOmmsSz3p8pW9L1ge1mDo8ftM= +github.com/shuffle/shuffle-shared v0.5.31/go.mod h1:X613gbo0dT3fnYvXDRwjQZyLC+T49T2nSQOrCV5QMlI= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= diff --git a/backend/go-app/main.go b/backend/go-app/main.go index b365416d..296c8739 100755 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -3839,7 +3839,9 @@ func runInitEs(ctx context.Context) { } // FIXME: Have this for all envs in all orgs (loop and find). - if len(parsedApikey) > 0 { + if len(parsedApikey) == 0 { + log.Printf("[WARNING] No apikey found for cleanup. Skipping cleanup schedule.") + } else { cleanupSchedule := 300 if len(os.Getenv("SHUFFLE_RERUN_SCHEDULE")) > 0 { @@ -3854,8 +3856,25 @@ func runInitEs(ctx context.Context) { } } - environments := []string{"Shuffle"} - log.Printf("[DEBUG] Starting schedule setup for execution cleanup every %d seconds. Running first immediately.", cleanupSchedule) + environments := []string{defaultEnv} + + // Comma separated list of RERUN environments + if len(os.Getenv("SHUFFLE_RERUN_ENVIRONMENTS")) > 0 { + foundenv := strings.Split(os.Getenv("SHUFFLE_RERUN_ENVIRONMENTS"), ",") + for i, env := range foundenv { + if len(env) == 0 { + continue + } + + environments[i] = strings.TrimSpace(env) + if !shuffle.ArrayContains(environments, env) { + environments = append(foundenv, env) + } + } + } + + log.Printf("[DEBUG] Starting schedule setup for execution cleanup every %d seconds. Running first immediately. Environments: %#v", cleanupSchedule, environments) + cleanupJob := func() func() { return func() { log.Printf("[INFO] Running schedule for cleaning up or re-running unfinished workflows in %d environments.", len(environments)) @@ -3925,8 +3944,6 @@ func runInitEs(ctx context.Context) { } else { _ = jobret } - } else { - log.Printf("[DEBUG] Couldn't find a valid API-key, hence couldn't run cleanup") } // Getting apps to see if we should initialize a test