update api change and remove os.exit

This commit is contained in:
Kumar Krishna 2016-11-14 23:16:36 -08:00
parent 8905233375
commit 3b10c10dd1
3 changed files with 39 additions and 9 deletions

View file

@ -25,7 +25,7 @@ type UpdateJob struct {
}
// Create a default UpdateJob object.
func NewUpdateJob(config *aurora.TaskConfig) *UpdateJob {
func NewDefaultUpdateJob(config *aurora.TaskConfig) *UpdateJob {
req := aurora.NewJobUpdateRequest()
req.TaskConfig = config
@ -66,6 +66,37 @@ func NewUpdateJob(config *aurora.TaskConfig) *UpdateJob {
return &UpdateJob{job, req}
}
func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings) *UpdateJob {
req := aurora.NewJobUpdateRequest()
req.TaskConfig = config
req.Settings = settings
job := NewJob().(AuroraJob)
job.jobConfig.TaskConfig = config
// Rebuild resource map from TaskConfig
for ptr := range config.Resources {
if ptr.NumCpus != nil {
job.resources["cpu"].NumCpus = ptr.NumCpus
continue // Guard against Union violations that Go won't enforce
}
if ptr.RamMb != nil {
job.resources["ram"].RamMb = ptr.RamMb
continue
}
if ptr.DiskMb != nil {
job.resources["disk"].DiskMb = ptr.DiskMb
continue
}
}
//TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior
return &UpdateJob{job, req}
}
// Set instance count the job will have after the update.
func (u *UpdateJob) InstanceCount(inst int32) *UpdateJob {
u.req.InstanceCount = inst