Simplifying KillJob API implementation (#52)
By submitting an empty set to the thrift call, the Aurora scheduler will look for active tasks itself.
This commit is contained in:
parent
a941bcb679
commit
dbb08ded90
1 changed files with 13 additions and 21 deletions
12
realis.go
12
realis.go
|
@ -583,19 +583,13 @@ func (r *realisClient) RealisConfig() *RealisConfig {
|
|||
|
||||
// Sends a kill message to the scheduler for all active tasks under a job.
|
||||
func (r *realisClient) KillJob(key *aurora.JobKey) (*aurora.Response, error) {
|
||||
|
||||
var instanceIds map[int32]bool
|
||||
var clientErr, err error
|
||||
var resp *aurora.Response
|
||||
instanceIds, err = r.GetInstanceIds(key, aurora.ACTIVE_STATES)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Could not retrieve relevant task instance IDs")
|
||||
}
|
||||
|
||||
if len(instanceIds) > 0 {
|
||||
retryErr := ExponentialBackoff(*r.config.backoff, func() (bool, error) {
|
||||
resp, clientErr = r.thriftCallHelper(func() (*aurora.Response, error) {
|
||||
return r.client.KillTasks(key, instanceIds, "")
|
||||
// Giving the KillTasks thrift call an empty set tells the Aurora scheduler to kill all active shards
|
||||
return r.client.KillTasks(key, nil, "")
|
||||
})
|
||||
|
||||
if clientErr != nil {
|
||||
|
@ -610,8 +604,6 @@ func (r *realisClient) KillJob(key *aurora.JobKey) (*aurora.Response, error) {
|
|||
}
|
||||
return resp, nil
|
||||
}
|
||||
return nil, errors.New("No tasks in the Active state")
|
||||
}
|
||||
|
||||
// Sends a create job message to the scheduler with a specific job configuration.
|
||||
// Although this API is able to create service jobs, it is better to use CreateService instead
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue