Related PR is: moby/moby#31952
Relevant Snippets below have been heavily elided to include only the important parts and ignore irrelevant complexity.
So, this is the problem: We're writing onto a writer we passed in all of these log lines in this basically-undocumented log line byte string format. This happens in daemon/logs.go
, see the for loop. There is no reason for this to occur on the daemon, the daemon shouldn't be responsible for reconstituting a response to be sent over the HTTP response. That should be the job of container_routes.go
, just like how it's every other Handler
's responsibility to take structs and turn them into json. Ideally, we would bubble up the channel from daemon/logger/logger.go
and access the raw messages from that channel, and then mogrify them into a byte string in the routes (by removing all of that formatting and writing from ContainerLogs
My major hangup is that right now the api server is isolated from the daemon through the backend. I understand why this is the case and I straight up totally agree that that's an awesome design. The PROBLEM is that we can't access the raw log Message
structs, which are defined in the daemon/logger/
package without importing that and totally breaking the isolation through backend.
My proposed solution is the 4th through final files, which refactors Messages
out of logger
, moves the bytestring construction to container_routes.go
, and changes ContainerLogs()
to write to a channel.
My major hangup, if this design looks good, is how do I handle the LogAttributes
field, which has useful methods defined on it.