executor: implement streaming stats API

plugins/driver: update driver interface to support streaming stats

client/tr: use streaming stats api

TODO:
 * how to handle errors and closed channel during stats streaming
 * prevent tight loop if Stats(ctx) returns an error

drivers: update drivers TaskStats RPC to handle streaming results

executor: better error handling in stats rpc

docker: better control and error handling of stats rpc

driver: allow stats to return a recoverable error
This commit is contained in:
Nick Ethier
2018-12-11 15:27:50 -05:00
parent 215a137e4a
commit fbf9a4c772
33 changed files with 1082 additions and 652 deletions

View File

@@ -496,13 +496,13 @@ func (d *Driver) InspectTask(taskID string) (*drivers.TaskStatus, error) {
return handle.TaskStatus(), nil
}
func (d *Driver) TaskStats(taskID string) (*drivers.TaskResourceUsage, error) {
func (d *Driver) TaskStats(ctx context.Context, taskID string, interval time.Duration) (<-chan *drivers.TaskResourceUsage, error) {
handle, ok := d.tasks.Get(taskID)
if !ok {
return nil, drivers.ErrTaskNotFound
}
return handle.exec.Stats()
return handle.exec.Stats(ctx, interval)
}
func (d *Driver) TaskEvents(ctx context.Context) (<-chan *drivers.TaskEvent, error) {