POC on how verification function would work. Update function should have something similar.

This commit is contained in:
Renán Del Valle 2021-04-29 20:08:19 -07:00
parent 9999a0834d
commit 34a41e86a8
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
2 changed files with 22 additions and 3 deletions

View file

@ -672,7 +672,23 @@ func (r *realisClient) CreateJob(auroraJob Job) (*aurora.Response, error) {
func() (*aurora.Response, error) {
return r.client.CreateJob(context.TODO(), auroraJob.JobConfig())
},
nil,
func() (*aurora.Response, bool) {
getTaskResp, err := r.client.GetTasksStatus(
context.TODO(),
&aurora.TaskQuery{JobKeys: []*aurora.JobKey{auroraJob.JobKey()}},
)
if err != nil {
return nil, false
}
tasks := response.ScheduleStatusResult(getTaskResp).GetTasks()
if len(tasks) != int(auroraJob.GetInstanceCount()) {
return nil, false
}
return nil, true
},
)
if retryErr != nil {

View file

@ -197,9 +197,12 @@ func (r *realisClient) thriftCallWithRetries(
// Allow caller to provide a function which checks if the original call was successful before
// it timed out.
if verifyOnTimeout != nil {
resp, ok := verifyOnTimeout()
verifyResp, ok := verifyOnTimeout()
if ok {
return resp, nil
r.logger.debugPrint("verified that the call went through successfully")
// Response might be different than the original.
return verifyResp, nil
}
}
}