check if the resposne schedule result is nil
This commit is contained in:
parent
e12370ffbb
commit
900f054633
2 changed files with 11 additions and 6 deletions
|
@ -528,19 +528,20 @@ func (r *realisClient) GetInstanceIds(key *aurora.JobKey, states map[aurora.Sche
|
|||
fmt.Println("error in ReestablishConn: ", err1)
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Error querying Aurora Scheduler for active IDs")
|
||||
}
|
||||
|
||||
resp, err = response.ResponseCodeCheck(resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tasks := response.ScheduleStatusResult(resp).GetTasks()
|
||||
|
||||
jobInstanceIds := make(map[int32]bool)
|
||||
for _, task := range tasks {
|
||||
jobInstanceIds[task.GetAssignedTask().GetInstanceId()] = true
|
||||
}
|
||||
|
||||
return jobInstanceIds, nil
|
||||
|
||||
}
|
||||
|
||||
func (r *realisClient) GetJobUpdateSummaries(jobUpdateQuery *aurora.JobUpdateQuery) (*aurora.Response, error) {
|
||||
|
|
|
@ -17,8 +17,9 @@ package response
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/rdelval/gorealis/gen-go/apache/aurora"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rdelval/gorealis/gen-go/apache/aurora"
|
||||
)
|
||||
|
||||
// Get key from a response created by a StartJobUpdate call
|
||||
|
@ -35,6 +36,9 @@ func ScheduleStatusResult(resp *aurora.Response) *aurora.ScheduleStatusResult_ {
|
|||
}
|
||||
|
||||
func ResponseCodeCheck(resp *aurora.Response) (*aurora.Response, error) {
|
||||
if resp == nil {
|
||||
return resp, errors.New("Got nil Response")
|
||||
}
|
||||
if resp.GetResponseCode() != aurora.ResponseCode_OK {
|
||||
return resp, errors.New(CombineMessage(resp))
|
||||
}
|
||||
|
@ -50,7 +54,7 @@ func CombineMessage(resp *aurora.Response) string {
|
|||
}
|
||||
|
||||
if buffer.Len() > 0 {
|
||||
buffer.Truncate(buffer.Len()-2) // Get rid of trailing comma + space
|
||||
buffer.Truncate(buffer.Len() - 2) // Get rid of trailing comma + space
|
||||
}
|
||||
return buffer.String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue