integration: Add logs tests#43642
Conversation
|
The tests randomly fail. Sometimes they all pass successfully, but sometimes they fail. See below for example errors. Example errors |
|
Quick update: I looked at the json log file of the container created in a failed test and it seems that the file itself is corrupted: I also checked the tests on the v20.10.16 tag and they don't fail there. So it's probably some recent regression. |
|
First commit with the regression is ae5f664 (#43294) The issue is that marshalFunc used in LogFile use a shared buffer. See:
With the mutex lock around WriteLogEntry got removed in the linked commit, the marshaller can be called for both stdout and stderr at the same time, which makes them write to the same buffer. Allocating a buffer inside the marshaller call fixes the problem. But this is probably not a good idea because it would cause too many memory allocation? Maybe we should restore the critical section for the WriteLogEntry? @corhere Could you please take a look? |
9d6f0b3 to
95efc0e
Compare
Marshalling log messages by json-file and local drivers involved serializing the message into a shared buffer. This caused a regression resulting in log corruption with recent changes where Log may be called from multiple goroutines at the same time. Solution is to use a sync.Pool to manage the buffers used for the serialization. Also removed the MarshalFunc, which the driver had to expose to the LogFile so that it can marshal the message. This is now moved entirely to the driver. Signed-off-by: Paweł Gronowski <[email protected]>
Each test handle a distinct case of ContainerLogs output. - Muxed stream, when container is started without tty - Single stream, when container is started with tty Signed-off-by: Paweł Gronowski <[email protected]>
95efc0e to
cd41010
Compare
Added integration tests for ContainerLogs.
Each test handle a distinct case of ContainerLogs output.
- How to verify it
make BIND_DIR=. TEST_FILTER='TestLogs' test-integration- A picture of a cute animal (not mandatory but encouraged)