Refactor updatejob to JobUpdate to be more in line with Aurora terminology.
This commit is contained in:
parent
76300782ba
commit
b0c25e9013
1 changed files with 24 additions and 27 deletions
|
@ -19,23 +19,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Structure to collect all information required to create job update
|
// Structure to collect all information required to create job update
|
||||||
type UpdateJob struct {
|
type JobUpdate struct {
|
||||||
*AuroraJob // SetInstanceCount for job is hidden, access via full qualifier
|
Job *AuroraJob
|
||||||
req *aurora.JobUpdateRequest
|
request *aurora.JobUpdateRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a default UpdateJob object.
|
// Create a default JobUpdate object.
|
||||||
func NewDefaultUpdateJob(config *aurora.TaskConfig) *UpdateJob {
|
func NewDefaultJobUpdate(job *AuroraJob) *JobUpdate {
|
||||||
|
|
||||||
req := aurora.JobUpdateRequest{}
|
req := aurora.JobUpdateRequest{}
|
||||||
req.TaskConfig = config
|
req.TaskConfig = job.jobConfig.TaskConfig
|
||||||
req.Settings = NewUpdateSettings()
|
req.Settings = NewUpdateSettings()
|
||||||
|
|
||||||
job := NewJob()
|
|
||||||
job.jobConfig.TaskConfig = config
|
|
||||||
|
|
||||||
// Rebuild resource map from TaskConfig
|
// Rebuild resource map from TaskConfig
|
||||||
for _, ptr := range config.Resources {
|
for _, ptr := range job.jobConfig.TaskConfig.Resources {
|
||||||
if ptr.NumCpus != nil {
|
if ptr.NumCpus != nil {
|
||||||
job.resources["cpu"].NumCpus = ptr.NumCpus
|
job.resources["cpu"].NumCpus = ptr.NumCpus
|
||||||
continue // Guard against Union violations that Go won't enforce
|
continue // Guard against Union violations that Go won't enforce
|
||||||
|
@ -62,10 +59,10 @@ func NewDefaultUpdateJob(config *aurora.TaskConfig) *UpdateJob {
|
||||||
req.Settings.RollbackOnFailure = true
|
req.Settings.RollbackOnFailure = true
|
||||||
|
|
||||||
//TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior
|
//TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior
|
||||||
return &UpdateJob{AuroraJob: job, req: &req}
|
return &JobUpdate{Job: job, request: &req}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings) *UpdateJob {
|
func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings) *JobUpdate {
|
||||||
|
|
||||||
req := aurora.NewJobUpdateRequest()
|
req := aurora.NewJobUpdateRequest()
|
||||||
req.TaskConfig = config
|
req.TaskConfig = config
|
||||||
|
@ -93,48 +90,48 @@ func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior
|
//TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior
|
||||||
return &UpdateJob{AuroraJob: job, req: req}
|
return &JobUpdate{Job: job, request: req}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set instance count the job will have after the update.
|
// Set instance count the job will have after the update.
|
||||||
func (u *UpdateJob) InstanceCount(inst int32) *UpdateJob {
|
func (u *JobUpdate) InstanceCount(inst int32) *JobUpdate {
|
||||||
u.req.InstanceCount = inst
|
u.request.InstanceCount = inst
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max number of instances being updated at any given moment.
|
// Max number of instances being updated at any given moment.
|
||||||
func (u *UpdateJob) BatchSize(size int32) *UpdateJob {
|
func (u *JobUpdate) BatchSize(size int32) *JobUpdate {
|
||||||
u.req.Settings.UpdateGroupSize = size
|
u.request.Settings.UpdateGroupSize = size
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimum number of seconds a shard must remain in RUNNING state before considered a success.
|
// Minimum number of seconds a shard must remain in RUNNING state before considered a success.
|
||||||
func (u *UpdateJob) WatchTime(ms int32) *UpdateJob {
|
func (u *JobUpdate) WatchTime(ms int32) *JobUpdate {
|
||||||
u.req.Settings.MinWaitInInstanceRunningMs = ms
|
u.request.Settings.MinWaitInInstanceRunningMs = ms
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all instances in a group to be done before moving on.
|
// Wait for all instances in a group to be done before moving on.
|
||||||
func (u *UpdateJob) WaitForBatchCompletion(batchWait bool) *UpdateJob {
|
func (u *JobUpdate) WaitForBatchCompletion(batchWait bool) *JobUpdate {
|
||||||
u.req.Settings.WaitForBatchCompletion = batchWait
|
u.request.Settings.WaitForBatchCompletion = batchWait
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max number of instance failures to tolerate before marking instance as FAILED.
|
// Max number of instance failures to tolerate before marking instance as FAILED.
|
||||||
func (u *UpdateJob) MaxPerInstanceFailures(inst int32) *UpdateJob {
|
func (u *JobUpdate) MaxPerInstanceFailures(inst int32) *JobUpdate {
|
||||||
u.req.Settings.MaxPerInstanceFailures = inst
|
u.request.Settings.MaxPerInstanceFailures = inst
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max number of FAILED instances to tolerate before terminating the update.
|
// Max number of FAILED instances to tolerate before terminating the update.
|
||||||
func (u *UpdateJob) MaxFailedInstances(inst int32) *UpdateJob {
|
func (u *JobUpdate) MaxFailedInstances(inst int32) *JobUpdate {
|
||||||
u.req.Settings.MaxFailedInstances = inst
|
u.request.Settings.MaxFailedInstances = inst
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// When False, prevents auto rollback of a failed update.
|
// When False, prevents auto rollback of a failed update.
|
||||||
func (u *UpdateJob) RollbackOnFail(rollback bool) *UpdateJob {
|
func (u *JobUpdate) RollbackOnFail(rollback bool) *JobUpdate {
|
||||||
u.req.Settings.RollbackOnFailure = rollback
|
u.request.Settings.RollbackOnFailure = rollback
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue