-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add streaming API for tasks #2773
base: master
Are you sure you want to change the base?
Conversation
@@ -170,3 +180,43 @@ func (s *Server) ListTasks(ctx context.Context, request *api.ListTasksRequest) ( | |||
Tasks: tasks, | |||
}, nil | |||
} | |||
|
|||
// ListTasksStream is the same as ListTasks, but instead of sending back all | |||
// tasks as one gRPC message, it brakes the messages up into chunks and sends |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: breaks
manager/controlapi/task.go
Outdated
// slice the first set of tasks off | ||
var theseTasks []*api.Task | ||
theseTasks, tasks = tasks[:maxTasksInResponse], tasks[maxTasksInResponse:] | ||
stream.Send(&api.ListTasksResponse{Tasks: theseTasks}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess stream.Send
can return an error, shouldn't it be checked ?
manager/controlapi/task.go
Outdated
// send, as the last message, an empty list of tasks, if we happen to have | ||
// a number of tasks that aligns to a maxTasksInResponse size. this | ||
// behavior is fine and expected. | ||
stream.Send(&api.ListTasksResponse{Tasks: tasks}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here?
Given that this changes the API; is this still a candidate for backporting to the 18.09 codebase? (maybe yes, maybe no, just leaving this here as I think of it now 😄 ) |
@thaJeztah: it actually doesn't change the public API of the docker engine. it changes the swarmkit API, but that API is more-or-less nonpublic, especially as far as the engine is concerned. you'll see in a bit, i'm running tests on the moby/moby branch right now before i push up that pull request. |
011e36e
to
657c0aa
Compare
As documented in moby/moby#37997, if there are too many tasks, then attempting to list them all may cause the size of the response to exceed the gRPC max message size. To avoid this case, introduct a ListTasksStream endpoint, which uses the gRPC streaming API to send tasks as a stream, avoiding exceeding the max message size. Signed-off-by: Drew Erny <drew.erny@docker.com>
657c0aa
to
102bbc2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the helpful comments!
ping @dperny looks like this needs a rebase |
- What I did
As documented in moby/moby#37997, if there are too many tasks, then attempting to list them all may cause the size of the response to exceed the gRPC max message size.
To avoid this case, introduct a ListTasksStream endpoint, which uses the gRPC streaming API to send tasks as a stream, avoiding exceeding the max message size.
- How I did it
Adds a new RPC to the ControlAPI server called
ListTasksStream
, which returns tasks as a stream instead of as one giant response.- How to test it
Includes automated test.