Fix k8s-file log format for terminating F-sequence#629
Conversation
The k8s-file format requires the space separator between tag and content to be present even when content is empty. The terminating F-sequence generated for partial log lines was missing this mandatory space, causing podman logs to fail with "is not a valid container log line". Changed terminating F-sequence from "F\n" to "F \n" and updated byte counts accordingly. Fixed test assertions to validate the correct format. Fixes containers/podman#28014 Signed-off-by: Jindrich Novy <jnovy@redhat.com>
|
@ricardobranco777 PTAL |
Thanks for fixing it. Do you have a RPM I can inject in our tests to verify it? |
|
A reference to the bad commit 59c2b94 would be nice. Looking at that this does change the behavior still and I guess we would argue whether #252 is valid or not. It now prints a final newline as part of podman logs which we did not previously. In practise this means that the output between podman run and podman logs differ because logs now always adds a final newline so logs no longer matches the real container output 1 to 1. I don't know if this matters in the real world to anyone, I doubt the extra newline causes complains but what it means it does is it claim the container wrote a final newline when it did not, so conmon injecting output into the container stream. both I don't care to much personally this here fixes at least the broken log format so sure LGTM in that regard |
|
How's the testing going @ricardobranco777 ? |
Sorry, I should've told you earlier. I found source RPM's and I need the binaries. |
|
@ricardobranco777 binary RPMs are available if you click e.g. |
|
I think it works. The podman e2e test fails differently now: https://openqa-assets.opensuse.org/tests/5649499/file/podman_e2e-localintegration.txt |
|
Thanks @ricardobranco777 - let me know if anything else needs to be fixed on conmon's side. |
well this is exactly what I have mentioned above, this is a behavioural change by injecting an additional newline, we do explicitly test that this is not the case so if conmon now does this we must chnage the podman test to allow that, but I like to actually have some input from others if conmon doing this now is really sane At the very least this here makes the log drivers behave differently! IMO it would be best to just revert the original fix instead and no do that to preserve the behavior. |
|
Thanks for feedback @Luap99 - I'd rather keep the current fix as it's correct according to CRI specification [1] and it is also consistent across drivers. Let's coordinate on podman side to fix the parser. The issue is in log consumption, not log generation. [1] https://github.com/kubernetes/design-proposals-archive/blob/main/node/kubelet-cri-logging.md |
|
Can you point out the exact text that says there must be a final F line? I don't see anything saying that there.
At least I do not interpret that in a way that a final F is required. In fact I would argue the opposite with that, P is when the log entry is not ended (i.e. no newline) and the container never wrote the newline so it should not be mark as ended IMO. How does other implementations deal with that, i.e. containerd?
as I have shown above it is not, the new k8s-log behavior injects a final newline while journald does not so that is not good that our tests see different behaviours based on the driver in use |
|
The CRI spec text you quoted doesn't explicitly define container termination behavior - you're correct. However, the spec's scope is limited to runtime-initiated line splitting, not container termination scenarios. The evidence that this behavior is expected comes from filed bugs against both conmon and containerd showing that missing terminating F-sequences break log consumers in production: Conmon issue #252: Reports that running The bug report explicitly states the expected behavior should be: and concludes: "conmon should be writing out a terminating F-sequence into the log if it sees a container pipe closing without a trailing newline" what I consider justified. Containerd issue #4813: Shows containerd has the identical bug. When running and stops. This breaks fluentd's concat plugin with timeout errors. Grafana Loki issue #10998: Documents that when a container outputs Regarding driver inconsistency - the journald driver doesn't inject the newline because it writes directly to journald using native journald fields, bypassing the CRI log format entirely. The k8s-file driver must comply with CRI format to be parseable by kubectl/log consumers. This is a pre-existing architectural difference: journald has always had different semantics than file-based drivers. The proper solution would be documenting this difference or making journald also emit CRI-compliant logs (which would require significant rework and I'm not planning to do that). Sources:
|
|
(I do not appreciate being answered by an LLM) Anyhow my point stands, the spec is not clear and the containerd issue was closed and not fixed AFAICT. |
|
@jnovy @Luap99 Specifically, this test is broken. You can find the failure in this CI. This also affects critest CI. This one can be fixed in CRI-O though. Personally I think this fix would be valid, but still upstream doesn't seem to be ready for it. I think this also should be reverted. |
…for details. Signed-off-by: Ayato Tokubi <atokubi@redhat.com>
|
At this point, if CRI-O is failing, I think we have an indication that the CRI docs aren't agreeing with reality. Concur with a revert. |
This reverts commit 67718f2. Breaks CRI-O and Kubernetes CI. See PR containers#629 discussion.
This reverts commit e25af44. Breaks CRI-O and Kubernetes CI. See PR containers#629 discussion.
After reverting PR containers#592 and containers#629, remove assertion expecting terminating F-sequence that is no longer generated.
|
@bitoku - just created PR for revert - PTAL. |
The k8s-file format requires the space separator between tag and content to be present even when content is empty. The terminating F-sequence generated for partial log lines was missing this mandatory space, causing podman logs to fail with "is not a valid container log line".
Changed terminating F-sequence from "F\n" to "F \n" and updated byte counts accordingly. Fixed test assertions to validate the correct format.
Fixes containers/podman#28014