Added High Availability control and failovers for Orborus with SHUFFLE_ORBORUS_UUID. Requires shuffle 2.1.0 or higher
This commit is contained in:
@@ -6,6 +6,7 @@ toolchain go1.24.3
|
||||
|
||||
//replace github.com/frikky/schemaless => ../../../schemaless
|
||||
//replace github.com/shuffle/shuffle-shared => ../../../shuffle-shared
|
||||
|
||||
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
|
||||
|
||||
require (
|
||||
@@ -22,7 +23,7 @@ require (
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/h2non/filetype v1.1.3
|
||||
github.com/satori/go.uuid v1.2.0
|
||||
github.com/shuffle/shuffle-shared v0.8.76
|
||||
github.com/shuffle/shuffle-shared v0.8.82
|
||||
golang.org/x/crypto v0.38.0
|
||||
google.golang.org/api v0.236.0
|
||||
google.golang.org/grpc v1.72.2
|
||||
|
||||
@@ -350,8 +350,8 @@ github.com/sendgrid/sendgrid-go v3.16.1+incompatible h1:zWhTmB0Y8XCDzeWIm2/BIt1G
|
||||
github.com/sendgrid/sendgrid-go v3.16.1+incompatible/go.mod h1:QRQt+LX/NmgVEvmdRw0VT/QgUn499+iza2FnDca9fg8=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
|
||||
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/shuffle/shuffle-shared v0.8.76 h1:bNgQ/wqN8J3WT/Qjf5SbamXbRwzSYZZulL/Pa81aTwM=
|
||||
github.com/shuffle/shuffle-shared v0.8.76/go.mod h1:RdfNxqCPI+zU4jQKy3E/p4Io2injm7LpSKQUCDHNtLk=
|
||||
github.com/shuffle/shuffle-shared v0.8.82 h1:vwXG/NOZNoPMfbF14ZnygoY8+AI2QVsggWfgfpSbqzo=
|
||||
github.com/shuffle/shuffle-shared v0.8.82/go.mod h1:RdfNxqCPI+zU4jQKy3E/p4Io2injm7LpSKQUCDHNtLk=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
|
||||
+10
-46
@@ -281,54 +281,18 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
ctx := shuffle.GetContext(request)
|
||||
env, err := shuffle.GetEnvironment(ctx, orgId, "")
|
||||
if err != nil {
|
||||
log.Printf("[WARNING] No env found matching %s - continuing without updating orborus anyway: %s", orgId, err)
|
||||
}
|
||||
|
||||
timeNow := time.Now().Unix()
|
||||
if err == nil && len(env.Id) > 0 && len(env.Name) > 0 && request.Method == "POST" {
|
||||
// Updates every 60 seconds~
|
||||
if time.Now().Unix() > env.Edited+60 {
|
||||
env.RunningIp = shuffle.GetRequestIp(request)
|
||||
|
||||
// Orborus label = custom label for Orborus
|
||||
if len(orborusLabel) > 0 {
|
||||
env.RunningIp = orborusLabel
|
||||
}
|
||||
|
||||
// Set the checkin cache
|
||||
|
||||
|
||||
body, err := ioutil.ReadAll(request.Body)
|
||||
if err == nil {
|
||||
var envData shuffle.OrborusStats
|
||||
err = json.Unmarshal(body, &envData)
|
||||
if err == nil {
|
||||
envData.RunningIp = env.RunningIp
|
||||
|
||||
marshalled, err := json.Marshal(envData)
|
||||
if err == nil {
|
||||
cacheKey := fmt.Sprintf("queueconfig-%s-%s", env.Name, env.OrgId)
|
||||
go shuffle.SetCache(context.Background(), cacheKey, marshalled, 2)
|
||||
}
|
||||
|
||||
|
||||
|
||||
if envData.Swarm {
|
||||
env.Licensed = true
|
||||
env.RunType = "docker"
|
||||
}
|
||||
|
||||
if envData.Kubernetes {
|
||||
env.RunType = "k8s"
|
||||
}
|
||||
|
||||
envData.DataLake = env.DataLake
|
||||
}
|
||||
}
|
||||
|
||||
env.Checkin = timeNow
|
||||
err = shuffle.SetEnvironment(ctx, env)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] Failed updating environment: %s", err)
|
||||
}
|
||||
err = shuffle.HandleOrborusFailover(ctx, request, resp, env)
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), "mismatch") {
|
||||
log.Printf("[WARNING] Failed handling Orborus failover: %s", err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//log.Printf("Found env: %#v", env)
|
||||
|
||||
Reference in New Issue
Block a user