Upgrade to Aurora 0.22.0 (#5)

* Upgrading to Thrift 0.13.1. This version is a fork of 0.13.0 with a patch on top of it to fix an issue where trying a realis call after the connection has been closed results in a panic.

* Upgrading compose set up to Mesos 1.6.2 and Aurora 0.22.0.

* Adding support for using different update strategies.

* Adding a monitor that is friendly with auto pause.

* Adding tests for new update strategies.
This commit is contained in:
Renán I. Del Valle 2020-05-05 20:55:25 -07:00 committed by GitHub
parent 1d8afcd329
commit 69ced895e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 2013 additions and 1068 deletions

View file

@ -716,9 +716,40 @@ struct JobUpdateKey {
2: string id 2: string id
} }
/** Limits the amount of active changes being made to instances to groupSize. */
struct QueueJobUpdateStrategy {
1: i32 groupSize
}
/** Similar to Queue strategy but will not start a new group until all instances in an active
* group have finished updating.
*/
struct BatchJobUpdateStrategy {
1: i32 groupSize
/* Update will pause automatically after each batch completes */
2: bool autopauseAfterBatch
}
/** Same as Batch strategy but each time an active group completes, the size of the next active
* group may change.
*/
struct VariableBatchJobUpdateStrategy {
1: list<i32> groupSizes
/* Update will pause automatically after each batch completes */
2: bool autopauseAfterBatch
}
union JobUpdateStrategy {
1: QueueJobUpdateStrategy queueStrategy
2: BatchJobUpdateStrategy batchStrategy
3: VariableBatchJobUpdateStrategy varBatchStrategy
}
/** Job update thresholds and limits. */ /** Job update thresholds and limits. */
struct JobUpdateSettings { struct JobUpdateSettings {
/** Max number of instances being updated at any given moment. */ /** Deprecated, please set value inside of desired update strategy instead.
* Max number of instances being updated at any given moment.
*/
1: i32 updateGroupSize 1: i32 updateGroupSize
/** Max number of instance failures to tolerate before marking instance as FAILED. */ /** Max number of instance failures to tolerate before marking instance as FAILED. */
@ -736,7 +767,7 @@ struct JobUpdateSettings {
/** Instance IDs to act on. All instances will be affected if this is not set. */ /** Instance IDs to act on. All instances will be affected if this is not set. */
7: set<Range> updateOnlyTheseInstances 7: set<Range> updateOnlyTheseInstances
/** /** Deprecated, please set updateStrategy to the Batch strategy instead.
* If true, use updateGroupSize as strict batching boundaries, and avoid proceeding to another * If true, use updateGroupSize as strict batching boundaries, and avoid proceeding to another
* batch until the preceding batch finishes updating. * batch until the preceding batch finishes updating.
*/ */
@ -755,6 +786,9 @@ struct JobUpdateSettings {
* differs between the old and new task configurations, updates will use the newest configuration. * differs between the old and new task configurations, updates will use the newest configuration.
*/ */
10: optional bool slaAware 10: optional bool slaAware
/** Update strategy to be used for the update. See JobUpdateStrategy for choices. */
11: optional JobUpdateStrategy updateStrategy
} }
/** Event marking a state transition in job update lifecycle. */ /** Event marking a state transition in job update lifecycle. */

View file

@ -14,7 +14,7 @@ services:
ipv4_address: 192.168.33.2 ipv4_address: 192.168.33.2
master: master:
image: rdelvalle/mesos-master:1.5.1 image: rdelvalle/mesos-master:1.6.2
restart: on-failure restart: on-failure
ports: ports:
- "5050:5050" - "5050:5050"
@ -32,7 +32,7 @@ services:
- zk - zk
agent-one: agent-one:
image: rdelvalle/mesos-agent:1.5.1 image: rdelvalle/mesos-agent:1.6.2
pid: host pid: host
restart: on-failure restart: on-failure
ports: ports:
@ -56,7 +56,7 @@ services:
- zk - zk
aurora-one: aurora-one:
image: rdelvalle/aurora:0.21.0 image: rdelvalle/aurora:0.22.0
pid: host pid: host
ports: ports:
- "8081:8081" - "8081:8081"
@ -69,6 +69,7 @@ services:
-http_authentication_mechanism=BASIC -http_authentication_mechanism=BASIC
-shiro_realm_modules=INI_AUTHNZ -shiro_realm_modules=INI_AUTHNZ
-shiro_ini_path=/etc/aurora/security.ini -shiro_ini_path=/etc/aurora/security.ini
-min_required_instances_for_sla_check=1
volumes: volumes:
- ./.aurora-config:/etc/aurora - ./.aurora-config:/etc/aurora
networks: networks:

View file

@ -1,4 +1,4 @@
// Autogenerated by Thrift Compiler (0.12.0) // Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package aurora package aurora

View file

@ -1,9 +1,9 @@
// Autogenerated by Thrift Compiler (0.12.0) // Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package aurora package aurora
import ( import(
"bytes" "bytes"
"context" "context"
"reflect" "reflect"

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,23 @@
// Autogenerated by Thrift Compiler (0.12.0) // Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package main package main
import ( import (
"context" "context"
"flag" "flag"
"fmt" "fmt"
"math" "math"
"net" "net"
"net/url" "net/url"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/apache/thrift/lib/go/thrift" "github.com/apache/thrift/lib/go/thrift"
"apache/aurora" "apache/aurora"
) )
var _ = aurora.GoUnusedProtection__
func Usage() { func Usage() {
fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
@ -175,19 +176,19 @@ func main() {
fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") fmt.Fprintln(os.Stderr, "CreateJob requires 1 args")
flag.Usage() flag.Usage()
} }
arg162 := flag.Arg(1) arg163 := flag.Arg(1)
mbTrans163 := thrift.NewTMemoryBufferLen(len(arg162)) mbTrans164 := thrift.NewTMemoryBufferLen(len(arg163))
defer mbTrans163.Close() defer mbTrans164.Close()
_, err164 := mbTrans163.WriteString(arg162) _, err165 := mbTrans164.WriteString(arg163)
if err164 != nil { if err165 != nil {
Usage() Usage()
return return
} }
factory165 := thrift.NewTJSONProtocolFactory() factory166 := thrift.NewTJSONProtocolFactory()
jsProt166 := factory165.GetProtocol(mbTrans163) jsProt167 := factory166.GetProtocol(mbTrans164)
argvalue0 := aurora.NewJobConfiguration() argvalue0 := aurora.NewJobConfiguration()
err167 := argvalue0.Read(jsProt166) err168 := argvalue0.Read(jsProt167)
if err167 != nil { if err168 != nil {
Usage() Usage()
return return
} }
@ -200,19 +201,19 @@ func main() {
fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args")
flag.Usage() flag.Usage()
} }
arg168 := flag.Arg(1) arg169 := flag.Arg(1)
mbTrans169 := thrift.NewTMemoryBufferLen(len(arg168)) mbTrans170 := thrift.NewTMemoryBufferLen(len(arg169))
defer mbTrans169.Close() defer mbTrans170.Close()
_, err170 := mbTrans169.WriteString(arg168) _, err171 := mbTrans170.WriteString(arg169)
if err170 != nil { if err171 != nil {
Usage() Usage()
return return
} }
factory171 := thrift.NewTJSONProtocolFactory() factory172 := thrift.NewTJSONProtocolFactory()
jsProt172 := factory171.GetProtocol(mbTrans169) jsProt173 := factory172.GetProtocol(mbTrans170)
argvalue0 := aurora.NewJobConfiguration() argvalue0 := aurora.NewJobConfiguration()
err173 := argvalue0.Read(jsProt172) err174 := argvalue0.Read(jsProt173)
if err173 != nil { if err174 != nil {
Usage() Usage()
return return
} }
@ -225,19 +226,19 @@ func main() {
fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args")
flag.Usage() flag.Usage()
} }
arg174 := flag.Arg(1) arg175 := flag.Arg(1)
mbTrans175 := thrift.NewTMemoryBufferLen(len(arg174)) mbTrans176 := thrift.NewTMemoryBufferLen(len(arg175))
defer mbTrans175.Close() defer mbTrans176.Close()
_, err176 := mbTrans175.WriteString(arg174) _, err177 := mbTrans176.WriteString(arg175)
if err176 != nil { if err177 != nil {
Usage() Usage()
return return
} }
factory177 := thrift.NewTJSONProtocolFactory() factory178 := thrift.NewTJSONProtocolFactory()
jsProt178 := factory177.GetProtocol(mbTrans175) jsProt179 := factory178.GetProtocol(mbTrans176)
argvalue0 := aurora.NewJobKey() argvalue0 := aurora.NewJobKey()
err179 := argvalue0.Read(jsProt178) err180 := argvalue0.Read(jsProt179)
if err179 != nil { if err180 != nil {
Usage() Usage()
return return
} }
@ -250,19 +251,19 @@ func main() {
fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args")
flag.Usage() flag.Usage()
} }
arg180 := flag.Arg(1) arg181 := flag.Arg(1)
mbTrans181 := thrift.NewTMemoryBufferLen(len(arg180)) mbTrans182 := thrift.NewTMemoryBufferLen(len(arg181))
defer mbTrans181.Close() defer mbTrans182.Close()
_, err182 := mbTrans181.WriteString(arg180) _, err183 := mbTrans182.WriteString(arg181)
if err182 != nil { if err183 != nil {
Usage() Usage()
return return
} }
factory183 := thrift.NewTJSONProtocolFactory() factory184 := thrift.NewTJSONProtocolFactory()
jsProt184 := factory183.GetProtocol(mbTrans181) jsProt185 := factory184.GetProtocol(mbTrans182)
argvalue0 := aurora.NewJobKey() argvalue0 := aurora.NewJobKey()
err185 := argvalue0.Read(jsProt184) err186 := argvalue0.Read(jsProt185)
if err185 != nil { if err186 != nil {
Usage() Usage()
return return
} }
@ -275,36 +276,36 @@ func main() {
fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") fmt.Fprintln(os.Stderr, "RestartShards requires 2 args")
flag.Usage() flag.Usage()
} }
arg186 := flag.Arg(1) arg187 := flag.Arg(1)
mbTrans187 := thrift.NewTMemoryBufferLen(len(arg186)) mbTrans188 := thrift.NewTMemoryBufferLen(len(arg187))
defer mbTrans187.Close() defer mbTrans188.Close()
_, err188 := mbTrans187.WriteString(arg186) _, err189 := mbTrans188.WriteString(arg187)
if err188 != nil { if err189 != nil {
Usage() Usage()
return return
} }
factory189 := thrift.NewTJSONProtocolFactory() factory190 := thrift.NewTJSONProtocolFactory()
jsProt190 := factory189.GetProtocol(mbTrans187) jsProt191 := factory190.GetProtocol(mbTrans188)
argvalue0 := aurora.NewJobKey() argvalue0 := aurora.NewJobKey()
err191 := argvalue0.Read(jsProt190) err192 := argvalue0.Read(jsProt191)
if err191 != nil { if err192 != nil {
Usage() Usage()
return return
} }
value0 := argvalue0 value0 := argvalue0
arg192 := flag.Arg(2) arg193 := flag.Arg(2)
mbTrans193 := thrift.NewTMemoryBufferLen(len(arg192)) mbTrans194 := thrift.NewTMemoryBufferLen(len(arg193))
defer mbTrans193.Close() defer mbTrans194.Close()
_, err194 := mbTrans193.WriteString(arg192) _, err195 := mbTrans194.WriteString(arg193)
if err194 != nil { if err195 != nil {
Usage() Usage()
return return
} }
factory195 := thrift.NewTJSONProtocolFactory() factory196 := thrift.NewTJSONProtocolFactory()
jsProt196 := factory195.GetProtocol(mbTrans193) jsProt197 := factory196.GetProtocol(mbTrans194)
containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs() containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs()
err197 := containerStruct1.ReadField2(jsProt196) err198 := containerStruct1.ReadField2(jsProt197)
if err197 != nil { if err198 != nil {
Usage() Usage()
return return
} }
@ -318,36 +319,36 @@ func main() {
fmt.Fprintln(os.Stderr, "KillTasks requires 3 args") fmt.Fprintln(os.Stderr, "KillTasks requires 3 args")
flag.Usage() flag.Usage()
} }
arg198 := flag.Arg(1) arg199 := flag.Arg(1)
mbTrans199 := thrift.NewTMemoryBufferLen(len(arg198)) mbTrans200 := thrift.NewTMemoryBufferLen(len(arg199))
defer mbTrans199.Close() defer mbTrans200.Close()
_, err200 := mbTrans199.WriteString(arg198) _, err201 := mbTrans200.WriteString(arg199)
if err200 != nil { if err201 != nil {
Usage() Usage()
return return
} }
factory201 := thrift.NewTJSONProtocolFactory() factory202 := thrift.NewTJSONProtocolFactory()
jsProt202 := factory201.GetProtocol(mbTrans199) jsProt203 := factory202.GetProtocol(mbTrans200)
argvalue0 := aurora.NewJobKey() argvalue0 := aurora.NewJobKey()
err203 := argvalue0.Read(jsProt202) err204 := argvalue0.Read(jsProt203)
if err203 != nil { if err204 != nil {
Usage() Usage()
return return
} }
value0 := argvalue0 value0 := argvalue0
arg204 := flag.Arg(2) arg205 := flag.Arg(2)
mbTrans205 := thrift.NewTMemoryBufferLen(len(arg204)) mbTrans206 := thrift.NewTMemoryBufferLen(len(arg205))
defer mbTrans205.Close() defer mbTrans206.Close()
_, err206 := mbTrans205.WriteString(arg204) _, err207 := mbTrans206.WriteString(arg205)
if err206 != nil { if err207 != nil {
Usage() Usage()
return return
} }
factory207 := thrift.NewTJSONProtocolFactory() factory208 := thrift.NewTJSONProtocolFactory()
jsProt208 := factory207.GetProtocol(mbTrans205) jsProt209 := factory208.GetProtocol(mbTrans206)
containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs() containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs()
err209 := containerStruct1.ReadField2(jsProt208) err210 := containerStruct1.ReadField2(jsProt209)
if err209 != nil { if err210 != nil {
Usage() Usage()
return return
} }
@ -363,25 +364,25 @@ func main() {
fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") fmt.Fprintln(os.Stderr, "AddInstances requires 2 args")
flag.Usage() flag.Usage()
} }
arg211 := flag.Arg(1) arg212 := flag.Arg(1)
mbTrans212 := thrift.NewTMemoryBufferLen(len(arg211)) mbTrans213 := thrift.NewTMemoryBufferLen(len(arg212))
defer mbTrans212.Close() defer mbTrans213.Close()
_, err213 := mbTrans212.WriteString(arg211) _, err214 := mbTrans213.WriteString(arg212)
if err213 != nil { if err214 != nil {
Usage() Usage()
return return
} }
factory214 := thrift.NewTJSONProtocolFactory() factory215 := thrift.NewTJSONProtocolFactory()
jsProt215 := factory214.GetProtocol(mbTrans212) jsProt216 := factory215.GetProtocol(mbTrans213)
argvalue0 := aurora.NewInstanceKey() argvalue0 := aurora.NewInstanceKey()
err216 := argvalue0.Read(jsProt215) err217 := argvalue0.Read(jsProt216)
if err216 != nil { if err217 != nil {
Usage() Usage()
return return
} }
value0 := argvalue0 value0 := argvalue0
tmp1, err217 := (strconv.Atoi(flag.Arg(2))) tmp1, err218 := (strconv.Atoi(flag.Arg(2)))
if err217 != nil { if err218 != nil {
Usage() Usage()
return return
} }
@ -395,19 +396,19 @@ func main() {
fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args")
flag.Usage() flag.Usage()
} }
arg218 := flag.Arg(1) arg219 := flag.Arg(1)
mbTrans219 := thrift.NewTMemoryBufferLen(len(arg218)) mbTrans220 := thrift.NewTMemoryBufferLen(len(arg219))
defer mbTrans219.Close() defer mbTrans220.Close()
_, err220 := mbTrans219.WriteString(arg218) _, err221 := mbTrans220.WriteString(arg219)
if err220 != nil { if err221 != nil {
Usage() Usage()
return return
} }
factory221 := thrift.NewTJSONProtocolFactory() factory222 := thrift.NewTJSONProtocolFactory()
jsProt222 := factory221.GetProtocol(mbTrans219) jsProt223 := factory222.GetProtocol(mbTrans220)
argvalue0 := aurora.NewJobConfiguration() argvalue0 := aurora.NewJobConfiguration()
err223 := argvalue0.Read(jsProt222) err224 := argvalue0.Read(jsProt223)
if err223 != nil { if err224 != nil {
Usage() Usage()
return return
} }
@ -420,19 +421,19 @@ func main() {
fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args")
flag.Usage() flag.Usage()
} }
arg224 := flag.Arg(1) arg225 := flag.Arg(1)
mbTrans225 := thrift.NewTMemoryBufferLen(len(arg224)) mbTrans226 := thrift.NewTMemoryBufferLen(len(arg225))
defer mbTrans225.Close() defer mbTrans226.Close()
_, err226 := mbTrans225.WriteString(arg224) _, err227 := mbTrans226.WriteString(arg225)
if err226 != nil { if err227 != nil {
Usage() Usage()
return return
} }
factory227 := thrift.NewTJSONProtocolFactory() factory228 := thrift.NewTJSONProtocolFactory()
jsProt228 := factory227.GetProtocol(mbTrans225) jsProt229 := factory228.GetProtocol(mbTrans226)
argvalue0 := aurora.NewJobUpdateRequest() argvalue0 := aurora.NewJobUpdateRequest()
err229 := argvalue0.Read(jsProt228) err230 := argvalue0.Read(jsProt229)
if err229 != nil { if err230 != nil {
Usage() Usage()
return return
} }
@ -447,19 +448,19 @@ func main() {
fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args")
flag.Usage() flag.Usage()
} }
arg231 := flag.Arg(1) arg232 := flag.Arg(1)
mbTrans232 := thrift.NewTMemoryBufferLen(len(arg231)) mbTrans233 := thrift.NewTMemoryBufferLen(len(arg232))
defer mbTrans232.Close() defer mbTrans233.Close()
_, err233 := mbTrans232.WriteString(arg231) _, err234 := mbTrans233.WriteString(arg232)
if err233 != nil { if err234 != nil {
Usage() Usage()
return return
} }
factory234 := thrift.NewTJSONProtocolFactory() factory235 := thrift.NewTJSONProtocolFactory()
jsProt235 := factory234.GetProtocol(mbTrans232) jsProt236 := factory235.GetProtocol(mbTrans233)
argvalue0 := aurora.NewJobUpdateKey() argvalue0 := aurora.NewJobUpdateKey()
err236 := argvalue0.Read(jsProt235) err237 := argvalue0.Read(jsProt236)
if err236 != nil { if err237 != nil {
Usage() Usage()
return return
} }
@ -474,19 +475,19 @@ func main() {
fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args")
flag.Usage() flag.Usage()
} }
arg238 := flag.Arg(1) arg239 := flag.Arg(1)
mbTrans239 := thrift.NewTMemoryBufferLen(len(arg238)) mbTrans240 := thrift.NewTMemoryBufferLen(len(arg239))
defer mbTrans239.Close() defer mbTrans240.Close()
_, err240 := mbTrans239.WriteString(arg238) _, err241 := mbTrans240.WriteString(arg239)
if err240 != nil { if err241 != nil {
Usage() Usage()
return return
} }
factory241 := thrift.NewTJSONProtocolFactory() factory242 := thrift.NewTJSONProtocolFactory()
jsProt242 := factory241.GetProtocol(mbTrans239) jsProt243 := factory242.GetProtocol(mbTrans240)
argvalue0 := aurora.NewJobUpdateKey() argvalue0 := aurora.NewJobUpdateKey()
err243 := argvalue0.Read(jsProt242) err244 := argvalue0.Read(jsProt243)
if err243 != nil { if err244 != nil {
Usage() Usage()
return return
} }
@ -501,19 +502,19 @@ func main() {
fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args")
flag.Usage() flag.Usage()
} }
arg245 := flag.Arg(1) arg246 := flag.Arg(1)
mbTrans246 := thrift.NewTMemoryBufferLen(len(arg245)) mbTrans247 := thrift.NewTMemoryBufferLen(len(arg246))
defer mbTrans246.Close() defer mbTrans247.Close()
_, err247 := mbTrans246.WriteString(arg245) _, err248 := mbTrans247.WriteString(arg246)
if err247 != nil { if err248 != nil {
Usage() Usage()
return return
} }
factory248 := thrift.NewTJSONProtocolFactory() factory249 := thrift.NewTJSONProtocolFactory()
jsProt249 := factory248.GetProtocol(mbTrans246) jsProt250 := factory249.GetProtocol(mbTrans247)
argvalue0 := aurora.NewJobUpdateKey() argvalue0 := aurora.NewJobUpdateKey()
err250 := argvalue0.Read(jsProt249) err251 := argvalue0.Read(jsProt250)
if err250 != nil { if err251 != nil {
Usage() Usage()
return return
} }
@ -528,19 +529,19 @@ func main() {
fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args")
flag.Usage() flag.Usage()
} }
arg252 := flag.Arg(1) arg253 := flag.Arg(1)
mbTrans253 := thrift.NewTMemoryBufferLen(len(arg252)) mbTrans254 := thrift.NewTMemoryBufferLen(len(arg253))
defer mbTrans253.Close() defer mbTrans254.Close()
_, err254 := mbTrans253.WriteString(arg252) _, err255 := mbTrans254.WriteString(arg253)
if err254 != nil { if err255 != nil {
Usage() Usage()
return return
} }
factory255 := thrift.NewTJSONProtocolFactory() factory256 := thrift.NewTJSONProtocolFactory()
jsProt256 := factory255.GetProtocol(mbTrans253) jsProt257 := factory256.GetProtocol(mbTrans254)
argvalue0 := aurora.NewJobUpdateKey() argvalue0 := aurora.NewJobUpdateKey()
err257 := argvalue0.Read(jsProt256) err258 := argvalue0.Read(jsProt257)
if err257 != nil { if err258 != nil {
Usage() Usage()
return return
} }
@ -555,19 +556,19 @@ func main() {
fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args")
flag.Usage() flag.Usage()
} }
arg259 := flag.Arg(1) arg260 := flag.Arg(1)
mbTrans260 := thrift.NewTMemoryBufferLen(len(arg259)) mbTrans261 := thrift.NewTMemoryBufferLen(len(arg260))
defer mbTrans260.Close() defer mbTrans261.Close()
_, err261 := mbTrans260.WriteString(arg259) _, err262 := mbTrans261.WriteString(arg260)
if err261 != nil { if err262 != nil {
Usage() Usage()
return return
} }
factory262 := thrift.NewTJSONProtocolFactory() factory263 := thrift.NewTJSONProtocolFactory()
jsProt263 := factory262.GetProtocol(mbTrans260) jsProt264 := factory263.GetProtocol(mbTrans261)
argvalue0 := aurora.NewJobUpdateKey() argvalue0 := aurora.NewJobUpdateKey()
err264 := argvalue0.Read(jsProt263) err265 := argvalue0.Read(jsProt264)
if err264 != nil { if err265 != nil {
Usage() Usage()
return return
} }
@ -598,19 +599,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args")
flag.Usage() flag.Usage()
} }
arg266 := flag.Arg(1) arg267 := flag.Arg(1)
mbTrans267 := thrift.NewTMemoryBufferLen(len(arg266)) mbTrans268 := thrift.NewTMemoryBufferLen(len(arg267))
defer mbTrans267.Close() defer mbTrans268.Close()
_, err268 := mbTrans267.WriteString(arg266) _, err269 := mbTrans268.WriteString(arg267)
if err268 != nil { if err269 != nil {
Usage() Usage()
return return
} }
factory269 := thrift.NewTJSONProtocolFactory() factory270 := thrift.NewTJSONProtocolFactory()
jsProt270 := factory269.GetProtocol(mbTrans267) jsProt271 := factory270.GetProtocol(mbTrans268)
argvalue0 := aurora.NewTaskQuery() argvalue0 := aurora.NewTaskQuery()
err271 := argvalue0.Read(jsProt270) err272 := argvalue0.Read(jsProt271)
if err271 != nil { if err272 != nil {
Usage() Usage()
return return
} }
@ -623,19 +624,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args")
flag.Usage() flag.Usage()
} }
arg272 := flag.Arg(1) arg273 := flag.Arg(1)
mbTrans273 := thrift.NewTMemoryBufferLen(len(arg272)) mbTrans274 := thrift.NewTMemoryBufferLen(len(arg273))
defer mbTrans273.Close() defer mbTrans274.Close()
_, err274 := mbTrans273.WriteString(arg272) _, err275 := mbTrans274.WriteString(arg273)
if err274 != nil { if err275 != nil {
Usage() Usage()
return return
} }
factory275 := thrift.NewTJSONProtocolFactory() factory276 := thrift.NewTJSONProtocolFactory()
jsProt276 := factory275.GetProtocol(mbTrans273) jsProt277 := factory276.GetProtocol(mbTrans274)
argvalue0 := aurora.NewTaskQuery() argvalue0 := aurora.NewTaskQuery()
err277 := argvalue0.Read(jsProt276) err278 := argvalue0.Read(jsProt277)
if err277 != nil { if err278 != nil {
Usage() Usage()
return return
} }
@ -648,19 +649,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args")
flag.Usage() flag.Usage()
} }
arg278 := flag.Arg(1) arg279 := flag.Arg(1)
mbTrans279 := thrift.NewTMemoryBufferLen(len(arg278)) mbTrans280 := thrift.NewTMemoryBufferLen(len(arg279))
defer mbTrans279.Close() defer mbTrans280.Close()
_, err280 := mbTrans279.WriteString(arg278) _, err281 := mbTrans280.WriteString(arg279)
if err280 != nil { if err281 != nil {
Usage() Usage()
return return
} }
factory281 := thrift.NewTJSONProtocolFactory() factory282 := thrift.NewTJSONProtocolFactory()
jsProt282 := factory281.GetProtocol(mbTrans279) jsProt283 := factory282.GetProtocol(mbTrans280)
argvalue0 := aurora.NewTaskQuery() argvalue0 := aurora.NewTaskQuery()
err283 := argvalue0.Read(jsProt282) err284 := argvalue0.Read(jsProt283)
if err283 != nil { if err284 != nil {
Usage() Usage()
return return
} }
@ -673,19 +674,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args")
flag.Usage() flag.Usage()
} }
arg284 := flag.Arg(1) arg285 := flag.Arg(1)
mbTrans285 := thrift.NewTMemoryBufferLen(len(arg284)) mbTrans286 := thrift.NewTMemoryBufferLen(len(arg285))
defer mbTrans285.Close() defer mbTrans286.Close()
_, err286 := mbTrans285.WriteString(arg284) _, err287 := mbTrans286.WriteString(arg285)
if err286 != nil { if err287 != nil {
Usage() Usage()
return return
} }
factory287 := thrift.NewTJSONProtocolFactory() factory288 := thrift.NewTJSONProtocolFactory()
jsProt288 := factory287.GetProtocol(mbTrans285) jsProt289 := factory288.GetProtocol(mbTrans286)
argvalue0 := aurora.NewJobKey() argvalue0 := aurora.NewJobKey()
err289 := argvalue0.Read(jsProt288) err290 := argvalue0.Read(jsProt289)
if err289 != nil { if err290 != nil {
Usage() Usage()
return return
} }
@ -718,19 +719,19 @@ func main() {
fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args")
flag.Usage() flag.Usage()
} }
arg292 := flag.Arg(1) arg293 := flag.Arg(1)
mbTrans293 := thrift.NewTMemoryBufferLen(len(arg292)) mbTrans294 := thrift.NewTMemoryBufferLen(len(arg293))
defer mbTrans293.Close() defer mbTrans294.Close()
_, err294 := mbTrans293.WriteString(arg292) _, err295 := mbTrans294.WriteString(arg293)
if err294 != nil { if err295 != nil {
Usage() Usage()
return return
} }
factory295 := thrift.NewTJSONProtocolFactory() factory296 := thrift.NewTJSONProtocolFactory()
jsProt296 := factory295.GetProtocol(mbTrans293) jsProt297 := factory296.GetProtocol(mbTrans294)
argvalue0 := aurora.NewJobConfiguration() argvalue0 := aurora.NewJobConfiguration()
err297 := argvalue0.Read(jsProt296) err298 := argvalue0.Read(jsProt297)
if err297 != nil { if err298 != nil {
Usage() Usage()
return return
} }
@ -743,19 +744,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args")
flag.Usage() flag.Usage()
} }
arg298 := flag.Arg(1) arg299 := flag.Arg(1)
mbTrans299 := thrift.NewTMemoryBufferLen(len(arg298)) mbTrans300 := thrift.NewTMemoryBufferLen(len(arg299))
defer mbTrans299.Close() defer mbTrans300.Close()
_, err300 := mbTrans299.WriteString(arg298) _, err301 := mbTrans300.WriteString(arg299)
if err300 != nil { if err301 != nil {
Usage() Usage()
return return
} }
factory301 := thrift.NewTJSONProtocolFactory() factory302 := thrift.NewTJSONProtocolFactory()
jsProt302 := factory301.GetProtocol(mbTrans299) jsProt303 := factory302.GetProtocol(mbTrans300)
argvalue0 := aurora.NewJobUpdateQuery() argvalue0 := aurora.NewJobUpdateQuery()
err303 := argvalue0.Read(jsProt302) err304 := argvalue0.Read(jsProt303)
if err303 != nil { if err304 != nil {
Usage() Usage()
return return
} }
@ -768,19 +769,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args")
flag.Usage() flag.Usage()
} }
arg304 := flag.Arg(1) arg305 := flag.Arg(1)
mbTrans305 := thrift.NewTMemoryBufferLen(len(arg304)) mbTrans306 := thrift.NewTMemoryBufferLen(len(arg305))
defer mbTrans305.Close() defer mbTrans306.Close()
_, err306 := mbTrans305.WriteString(arg304) _, err307 := mbTrans306.WriteString(arg305)
if err306 != nil { if err307 != nil {
Usage() Usage()
return return
} }
factory307 := thrift.NewTJSONProtocolFactory() factory308 := thrift.NewTJSONProtocolFactory()
jsProt308 := factory307.GetProtocol(mbTrans305) jsProt309 := factory308.GetProtocol(mbTrans306)
argvalue0 := aurora.NewJobUpdateQuery() argvalue0 := aurora.NewJobUpdateQuery()
err309 := argvalue0.Read(jsProt308) err310 := argvalue0.Read(jsProt309)
if err309 != nil { if err310 != nil {
Usage() Usage()
return return
} }
@ -793,19 +794,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args")
flag.Usage() flag.Usage()
} }
arg310 := flag.Arg(1) arg311 := flag.Arg(1)
mbTrans311 := thrift.NewTMemoryBufferLen(len(arg310)) mbTrans312 := thrift.NewTMemoryBufferLen(len(arg311))
defer mbTrans311.Close() defer mbTrans312.Close()
_, err312 := mbTrans311.WriteString(arg310) _, err313 := mbTrans312.WriteString(arg311)
if err312 != nil { if err313 != nil {
Usage() Usage()
return return
} }
factory313 := thrift.NewTJSONProtocolFactory() factory314 := thrift.NewTJSONProtocolFactory()
jsProt314 := factory313.GetProtocol(mbTrans311) jsProt315 := factory314.GetProtocol(mbTrans312)
argvalue0 := aurora.NewJobUpdateRequest() argvalue0 := aurora.NewJobUpdateRequest()
err315 := argvalue0.Read(jsProt314) err316 := argvalue0.Read(jsProt315)
if err315 != nil { if err316 != nil {
Usage() Usage()
return return
} }

View file

@ -1,22 +1,23 @@
// Autogenerated by Thrift Compiler (0.12.0) // Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package main package main
import ( import (
"context" "context"
"flag" "flag"
"fmt" "fmt"
"math" "math"
"net" "net"
"net/url" "net/url"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"github.com/apache/thrift/lib/go/thrift" "github.com/apache/thrift/lib/go/thrift"
"apache/aurora" "apache/aurora"
) )
var _ = aurora.GoUnusedProtection__
func Usage() { func Usage() {
fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
@ -179,19 +180,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args")
flag.Usage() flag.Usage()
} }
arg81 := flag.Arg(1) arg82 := flag.Arg(1)
mbTrans82 := thrift.NewTMemoryBufferLen(len(arg81)) mbTrans83 := thrift.NewTMemoryBufferLen(len(arg82))
defer mbTrans82.Close() defer mbTrans83.Close()
_, err83 := mbTrans82.WriteString(arg81) _, err84 := mbTrans83.WriteString(arg82)
if err83 != nil { if err84 != nil {
Usage() Usage()
return return
} }
factory84 := thrift.NewTJSONProtocolFactory() factory85 := thrift.NewTJSONProtocolFactory()
jsProt85 := factory84.GetProtocol(mbTrans82) jsProt86 := factory85.GetProtocol(mbTrans83)
argvalue0 := aurora.NewTaskQuery() argvalue0 := aurora.NewTaskQuery()
err86 := argvalue0.Read(jsProt85) err87 := argvalue0.Read(jsProt86)
if err86 != nil { if err87 != nil {
Usage() Usage()
return return
} }
@ -204,19 +205,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args")
flag.Usage() flag.Usage()
} }
arg87 := flag.Arg(1) arg88 := flag.Arg(1)
mbTrans88 := thrift.NewTMemoryBufferLen(len(arg87)) mbTrans89 := thrift.NewTMemoryBufferLen(len(arg88))
defer mbTrans88.Close() defer mbTrans89.Close()
_, err89 := mbTrans88.WriteString(arg87) _, err90 := mbTrans89.WriteString(arg88)
if err89 != nil { if err90 != nil {
Usage() Usage()
return return
} }
factory90 := thrift.NewTJSONProtocolFactory() factory91 := thrift.NewTJSONProtocolFactory()
jsProt91 := factory90.GetProtocol(mbTrans88) jsProt92 := factory91.GetProtocol(mbTrans89)
argvalue0 := aurora.NewTaskQuery() argvalue0 := aurora.NewTaskQuery()
err92 := argvalue0.Read(jsProt91) err93 := argvalue0.Read(jsProt92)
if err92 != nil { if err93 != nil {
Usage() Usage()
return return
} }
@ -229,19 +230,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args")
flag.Usage() flag.Usage()
} }
arg93 := flag.Arg(1) arg94 := flag.Arg(1)
mbTrans94 := thrift.NewTMemoryBufferLen(len(arg93)) mbTrans95 := thrift.NewTMemoryBufferLen(len(arg94))
defer mbTrans94.Close() defer mbTrans95.Close()
_, err95 := mbTrans94.WriteString(arg93) _, err96 := mbTrans95.WriteString(arg94)
if err95 != nil { if err96 != nil {
Usage() Usage()
return return
} }
factory96 := thrift.NewTJSONProtocolFactory() factory97 := thrift.NewTJSONProtocolFactory()
jsProt97 := factory96.GetProtocol(mbTrans94) jsProt98 := factory97.GetProtocol(mbTrans95)
argvalue0 := aurora.NewTaskQuery() argvalue0 := aurora.NewTaskQuery()
err98 := argvalue0.Read(jsProt97) err99 := argvalue0.Read(jsProt98)
if err98 != nil { if err99 != nil {
Usage() Usage()
return return
} }
@ -254,19 +255,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args")
flag.Usage() flag.Usage()
} }
arg99 := flag.Arg(1) arg100 := flag.Arg(1)
mbTrans100 := thrift.NewTMemoryBufferLen(len(arg99)) mbTrans101 := thrift.NewTMemoryBufferLen(len(arg100))
defer mbTrans100.Close() defer mbTrans101.Close()
_, err101 := mbTrans100.WriteString(arg99) _, err102 := mbTrans101.WriteString(arg100)
if err101 != nil { if err102 != nil {
Usage() Usage()
return return
} }
factory102 := thrift.NewTJSONProtocolFactory() factory103 := thrift.NewTJSONProtocolFactory()
jsProt103 := factory102.GetProtocol(mbTrans100) jsProt104 := factory103.GetProtocol(mbTrans101)
argvalue0 := aurora.NewJobKey() argvalue0 := aurora.NewJobKey()
err104 := argvalue0.Read(jsProt103) err105 := argvalue0.Read(jsProt104)
if err104 != nil { if err105 != nil {
Usage() Usage()
return return
} }
@ -299,19 +300,19 @@ func main() {
fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args")
flag.Usage() flag.Usage()
} }
arg107 := flag.Arg(1) arg108 := flag.Arg(1)
mbTrans108 := thrift.NewTMemoryBufferLen(len(arg107)) mbTrans109 := thrift.NewTMemoryBufferLen(len(arg108))
defer mbTrans108.Close() defer mbTrans109.Close()
_, err109 := mbTrans108.WriteString(arg107) _, err110 := mbTrans109.WriteString(arg108)
if err109 != nil { if err110 != nil {
Usage() Usage()
return return
} }
factory110 := thrift.NewTJSONProtocolFactory() factory111 := thrift.NewTJSONProtocolFactory()
jsProt111 := factory110.GetProtocol(mbTrans108) jsProt112 := factory111.GetProtocol(mbTrans109)
argvalue0 := aurora.NewJobConfiguration() argvalue0 := aurora.NewJobConfiguration()
err112 := argvalue0.Read(jsProt111) err113 := argvalue0.Read(jsProt112)
if err112 != nil { if err113 != nil {
Usage() Usage()
return return
} }
@ -324,19 +325,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args")
flag.Usage() flag.Usage()
} }
arg113 := flag.Arg(1) arg114 := flag.Arg(1)
mbTrans114 := thrift.NewTMemoryBufferLen(len(arg113)) mbTrans115 := thrift.NewTMemoryBufferLen(len(arg114))
defer mbTrans114.Close() defer mbTrans115.Close()
_, err115 := mbTrans114.WriteString(arg113) _, err116 := mbTrans115.WriteString(arg114)
if err115 != nil { if err116 != nil {
Usage() Usage()
return return
} }
factory116 := thrift.NewTJSONProtocolFactory() factory117 := thrift.NewTJSONProtocolFactory()
jsProt117 := factory116.GetProtocol(mbTrans114) jsProt118 := factory117.GetProtocol(mbTrans115)
argvalue0 := aurora.NewJobUpdateQuery() argvalue0 := aurora.NewJobUpdateQuery()
err118 := argvalue0.Read(jsProt117) err119 := argvalue0.Read(jsProt118)
if err118 != nil { if err119 != nil {
Usage() Usage()
return return
} }
@ -349,19 +350,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args")
flag.Usage() flag.Usage()
} }
arg119 := flag.Arg(1) arg120 := flag.Arg(1)
mbTrans120 := thrift.NewTMemoryBufferLen(len(arg119)) mbTrans121 := thrift.NewTMemoryBufferLen(len(arg120))
defer mbTrans120.Close() defer mbTrans121.Close()
_, err121 := mbTrans120.WriteString(arg119) _, err122 := mbTrans121.WriteString(arg120)
if err121 != nil { if err122 != nil {
Usage() Usage()
return return
} }
factory122 := thrift.NewTJSONProtocolFactory() factory123 := thrift.NewTJSONProtocolFactory()
jsProt123 := factory122.GetProtocol(mbTrans120) jsProt124 := factory123.GetProtocol(mbTrans121)
argvalue0 := aurora.NewJobUpdateQuery() argvalue0 := aurora.NewJobUpdateQuery()
err124 := argvalue0.Read(jsProt123) err125 := argvalue0.Read(jsProt124)
if err124 != nil { if err125 != nil {
Usage() Usage()
return return
} }
@ -374,19 +375,19 @@ func main() {
fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args")
flag.Usage() flag.Usage()
} }
arg125 := flag.Arg(1) arg126 := flag.Arg(1)
mbTrans126 := thrift.NewTMemoryBufferLen(len(arg125)) mbTrans127 := thrift.NewTMemoryBufferLen(len(arg126))
defer mbTrans126.Close() defer mbTrans127.Close()
_, err127 := mbTrans126.WriteString(arg125) _, err128 := mbTrans127.WriteString(arg126)
if err127 != nil { if err128 != nil {
Usage() Usage()
return return
} }
factory128 := thrift.NewTJSONProtocolFactory() factory129 := thrift.NewTJSONProtocolFactory()
jsProt129 := factory128.GetProtocol(mbTrans126) jsProt130 := factory129.GetProtocol(mbTrans127)
argvalue0 := aurora.NewJobUpdateRequest() argvalue0 := aurora.NewJobUpdateRequest()
err130 := argvalue0.Read(jsProt129) err131 := argvalue0.Read(jsProt130)
if err130 != nil { if err131 != nil {
Usage() Usage()
return return
} }

View file

@ -1,6 +1,6 @@
#! /bin/bash #! /bin/bash
THRIFT_VER=0.12.0 THRIFT_VER=0.13.0
if [[ $(thrift -version | grep -e $THRIFT_VER -c) -ne 1 ]]; then if [[ $(thrift -version | grep -e $THRIFT_VER -c) -ne 1 ]]; then
echo "Warning: This wrapper has only been tested with version" $THRIFT_VER; echo "Warning: This wrapper has only been tested with version" $THRIFT_VER;

2
go.mod
View file

@ -7,6 +7,6 @@ require (
github.com/stretchr/testify v1.5.0 github.com/stretchr/testify v1.5.0
) )
replace github.com/apache/thrift v0.12.0 => github.com/ridv/thrift v0.12.2 replace github.com/apache/thrift v0.13.0 => github.com/ridv/thrift v0.13.1
go 1.13 go 1.13

View file

@ -31,32 +31,36 @@ type JobUpdate struct {
func NewJobUpdate() *JobUpdate { func NewJobUpdate() *JobUpdate {
newTask := NewTask() newTask := NewTask()
req := aurora.JobUpdateRequest{} return &JobUpdate{
req.TaskConfig = newTask.TaskConfig() task: newTask,
req.Settings = newUpdateSettings() request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
}
return &JobUpdate{task: newTask, request: &req}
} }
// Creates an update with default values using an AuroraTask as the underlying task configuration.
// This function has a high level understanding of Aurora Tasks and thus will support copying a task that is configured
// to use Thermos.
func JobUpdateFromAuroraTask(task *AuroraTask) *JobUpdate { func JobUpdateFromAuroraTask(task *AuroraTask) *JobUpdate {
newTask := task.Clone() newTask := task.Clone()
req := aurora.JobUpdateRequest{} return &JobUpdate{
req.TaskConfig = newTask.TaskConfig() task: newTask,
req.Settings = newUpdateSettings() request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
}
return &JobUpdate{task: newTask, request: &req}
} }
// JobUpdateFromConfig creates an update with default values using an aurora.TaskConfig
// primitive as the underlying task configuration.
// This function should not be used unless the implications of using a primitive value are understood.
// For example, the primitive has no concept of Thermos.
func JobUpdateFromConfig(task *aurora.TaskConfig) *JobUpdate { func JobUpdateFromConfig(task *aurora.TaskConfig) *JobUpdate {
// Perform a deep copy to avoid unexpected behavior // Perform a deep copy to avoid unexpected behavior
newTask := TaskFromThrift(task) newTask := TaskFromThrift(task)
req := aurora.JobUpdateRequest{} return &JobUpdate{
req.TaskConfig = newTask.TaskConfig() task: newTask,
req.Settings = newUpdateSettings() request: &aurora.JobUpdateRequest{TaskConfig: newTask.TaskConfig(), Settings: newUpdateSettings()},
}
return &JobUpdate{task: newTask, request: &req}
} }
// Set instance count the job will have after the update. // Set instance count the job will have after the update.
@ -106,6 +110,26 @@ func (j *JobUpdate) PulseIntervalTimeout(timeout time.Duration) *JobUpdate {
j.request.Settings.BlockIfNoPulsesAfterMs = thrift.Int32Ptr(int32(timeout.Seconds() * 1000)) j.request.Settings.BlockIfNoPulsesAfterMs = thrift.Int32Ptr(int32(timeout.Seconds() * 1000))
return j return j
} }
func (j *JobUpdate) BatchUpdateStrategy(autoPause bool, batchSize int32) *JobUpdate {
j.request.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{
BatchStrategy: &aurora.BatchJobUpdateStrategy{GroupSize: batchSize, AutopauseAfterBatch: autoPause},
}
return j
}
func (j *JobUpdate) QueueUpdateStrategy(groupSize int32) *JobUpdate {
j.request.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{
QueueStrategy: &aurora.QueueJobUpdateStrategy{GroupSize: groupSize},
}
return j
}
func (j *JobUpdate) VariableBatchStrategy(autoPause bool, batchSizes ...int32) *JobUpdate {
j.request.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{
VarBatchStrategy: &aurora.VariableBatchJobUpdateStrategy{GroupSizes: batchSizes, AutopauseAfterBatch: autoPause},
}
return j
}
func newUpdateSettings() *aurora.JobUpdateSettings { func newUpdateSettings() *aurora.JobUpdateSettings {

View file

@ -244,3 +244,68 @@ func (c *Client) MonitorHostMaintenance(hosts []string,
} }
} }
} }
// AutoPaused monitor is a special monitor for auto pause enabled batch updates. This monitor ensures that the update
// being monitored is capable of auto pausing and has auto pausing enabled. After verifying this information,
// the monitor watches for the job to enter the ROLL_FORWARD_PAUSED state and calculates the current batch
// the update is in using information from the update configuration.
func (c *Client) MonitorAutoPausedUpdate(key aurora.JobUpdateKey, interval, timeout time.Duration) (int, error) {
key.Job = &aurora.JobKey{
Role: key.Job.Role,
Environment: key.Job.Environment,
Name: key.Job.Name,
}
query := aurora.JobUpdateQuery{
UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES,
Limit: 1,
Key: &key,
}
updateDetails, err := c.JobUpdateDetails(query)
if err != nil {
return -1, errors.Wrap(err, "unable to get information about update")
}
if len(updateDetails) == 0 {
return -1, errors.Errorf("details for update could not be found")
}
updateStrategy := updateDetails[0].Update.Instructions.Settings.UpdateStrategy
var batchSizes []int32
switch {
case updateStrategy.IsSetVarBatchStrategy():
batchSizes = updateStrategy.VarBatchStrategy.GroupSizes
if !updateStrategy.VarBatchStrategy.AutopauseAfterBatch {
return -1, errors.Errorf("update does not have auto pause enabled")
}
case updateStrategy.IsSetBatchStrategy():
batchSizes = []int32{updateStrategy.BatchStrategy.GroupSize}
if !updateStrategy.BatchStrategy.AutopauseAfterBatch {
return -1, errors.Errorf("update does not have auto pause enabled")
}
default:
return -1, errors.Errorf("update is not using a batch update strategy")
}
query.UpdateStatuses = append(TerminalUpdateStates(), aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED)
summary, err := c.MonitorJobUpdateQuery(query, interval, timeout)
if err != nil {
return -1, err
}
// Summary 0 is assumed to exist because MonitorJobUpdateQuery will return an error if there is Summaries
if summary[0].State.Status != aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED {
return -1, errors.Errorf("update is in a terminal state %v", summary[0].State.Status)
}
updatingInstances := make(map[int32]struct{})
for _, e := range updateDetails[0].InstanceEvents {
// We only care about INSTANCE_UPDATING actions because we only care that they've been attempted
if e != nil && e.GetAction() == aurora.JobUpdateAction_INSTANCE_UPDATING {
updatingInstances[e.GetInstanceId()] = struct{}{}
}
}
return calculateCurrentBatch(int32(len(updatingInstances)), batchSizes), nil
}

View file

@ -26,6 +26,7 @@ import (
"github.com/aurora-scheduler/gorealis/v2/gen-go/apache/aurora" "github.com/aurora-scheduler/gorealis/v2/gen-go/apache/aurora"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
var r *realis.Client var r *realis.Client
@ -698,7 +699,6 @@ func TestRealisClient_PartitionPolicy(t *testing.T) {
Environment("prod"). Environment("prod").
Role(role). Role(role).
Name("create_thermos_job_partition_policy_test"). Name("create_thermos_job_partition_policy_test").
ExecutorName(aurora.AURORA_EXECUTOR_NAME).
ThermosExecutor(thermosExec). ThermosExecutor(thermosExec).
CPU(.5). CPU(.5).
RAM(64). RAM(64).
@ -723,3 +723,103 @@ func TestRealisClient_PartitionPolicy(t *testing.T) {
} }
} }
func TestRealisClient_UpdateStrategies(t *testing.T) {
// Create a single job
job := realis.NewJob().
Environment("prod").
Role("vagrant").
ThermosExecutor(thermosExec).
CPU(.01).
RAM(4).
Disk(10).
InstanceCount(6).
IsService(true)
// Needed to populate the task config correctly
assert.NoError(t, job.BuildThermosPayload())
strategies := []struct {
jobUpdate *realis.JobUpdate
Name string
}{
{
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
QueueUpdateStrategy(2).
InstanceCount(6).
WatchTime(1000),
Name: "Queue",
},
{
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
BatchUpdateStrategy(false, 2).
InstanceCount(6).
WatchTime(1000),
Name: "Batch",
},
{
jobUpdate: realis.JobUpdateFromAuroraTask(job.AuroraTask()).
VariableBatchStrategy(false, 1, 2, 3).
InstanceCount(6).
WatchTime(1000),
Name: "VarBatch",
},
}
for _, strategy := range strategies {
t.Run("TestRealisClient_UpdateStrategies_"+strategy.Name, func(t *testing.T) {
strategy.jobUpdate.Name("update_strategies_" + strategy.Name)
result, err := r.StartJobUpdate(strategy.jobUpdate, "")
require.NoError(t, err)
assert.NotNil(t, result)
var ok bool
var mErr error
key := *result.GetKey()
if ok, mErr = r.MonitorJobUpdate(key, 5, 240); !ok || mErr != nil {
// Update may already be in a terminal state so don't check for error
assert.NoError(t, r.AbortJobUpdate(key, "Monitor timed out."))
}
assert.NoError(t, r.KillJob(strategy.jobUpdate.JobKey()))
})
}
}
func TestRealisClient_BatchAwareAutoPause(t *testing.T) {
// Create a single job
job := realis.NewJob().
Environment("prod").
Role("vagrant").
Name("BatchAwareAutoPauseTest").
ThermosExecutor(thermosExec).
CPU(.01).
RAM(4).
Disk(10).
InstanceCount(6).
IsService(true)
updateGroups := []int32{1, 2, 3}
strategy := realis.JobUpdateFromAuroraTask(job.AuroraTask()).
VariableBatchStrategy(true, updateGroups...).
InstanceCount(6).
WatchTime(1000)
result, err := r.StartJobUpdate(strategy, "")
require.NoError(t, err)
require.NotNil(t, result)
key := *result.GetKey()
for i := range updateGroups {
curStep, mErr := r.MonitorAutoPausedUpdate(key, time.Second*5, time.Second*240)
if mErr != nil {
// Update may already be in a terminal state so don't check for error
assert.NoError(t, r.AbortJobUpdate(key, "Monitor timed out."))
}
assert.Equal(t, i, curStep)
require.NoError(t, r.ResumeJobUpdate(key, "auto resuming test"))
}
assert.NoError(t, r.KillJob(strategy.JobKey()))
}

31
util.go
View file

@ -40,6 +40,18 @@ func init() {
} }
} }
// TerminalJobUpdateStates returns a slice containing all the terminal states an update may end up in.
// This is a function in order to avoid having a slice that can be accidentally mutated.
func TerminalUpdateStates() []aurora.JobUpdateStatus {
return []aurora.JobUpdateStatus{
aurora.JobUpdateStatus_ROLLED_FORWARD,
aurora.JobUpdateStatus_ROLLED_BACK,
aurora.JobUpdateStatus_ABORTED,
aurora.JobUpdateStatus_ERROR,
aurora.JobUpdateStatus_FAILED,
}
}
func validateAuroraAddress(address string) (string, error) { func validateAuroraAddress(address string) (string, error) {
// If no protocol defined, assume http // If no protocol defined, assume http
@ -73,3 +85,22 @@ func validateAuroraAddress(address string) (string, error) {
return u.String(), nil return u.String(), nil
} }
func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int {
for i, size := range batchSizes {
updatingInstances -= size
if updatingInstances <= 0 {
return i
}
}
// Overflow batches
batchCount := len(batchSizes) - 1
lastBatchIndex := len(batchSizes) - 1
batchCount += int(updatingInstances / batchSizes[lastBatchIndex])
if updatingInstances%batchSizes[lastBatchIndex] != 0 {
batchCount++
}
return batchCount
}

58
util_test.go Normal file
View file

@ -0,0 +1,58 @@
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package realis
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCurrentBatchCalculator(t *testing.T) {
t.Run("singleBatchOverflow", func(t *testing.T) {
curBatch := calculateCurrentBatch(10, []int32{2})
assert.Equal(t, 4, curBatch)
})
t.Run("noInstancesUpdating", func(t *testing.T) {
curBatch := calculateCurrentBatch(0, []int32{2})
assert.Equal(t, 0, curBatch)
})
t.Run("evenMatchSingleBatch", func(t *testing.T) {
curBatch := calculateCurrentBatch(2, []int32{2})
assert.Equal(t, 0, curBatch)
})
t.Run("moreInstancesThanBatches", func(t *testing.T) {
curBatch := calculateCurrentBatch(5, []int32{1, 2})
assert.Equal(t, 2, curBatch)
})
t.Run("moreInstancesThanBatchesDecreasing", func(t *testing.T) {
curBatch := calculateCurrentBatch(5, []int32{2, 1})
assert.Equal(t, 3, curBatch)
})
t.Run("unevenFit", func(t *testing.T) {
curBatch := calculateCurrentBatch(2, []int32{1, 2})
assert.Equal(t, 1, curBatch)
})
t.Run("halfWay", func(t *testing.T) {
curBatch := calculateCurrentBatch(1, []int32{1, 2})
assert.Equal(t, 0, curBatch)
})
}