Implement the "logs" endpoint for the journald log driver#13707
Implement the "logs" endpoint for the journald log driver#13707LK4D4 merged 1 commit intomoby:masterfrom
Conversation
|
Any comment from upstream? This would be a really nice feature. I already have logging people asking me about it. |
|
Think they've been busy bug-hunting for the release. |
|
I get |
|
I can't reproduce the first symptom; can you give me more details about how you're getting it to happen? The duplicate log data doesn't appear to be driver-specific (now that I know what to look for, I'm seeing it with the journald driver, too), but it goes away if I revert 153f98b. |
|
@nalind I run and then just do |
|
Ah, thanks! It's still not giving me the It looks as though, if the client and daemon disagreed about whether or not the container had a tty allocated to it, that the data stream coming back from the server wouldn't be muxed using an stdcopy.StdWriter, so it wouldn't be in the format that stdcopy.StdCopy expects to demux, and that should cause the |
|
@nalind I'm using systemd-220. Maybe it returns crap instead of logs sometimes. |
|
I'm also running with version 220 (Fedora 23's systemd-220-3.fc23), but the like messages we retrieve from json-logs, data we read back from the journal should be wrapped up and chunked before it gets to the client, so if the driver was getting garbage back, I'd expect to get garbage in the output of the |
|
@nalind I can't imagine. I'll try to put some logging to your code later. |
|
Ah, found it. When built without the The Dockerfile installs As for the formatting of the error when it's sent back to the client, if I'm tweaking the patch set to fix both of these problems and rebasing against the current master. |
|
Rebasing to resolve reported merge conflicts. |
5fa6cbf to
9a0d79e
Compare
|
Catching up with the new fluentd driver. |
61a5dca to
b27de40
Compare
|
ping @LK4D4 have you been able to successfully test this? |
|
Hi, the log reader interface was refactored and should (I hope!) be much simpler to implement now, as all you need to do is implement a |
|
Yes, I waited for this refactoring. Now implementation of journald logs should be simpler and more robust. |
|
The current refactor keeps knowledge of the number of lines to read when it's in "last" mode, and the cutoff time in "since" mode, in |
|
@nalind Not anymore. ContainerLogs does nothing except call the ReadLogs on the configured logger and Listens for logger.Messages on a channel. |
|
@cpuguy83 Oh, you're right, that's new today, and it's much better. |
|
@dmp1ce Are you getting error or not? I'm not sure how your docker is built, but with |
|
@LK4D4 Sorry, I AM getting the error. I updated my comment with the removed "not". I'm installing using the instructions here: https://docs.docker.com/engine/installation/ubuntulinux/ I'm using the journald driver using Docker Compose and |
|
@dmp1ce it should be fine if binary built as dynamic with journald build-tag. I think @jfrazelle or @tianon know more than me about which binary we ship for ubuntu. |
|
I am using official docker-engine package for jessie and getting this message too: Getting logs through |
|
@bobrik How do you start your container and what version do you use? Seems like works fine for me on master with |
|
Yeah, as far as I know, logging to journald should be enabled in our Ubuntu
and Debian packages, since they're dynamic for sure.
We have libsystemd-journal-dev in
https://github.com/docker/docker/blob/0b7e9ef910b91a0a8cb334db852ad143c4660155/contrib/builder/deb/debian-jessie/Dockerfile#L7
combined with
https://github.com/docker/docker/blob/c21eb2a4209f6339fe59e4a97c3e6479aeb39f94/hack/make.sh#L109-L111
should be sufficient for that code to be enabled (and I actually used it on
1.9.1 successfully myself on Tuesday).
|
|
|
I think it's packaging problem. The binary must be linked with libsystemd. |
|
Interesting, I can reproduce on both 1.9.1 and 1.10.0-rc1 using the official |
|
@tianon check ldd. Also, maybe we don't set |
|
Hmm, I think the build containers (per contrib/builder/deb/generate.sh) might not have pkg-config in them. I had erroneously assumed that they were pulled in by build-essential on Debian, and the various development tools groups. If |
|
Yeah, I don't see |
$ nm -CDu /usr/bin/docker | grep sd_journal_add_match
$ Into the build system I go! 😄 |
|
Man, I could've sworn |
|
I have Ubuntu 15.10 running with Docker version 1.10.0. I'm still getting |
|
Yes, it should have. When I poke at the packages in the apt repository, I'm finding the expected references to the right unresolved symbols in the 1.10.1 packages for jessie, precise, trusty, and wheezy, but not in the packages for stretch or wily. On stretch and wily, the expected headers are included in libsystemd-dev, which the build scripts install, but there is no libsystemd-journal.pc for pkg-config to find when hack/make.sh calls it, so the logic doesn't get built at build-time. Given that those are newer versions, we might be better off changing pkg-config references to just look for libsystemd, and have make.sh look for a version of it that's at least 209, when systemd's news file says those were all merged together. |
|
Whoops, packages for precise and wheezy don't link with the right libraries - I was taking their packages apart wrong. So only jessie and trusty are being built with the feature. |
|
@nalind OK. Thanks. Is this already merged then for Wily? What about the future Xenial? |
|
@dmp1ce I was mistaken in thinking that we could fix it by changing the pkg-config dependency (we'd stop pulling things in on older releases, and there's no single option that's present across all of the desired build targets), so that was closed without merging. So for the moment at least, it's not working in stretch or wily. |
|
@nalind Should I create an issue for Wily? |
|
@dmp1ce Yeah, I think that's how we make sure it stays on the radar. |
This change set uses the journald libraries to read log entries from the journal, and hooks that up to the "logs" endpoint. It moves handling of the --last option out of the endpoint logic and into the log drivers themselves, because doing so has the potential cut down on how much data the journald driver will have to dump to its pipe.
It's multiple patches to hopefully be easier to review, but I have no qualms about squashing things together if that's preferred.