X Tutup
Skip to content

Add tail and since to service logs#31500

Merged
vdemeester merged 1 commit intomoby:masterfrom
dperny:fix-service-logs-cli
Mar 14, 2017
Merged

Add tail and since to service logs#31500
vdemeester merged 1 commit intomoby:masterfrom
dperny:fix-service-logs-cli

Conversation

@dperny
Copy link
Contributor

@dperny dperny commented Mar 2, 2017

- What I did
This change adds the ability to do --tail and --since on docker service logs.

Should also fix #31307.

Part of a series of changes in #31399.

- How I did it
It wires up the API endpoints to each other and fixes some older bugs.

- How to verify it
Make a service, note how passing --tail and --since

- Description for the changelog

docker service logs now supports since and tail options.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there should be a different message for parse errors and negative values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I submit a CFB: Call For Bikeshedding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm sorry, I mean it is legitimately a bad error message and I do need help getting it better, and it would benefit from some light bikeshedding to get right)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion:

if err != nil {
        return errors.New(`Tail must be a non-negative integer, or "all"`)
}
if t < 0 {
        return errors.New("negative Tail values are not supported")
}

(I don't actually think the current log message is bad for the second case, but I have a slight preference for talking about the domain of the parameter, instead of what a negative parameter would do if it was supported.)

@aaronlehmann
Copy link

Can you please add tests for these features?

@dperny
Copy link
Contributor Author

dperny commented Mar 2, 2017

I'm finally remembering to run make test before I push but now the hurdle is remembering to actually write new tests.

I'll get right on it @aaronlehmann .

@dperny dperny force-pushed the fix-service-logs-cli branch from ce43475 to c35a984 Compare March 3, 2017 23:48
@dperny
Copy link
Contributor Author

dperny commented Mar 3, 2017

pushed up new changes. tests are gonna fail, this requires a revendor from swarmkit master, which someone mentioned is currently in a different PR

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: how about $(seq 1 6)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on local

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: how about $(seq 1 6)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: Seems like the sleep could be a lot shorter, since we're parsing the timestamps later on as an argument to --since, instead of fudging it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this sleep to be shorter.

Copy link

@aaronlehmann aaronlehmann Mar 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: might be better to use waitAndAssert to wait for docker service logs to return the full set of logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitAndAssert is undocumented, headache-causing voodoo magic and I was trying to avoid it if at all possible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be racy. If service logs runs before the container finishes its output, the test might fail. Should we wait for the task to finish running instead of waiting for it to start running?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're almost certainly correct, and the possibility of a race also exists in the since test as well, as I've just realized (sleeping does not guarantee that anything else has happened on the system in the meantime.)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah
Copy link
Member

This is not introducing API changes (i.e. the API already supported this, and is documented?)

@dperny
Copy link
Contributor Author

dperny commented Mar 6, 2017

@thaJeztah I'm not sure if this is documented or not, but the API endpoints and CLI flags all existed, they just weren't wired up.

@thaJeztah
Copy link
Member

It's probably here; https://github.com/docker/docker/blob/f9bd8ec8b268581f93095c5a80679f0a8ff498bf/api/swagger.yaml#L7646-L7726, but check if it's all documented.

Given that it's been an experimental feature, if we expect this feature to leave experimental in docker 17.04, it should be mentioned in the API changes for API 1.27 https://github.com/docker/docker/blob/3a88a24d23e6eb1ca521cd9ab6e306d4ba1c1464/docs/api/version-history.md#v127-api-changes (or 1.28 if it's gonna leave experimental in 17.05

@dperny
Copy link
Contributor Author

dperny commented Mar 7, 2017

Right now there is a flaky test in my local branch that I'm trying to sort out before I finish this PR.

@dperny dperny force-pushed the fix-service-logs-cli branch from c35a984 to 4481bba Compare March 7, 2017 21:54
@dperny
Copy link
Contributor Author

dperny commented Mar 7, 2017

Fixed the flaky integration test.

@dperny dperny mentioned this pull request Mar 7, 2017
12 tasks
@dperny
Copy link
Contributor Author

dperny commented Mar 8, 2017

There probably needs to be a revendoring for the integration test to pass

@dperny
Copy link
Contributor Author

dperny commented Mar 8, 2017

This definitely need revendoring for the integration tests to pass. There is a separate open PR for revendoring swarmkit.

@dperny dperny mentioned this pull request Mar 8, 2017
@thaJeztah
Copy link
Member

@dperny #31535 (comment) was merged

@dperny
Copy link
Contributor Author

dperny commented Mar 8, 2017

Rebasing, running tests, and pushing now.

@dperny dperny force-pushed the fix-service-logs-cli branch from 4481bba to fe9e67d Compare March 8, 2017 21:50
@aluzzardi aluzzardi added the priority/P1 Important: P1 issues are a top priority and a must-have for the next release. label Mar 10, 2017
@aluzzardi aluzzardi added this to the 17.04.0 milestone Mar 10, 2017
@aluzzardi
Copy link
Member

Tentatively targeting 17.04.0

@aluzzardi
Copy link
Member

@dperny I see a few of @aaronlehmann's comments not being addressed - could you double check?

@dperny
Copy link
Contributor Author

dperny commented Mar 10, 2017

His comments don't appear addressed because the diff for those particular lines is the same; the comments have been addressed after those lines.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: maybe use errors.Wrap to add some context to the error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: maybe use errors.Wrap to add some context to the error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand, yes. There's a stream from the engine to the manager, and a stream from the manager to the client. While lines from different nodes could get interleaved, I can't think of any way that log lines from a single node would change their order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone, I cannot remember who, has mentioned that they have seen engine-side logs come back in the wrong order. I don't have proof, this is something like a third-hand account, i'm not sure if it's a bug or a consequence of some technical limitation, and i'm not even sure it's real. would it be alright for me to leave these TODOs in, in case the tests fail later, so someone might know why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've reworded the TODOs into regular comments.

@aaronlehmann
Copy link

LGTM

@dperny dperny force-pushed the fix-service-logs-cli branch from fe9e67d to 6860fe5 Compare March 10, 2017 22:46

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be TestServiceLogsCompleteness

Comment there looks good, though

This change adds the ability to do --tail and --since on docker service
logs. It wires up the API endpoints to each other and fixes some older
bugs. It adds integration tests for these new features.

Signed-off-by: Drew Erny <drew.erny@docker.com>
@dperny dperny force-pushed the fix-service-logs-cli branch from 6860fe5 to 8dc437b Compare March 10, 2017 22:59
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐸

@vdemeester vdemeester merged commit 1d46080 into moby:master Mar 14, 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

Labels

impact/changelog impact/cli priority/P1 Important: P1 issues are a top priority and a must-have for the next release. status/4-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker Remote API 1.26 - Service Logs cannot specify tail

6 participants

X Tutup