feat: adding SHUFFLE_SWARM_CONTROL_MODE
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -26,9 +27,8 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"sync"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
//"os/signal"
|
||||
//"syscall"
|
||||
@@ -1041,12 +1041,10 @@ func getOrborusStats(ctx context.Context) shuffle.OrborusStats {
|
||||
return newStats
|
||||
}
|
||||
|
||||
|
||||
if swarmConfig == "run" || swarmConfig == "swarm" {
|
||||
newStats.Swarm = true
|
||||
}
|
||||
|
||||
|
||||
// Run this 1/10 times
|
||||
//if rand.Intn(10) != 1 {
|
||||
// return newStats
|
||||
@@ -1077,7 +1075,6 @@ func getOrborusStats(ctx context.Context) shuffle.OrborusStats {
|
||||
newStats.MaxMemory = int(pers.MemTotal)
|
||||
}
|
||||
|
||||
|
||||
// Get list of all running containers
|
||||
containers, err := dockercli.ContainerList(ctx, types.ContainerListOptions{})
|
||||
if err != nil {
|
||||
@@ -1409,6 +1406,13 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
swarmPollingTime := time.Now()
|
||||
swarmRequestsMade := 0
|
||||
swarmControlMode := false
|
||||
if os.Getenv("SHUFFLE_SWARM_CONTROL_MODE") == "true" {
|
||||
swarmControlMode = true
|
||||
}
|
||||
|
||||
log.Printf("[INFO] Waiting for executions at %s with Environment %#v", fullUrl, environment)
|
||||
hasStarted := false
|
||||
for {
|
||||
@@ -1529,6 +1533,20 @@ func main() {
|
||||
log.Printf("[WARNING] Throttle - Cutting down requests from %d to %d (MAX: %d, CUR: %d)", len(executionRequests.Data), allowed, maxConcurrency, executionCount)
|
||||
executionRequests.Data = executionRequests.Data[0:allowed]
|
||||
}
|
||||
} else if (swarmControlMode && (swarmConfig == "run" || swarmConfig == "swarm")) {
|
||||
if len(executionRequests.Data) > 50 {
|
||||
executionRequests.Data = executionRequests.Data[0:50]
|
||||
}
|
||||
|
||||
if swarmRequestsMade > 100 && time.Since(swarmPollingTime).Seconds() > 5 {
|
||||
log.Printf("[DEBUG] Swarm requests made: %d", swarmRequestsMade)
|
||||
time.Sleep(time.Duration(sleepTime) * time.Second)
|
||||
|
||||
swarmPollingTime = time.Now()
|
||||
swarmRequestsMade = 0
|
||||
}
|
||||
|
||||
swarmRequestsMade += len(executionRequests.Data)
|
||||
}
|
||||
|
||||
// New, abortable version. Should check executionid and remove everything else
|
||||
@@ -1611,7 +1629,6 @@ func main() {
|
||||
env = append(env, fmt.Sprintf("SHUFFLE_VOLUME_BINDS=%s", os.Getenv("SHUFFLE_VOLUME_BINDS")))
|
||||
}
|
||||
|
||||
|
||||
if len(os.Getenv("SHUFFLE_APP_SDK_TIMEOUT")) > 0 {
|
||||
env = append(env, fmt.Sprintf("SHUFFLE_APP_SDK_TIMEOUT=%s", os.Getenv("SHUFFLE_APP_SDK_TIMEOUT")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user