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 Support for Service Task Logs #32015

Merged
merged 1 commit into from Apr 4, 2017

Conversation

@dperny
Contributor

dperny commented Mar 22, 2017

This PR probably needs a docs update too. I'm gonna wait until it passes design review before I update the docs

- What I did
Refactored the API to more easily accept new endpoints. Added REST, client, and CLI endpoints for getting logs from a specific task. All that is needed after this commit to enable arbitrary service log selectors is a REST endpoint.

Added a --task flag to docker service logs to get logs for a specific task.

Added search by task if a service wasn't found.

- How I did it
Refactored a bunch of code, added a couple of new endpoints.

- How to verify it
Added a new integration test. You can also try running docker service logs --task [taskid].

- Description for the changelog
docker service logs command now also gets task logs. Added /task/{id}/logs REST endpoint.

- A picture of a cute animal (not mandatory but encouraged)
image

/cc @aluzzardi

@AkihiroSuda

This comment has been minimized.

Show comment
Hide comment
@AkihiroSuda
Member

AkihiroSuda commented Mar 23, 2017

@dnephin

Will task ids and service ids ever overlap?

Could we just accept all the ids without adding a new flag?

Show outdated Hide outdated api/server/router/swarm/cluster_routes.go Outdated
Show outdated Hide outdated integration-cli/docker_cli_service_logs_experimental_test.go Outdated
@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 23, 2017

Contributor

I'm not sure the right options for the CLI UI. What I've presented is my best effort as to what I think is correct. Ideally I'd like to support any arbitrary combination of task/service/node logs to reflect what the swarmkit GRPC can do with log selectors. However, that concept DOES NOT map to the existing REST API paradigm, and, by extension, to the CLI.

Someone is going to come in here, like the last PR about this, and suggest that we do like filters or whatever and I agree with you but I'm really boxed in by the REST paradigm, which is not conducive to arbitrary selectors like GRPC API is. We'd need an extra API endpoint that does have the format /service/{id}/logs, like maybe /swarm/logs?service=wombo&task=combo which DOES map to the LogSelector. That's part of what I've enabled by making that getSwarmLogs() handler like it is; we can just add a new route when we decide what we want that route should be named.

I'm going to alter the CLI to have the pattern docker service logs SERVICE|TASK, no flags. If you want something better, fight me with your PRs. Both fox no items final destination.

Contributor

dperny commented Mar 23, 2017

I'm not sure the right options for the CLI UI. What I've presented is my best effort as to what I think is correct. Ideally I'd like to support any arbitrary combination of task/service/node logs to reflect what the swarmkit GRPC can do with log selectors. However, that concept DOES NOT map to the existing REST API paradigm, and, by extension, to the CLI.

Someone is going to come in here, like the last PR about this, and suggest that we do like filters or whatever and I agree with you but I'm really boxed in by the REST paradigm, which is not conducive to arbitrary selectors like GRPC API is. We'd need an extra API endpoint that does have the format /service/{id}/logs, like maybe /swarm/logs?service=wombo&task=combo which DOES map to the LogSelector. That's part of what I've enabled by making that getSwarmLogs() handler like it is; we can just add a new route when we decide what we want that route should be named.

I'm going to alter the CLI to have the pattern docker service logs SERVICE|TASK, no flags. If you want something better, fight me with your PRs. Both fox no items final destination.

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 23, 2017

Contributor

Fixed the CLI UI. Fixed the tests.

Contributor

dperny commented Mar 23, 2017

Fixed the CLI UI. Fixed the tests.

@cowlicks

This comment has been minimized.

Show comment
Hide comment
@cowlicks

cowlicks commented Mar 25, 2017

LGTM

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 30, 2017

Contributor

@dnephin Moved service log handling to a selector as suggested.

Contributor

dperny commented Mar 30, 2017

@dnephin Moved service log handling to a selector as suggested.

Show outdated Hide outdated daemon/cluster/services.go Outdated
Show outdated Hide outdated daemon/cluster/services.go Outdated
Show outdated Hide outdated daemon/cluster/services.go Outdated
@aluzzardi

This comment has been minimized.

Show comment
Hide comment
@aluzzardi

aluzzardi Mar 30, 2017

Member

Minor comments, overall LGTM

Member

aluzzardi commented Mar 30, 2017

Minor comments, overall LGTM

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 30, 2017

Contributor

@aluzzardi fixed nits

Contributor

dperny commented Mar 30, 2017

@aluzzardi fixed nits

Show outdated Hide outdated cli/command/service/logs.go Outdated
Show outdated Hide outdated cli/command/service/logs.go Outdated
@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 31, 2017

Contributor

@vdemeester fixed.

Contributor

dperny commented Mar 31, 2017

@vdemeester fixed.

@vieux

This comment has been minimized.

Show comment
Hide comment
@vieux

vieux Mar 31, 2017

Collaborator

@dperny can you update the documentation ? (at least the API doc to add the endpoint)

Collaborator

vieux commented Mar 31, 2017

@dperny can you update the documentation ? (at least the API doc to add the endpoint)

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 31, 2017

Contributor

I would like to do so but I am unclear on how to go about it.

Contributor

dperny commented Mar 31, 2017

I would like to do so but I am unclear on how to go about it.

@vieux

This comment has been minimized.

Show comment
Hide comment
@vieux

vieux Mar 31, 2017

Collaborator

you need to edit api/swagger.yaml you can look at service logs for inspiration :P

Collaborator

vieux commented Mar 31, 2017

you need to edit api/swagger.yaml you can look at service logs for inspiration :P

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Mar 31, 2017

Contributor

updated api/swagger.yml to reflect task logs. The updated API documentation may not be totally correct (it is copied from service logs, which is also not totally correct for pre-existing reasons) and will need to be updated again before service logs are moved out of experimental.

Contributor

dperny commented Mar 31, 2017

updated api/swagger.yml to reflect task logs. The updated API documentation may not be totally correct (it is copied from service logs, which is also not totally correct for pre-existing reasons) and will need to be updated again before service logs are moved out of experimental.

Show outdated Hide outdated api/swagger.yaml Outdated
Show outdated Hide outdated api/swagger.yaml Outdated
Show outdated Hide outdated api/swagger.yaml Outdated
@vieux

This comment has been minimized.

Show comment
Hide comment
@vieux

vieux Apr 1, 2017

Collaborator

LGTM

Collaborator

vieux commented Apr 1, 2017

LGTM

@vdemeester

LGTM 🐸
/cc @thaJeztah @dnephin

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Apr 3, 2017

Contributor

@dnephin fixed concerns.

Contributor

dperny commented Apr 3, 2017

@dnephin fixed concerns.

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Apr 3, 2017

Contributor

@dnephin actually fixed all the concerns the right way this time.

Contributor

dperny commented Apr 3, 2017

@dnephin actually fixed all the concerns the right way this time.

@dnephin

dnephin approved these changes Apr 3, 2017

LGTM!

@vieux

This comment has been minimized.

Show comment
Hide comment
@vieux

vieux Apr 4, 2017

Collaborator

@dperny I think the error is legit

Collaborator

vieux commented Apr 4, 2017

@dperny I think the error is legit

Add support for task and arbitrary combo logs
Refactored the API to more easily accept new endpoints. Added REST,
client, and CLI endpoints for getting logs from a specific task. All
that is needed after this commit to enable arbitrary service log
selectors is a REST endpoint and handler.

Task logs can be retrieved by putting in a task ID at the CLI instead of
a service ID.

Signed-off-by: Drew Erny <drew.erny@docker.com>
@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Apr 4, 2017

Contributor

Forgot to strip a trailing newline, it's fixed now.

Contributor

dperny commented Apr 4, 2017

Forgot to strip a trailing newline, it's fixed now.

@vieux

This comment has been minimized.

Show comment
Hide comment
@vieux

vieux Apr 4, 2017

Collaborator

LGTM 👍

Collaborator

vieux commented Apr 4, 2017

LGTM 👍

@vieux vieux merged commit 170be9c into moby:master Apr 4, 2017

6 checks passed

dco-signed All commits are signed
experimental Jenkins build Docker-PRs-experimental 32490 has succeeded
Details
janky Jenkins build Docker-PRs 41100 has succeeded
Details
powerpc Jenkins build Docker-PRs-powerpc 1272 has succeeded
Details
windowsRS1 Jenkins build Docker-PRs-WoW-RS1 12202 has succeeded
Details
z Jenkins build Docker-PRs-s390x 1106 has succeeded
Details

@GordonTheTurtle GordonTheTurtle added this to the 17.05.0 milestone Apr 4, 2017

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Apr 4, 2017

Member

ping @dperny erm;

Added docker service logs --task command and /task/{id}/logs REST endpoint.

Looks like the --task flag is not part of this PR, correct?

Also, can you open a pull request to add a mention of this endpoint to the API changelog; https://github.com/docker/docker/blob/master/docs/api/version-history.md#v129-api-changes ?

Member

thaJeztah commented Apr 4, 2017

ping @dperny erm;

Added docker service logs --task command and /task/{id}/logs REST endpoint.

Looks like the --task flag is not part of this PR, correct?

Also, can you open a pull request to add a mention of this endpoint to the API changelog; https://github.com/docker/docker/blob/master/docs/api/version-history.md#v129-api-changes ?

return err
}
maxLength = getMaxLength(task.Slot)
responseBody, err = cli.TaskLogs(ctx, opts.target, options)

This comment has been minimized.

@thaJeztah

thaJeztah Apr 4, 2017

Member

Do we have to make this API-version dependent? Or is it ok to have this fail when talking to an older daemon (given that it was "experimental" so far?

@thaJeztah

thaJeztah Apr 4, 2017

Member

Do we have to make this API-version dependent? Or is it ok to have this fail when talking to an older daemon (given that it was "experimental" so far?

This comment has been minimized.

@dperny

dperny Apr 4, 2017

Contributor

Oh hmmmm I hadn't thought about that...

@dperny

dperny Apr 4, 2017

Contributor

Oh hmmmm I hadn't thought about that...

This comment has been minimized.

@dperny

dperny Apr 4, 2017

Contributor

I may be mistaken but I BELIEVE if you talk to an older daemon, it's going to fail in the same way it would if I patched this, just with a less helpful error message.

@dperny

dperny Apr 4, 2017

Contributor

I may be mistaken but I BELIEVE if you talk to an older daemon, it's going to fail in the same way it would if I patched this, just with a less helpful error message.

This comment has been minimized.

@thaJeztah

thaJeztah Apr 4, 2017

Member

Well, it's still experimental, so "ok" to break, but what happens with a 17.03 / 17.04 client talking to a 17.05 daemon?

@thaJeztah

thaJeztah Apr 4, 2017

Member

Well, it's still experimental, so "ok" to break, but what happens with a 17.03 / 17.04 client talking to a 17.05 daemon?

@dperny

This comment has been minimized.

Show comment
Hide comment
@dperny

dperny Apr 4, 2017

Contributor

@thaJeztah Yes, the --task part of this was dropped. Sorry about that. I'll edit the original PR message.

Contributor

dperny commented Apr 4, 2017

@thaJeztah Yes, the --task part of this was dropped. Sorry about that. I'll edit the original PR message.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Apr 4, 2017

Member

Yes, the --task part of this was dropped. Sorry about that. I'll edit the original PR message.

Thanks! I was confused for a bit, couldn't find the flag LOL

Member

thaJeztah commented Apr 4, 2017

Yes, the --task part of this was dropped. Sorry about that. I'll edit the original PR message.

Thanks! I was confused for a bit, couldn't find the flag LOL

@thaJeztah thaJeztah removed the impact/cli label Apr 4, 2017

dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment