concourse: Missing build logs - containerd
Summary
When using the containerd runtime, we are seeing an issue when Concourse is managed. The problem is that after the worker gets reselected (web restart - drain etc.) the worker starts reporting/emitting build logs rather randomly and some logs are lost. This impacts logs of jobs that are running, in parallel with the concourse update. I think this could potentially block users from actually wanting to migrate to containerd, if we are not able to find a solution.
Steps to reproduce
Run concourse deploy and have other long running jobs that emit build logs at the moment
Expected results
All build logs are emitted correctly and visualised in the UI as before the update
Actual results
Check the welcome message, before the recreate and after the recreate. Notice how after we have some logs that are not present in the UI, although the container still resumes it’s execution just fine.
Additional context
I have tested this in a bosh environment, haven’t been able to test it in docker/kubernetes
Triaging info
- Concourse version: v7.13.1, v7.11.2, v7.11.0
- Browser (if applicable): Chrome
- Did this used to work? Worked/works fine with
guardian
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (18 by maintainers)
Commits related to this issue
- WIP - DO NOT MERGE POC fix for #9189 Signed-off-by: Taylor Silva <dev@taydev.net> — committed to concourse/concourse by taylorsilva a year ago
- WIP - DO NOT MERGE POC fix for #9189 Signed-off-by: Taylor Silva <dev@taydev.net> — committed to concourse/concourse by taylorsilva a year ago
That’s great to hear - thanks so much for jumping on this and getting it resolved.
Without prior context on this part of the functionality, it was definitely a bit tough for me to wrap my head around the entire implementation. We actually ran into the same issues with closing and opening attaches just yesterday, so your insights and the way you walked through your approach have been incredibly helpful in understanding the whole picture.
Looking forward to the PR. We’ll validate it on our side as well. Thanks for pulling this together so quickly!
Thank you guys so much for figuring out why this is happening. It really helped with trying to figure out a solution, which I think I found!
No more dropped logs!!
My fix here is basically what Ivan was going for, managing the
cio.IOstreams. Order of operation really matters here. We do have to attach first before closing the old streams. Closing the old streams first results in the FIFO’s being deleted and the resulting re-attach failing.I’m pushing my WIP fix to a branch here: https://github.com/concourse/concourse/compare/master...issue-9189
I’ll clean it up more tomorrow and get it PR’d for the next release.
I spent some time digging into intermittent missing task logs after ATC restart and I found:
lsof /run/containerd/fifo/.../task-stdoutafter restarting the ATC. This happens because the ATC triggers a fresh call to Attach after reconnecting to the worker.Attachcall (viaLoadProcess+cio.NewAttach) seems to create a new reader on the FIFO. Since FIFOs deliver data to the first reader that reads it, I suspect this is causing log lines to be split or lost across multiple readers.My suspicion:
The Concourse worker is unintentionally creating redundant attaches without properly closing old ones, leading to multiple competing readers on task-stdout.
What I tried
As a stopgap, I added code to force-close any existing FDs tied to task-stdout before performing a new attach(here):
This brute-force cleanup resolved the issue right away, but it’s clearly not an ideal or long-term solution.
I’m continuing to explore a more robust approach by explicitly managing cio.IO streams, so we can cleanly Cancel() and Close() old attaches without resorting to closing FDs manually.
If anyone has ideas or prior experience with managing cio.IO more predictably, it would be highly appreciated!
Tested with:
And the file in the container is correctly filled, however after the restart of the webs, there are no longer any build logs in the UI of Concourse, which imho confirms the worker resumes the build execution but fails to re-establish the log stream.
So:
The issues occurs with all of the versions when using
containerd, also both issues start to occur when Concourse is being deployed. We do rolling update with two web nodes and multiple worker nodes. We always have a running web, there is no downtime of the UI, or anything else. Because of the web restarts we are seeing multiple “selected worker” statements. Our workers start to recreate only after all webs have finished, but even then the worker which is still not recreated stops emitting build logs for some reason. And it is not that all of them are not emitting. Some are dropped, while others continue as seen in the screenshot. Sometimes for durations of minutes we see build logs loss. To answer the second question, Yes, with guardian this is not reproducible, withcontainerdit reproduces each time.For the UID duplication: v7.13.1, 2 web nodes, steps:
bosh deploy —recreateflag. Haven’t been able to check the logs, but when I reproduce it, I will make sure to do so.