Implement plugins for logging drivers#28403
Conversation
3bcfb39 to
20beb61
Compare
20beb61 to
def27ad
Compare
|
The other alternative here would be to, instead of using fifo's, either hijack the HTTP stream (getting rid of the HTTP overhead), or potentially force an upgrade to HTTP2 (which is likely simpler for implementers than hijack). |
|
Just to note for those looking for something in the interim, Docker does currently support GELF (which is a standardized protocol for logging), so anything which can consume that (and/or translate that, like |
|
Thank you for working on this 👍 Some questions about FIFO, from my previous similar PR (#23198)
|
Correct, write will be blocked, which is the behavior for all existing drivers except UDP based ones.
writes will be blocked until the plugin comes back |
|
@AkihiroSuda For non-blocking behavior, I implemented a ring buffer that can be used with any driver in #28762 |
|
Since we are already going to be communicating over a unix socket, I'm going to ditch the fifo. These offer similar performance, but with the unix socket I don't have to setup anything else. |
90e6407 to
a277a32
Compare
|
Just an update on this:
To think about (need input from others):
Here's my plugin implementation: https://github.com/cpuguy83/docker-log-driver-test |
|
This should be good to go. |
|
|
b62cd28 to
d13e742
Compare
|
Added. |
api/types/plugins/logdriver/io.go
Outdated
There was a problem hiding this comment.
Is this call to io.ReadFull necessary, given the real read at L 83?
There was a problem hiding this comment.
Yes, this gets the size of the message.
83 gets the actual message, which we need the size of to know where it ends.
api/types/plugins/logdriver/io.go
Outdated
There was a problem hiding this comment.
shouldnt uint32(n) -> uint32(total) ?
There was a problem hiding this comment.
Here we are putting writing the size of the log entry to the buffer.
But the buffer needs to be the total size otherwise we'll be 4-bytes short.
There was a problem hiding this comment.
Thanks, I just looked at the logEntry's Size() implementation. Looks good.
There was a problem hiding this comment.
TimeNano is not copied into the dAtA marshal output. Looks incorrect.
There was a problem hiding this comment.
I think this is an protobuf optimization since TimeNano is an int64 already there is nothing extra to copy.
docs/extend/plugins_logging.md
Outdated
There was a problem hiding this comment.
josn, it's the same as json, but all the keys are scrambled up.
:) Thanks I do this all the time.
Logging plugins use the same HTTP interface as other plugins for basic
command operations meanwhile actual logging operations are handled (on
Unix) via a fifo.
The plugin interface looks like so:
```go
type loggingPlugin interface {
StartLogging(fifoPath string, loggingContext Context) error
StopLogging(fifoPath)
```
This means a plugin must implement `LoggingDriver.StartLogging` and
`LoggingDriver.StopLogging` endpoints and be able to consume the passed
in fifo.
Logs are sent via stream encoder to the fifo encoded with protobuf.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
d13e742 to
27bd684
Compare
|
@cpuguy83: I'm okay with a follow up PR to address
|
|
LGTM |
|
Cool, going to move to docs-review then, thanks! |
|
Discussed with @cpuguy83 and we'll do a follow up for docs due to code-freeze today |
This is intended as PoC code that as of yet untested other than ensuring compilation.
Logging plugins use the same HTTP interface as other plugins for basic
command operations meanwhile actual logging operations are handled (on
Unix) via a fifo. I believe this is much cleaner than dealing with go1.8 style plugins.
The plugin interface looks like so:
This means a plugin must implement
LoggingDriver.StartLoggingandLoggingDriver.StopLoggingendpoints and be able to consume the passedin fifo.
Logs are sent via stream encoder to the fifo encoded with json.
Ideally this would be protobuf, but I did not implement this yet.
ping @tiborvass @anusha-ragunathan