Merge pull request #1559 from mlaventure/fix-oor-panic

client: Prevent Out-Of-Range panic in task.Metrics()
This commit is contained in:
Phil Estes
2017-09-26 14:39:39 -04:00
committed by GitHub
2 changed files with 74 additions and 0 deletions

View File

@@ -436,6 +436,15 @@ func (t *task) Metrics(ctx context.Context) (*types.Metric, error) {
if err != nil {
return nil, errdefs.FromGRPC(err)
}
if response.Metrics == nil {
_, err := t.Status(ctx)
if err != nil && errdefs.IsNotFound(err) {
return nil, err
}
return nil, errors.New("no metrics received")
}
return response.Metrics[0], nil
}