Repository navigation
fix: baggageclaim: fix overlay driver stacking mounts on worker restart - #9723
Conversation
Signed-off-by: Kump3r <[email protected]>
Signed-off-by: Kump3r <[email protected]>
|
Example error message in production: |
| // tracks paths mounted during this Recover call so they | ||
| // can be rolled back if a later step fails. | ||
| var mountedThisPass []string | ||
| rollback := func() { | ||
| for _, path := range mountedThisPass { | ||
| if err := syscall.Unmount(path, 0); err != nil && !errors.Is(err, syscall.EINVAL) { | ||
| driver.logger.Error("rollback-unmount", err, lager.Data{"path": path}) | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I'm not sure about the utility of doing this rollback. It assumes the state prior to Recover() being called is a better place to leave things in if there's a failure of any kind. Without knowing what error we're dealing with this may or may not be useful. Why is unmounting what we've successfully mounted so far a good thing to do?
Another question: why do we ignore EINVAL errors ("invalid argument") during rollback?
I think it would make sense to do this if we know why. I see in the issue you wrote:
Defect 2 - Recover() does not roll back mounts on error (line 115–162)
Why is this a defect?
There was a problem hiding this comment.
This rollback function also seems to be the entire reason for adding the boolean return value to bindMount() and overlayMount().
There was a problem hiding this comment.
If we end up keeping this, we should also rollback in the reverse order of the list to correctly rollback any parent->child relationships. Current setup would rollback a parent before a child.
There was a problem hiding this comment.
Let me provide some clarity although I do agree with the challenge and you are right to question, also the reversed order is an actual bug.
To the point why do it in the first place - The rollback was added as defense-in-depth for the case where Recover() mounts volumes 1..K successfully and then fails on K+1, leaving a partial state. The theory was: better to clean up what we added than leave half-mounted volumes.vBut given that the primary fix is the idempotency check (mountinfo.Mounted() before every syscall.Mount), partial mounts from a failed pass are already harmless on the next restart — the idempotency check will skip them. So rollback doesn't actually add safety, just complexity. Removing it now.
The bool return only exists for rollback - Yup, without rollback there's no reason to distinguish "we mounted it this pass" from "it was already mounted". Both bindMount and overlayMount go back to returning plain error.
Rollback order is wrong (parent before child) - Yes, I missed this and its a real bug: the list was ordered roots first then CoWs, so rollback would try to unmount a root bind-mount while its CoW overlay was still live - that would fail with EBUSY. The fix would be to reverse the list before iterating. But since we're dropping rollback entirely, this doesn't need to be fixed - it goes away.
|
|
||
| runner.Bounce() |
There was a problem hiding this comment.
Why do we bounce the runner in the BeforeEach()? If we want to test multiple restarts we could do a for loop in the It() instead where we restart the runner multiple times.
There was a problem hiding this comment.
Valid point - the test is clearer if the full scenario (create → bounce → assert → bounce again → assert) lives inside the It block rather than split across BeforeEach and It. Both bounces are now inside the It, so the reader can follow the whole story without jumping between blocks.
|
|
||
| AfterEach(func() { | ||
| _ = syscall.Unmount(rootVolume.Path(), 0) | ||
| _ = syscall.Unmount(cowVolume.Path(), 0) |
There was a problem hiding this comment.
nit: why ignore errors? We check for errors in the other tests in this file.
There was a problem hiding this comment.
I used _ = here because AfterEach runs even when the test body fails, and
at that point I wasn't certain whether the mounts would still be present -
if the test failed mid-bounce, cleanup might be in an unknown state and a
hard Expect would produce a noisy secondary failure that masks the real one.
That said, the test is structured so both volumes are always mounted by the
time AfterEach runs, so the uncertainty doesn't actually exist. Fixed to use
Expect(err).NotTo(HaveOccurred())
…d drop error handling Signed-off-by: Kump3r <[email protected]>
Signed-off-by: Kump3r <[email protected]>
|
Validated the fix by compiling the binary and switching to the bosh VM, with the same steps described in the issue: As you can see with the new binary the cound is not multiplied on each restart |
taylorsilva
left a comment
There was a problem hiding this comment.
Thanks for making the changes Kalin! LGTM now. I'll make sure this makes it over to 8.3.1
|
Thanks for the quick response as always and for taking a look |
soda entered an OOM loop on 2026-10-03: VictoriaMetrics grew its caches to ~4.5 GiB under the default -memory.allowedPercent=60, filled the 4 GiB swap file, and the kernel killed it six times, taking the Concourse and metrics tailnet services down with it. - VictoriaMetrics: cap caches with -memory.allowedBytes=1500MB and add MemoryHigh=1400M/MemoryMax=1800M so a spike is reclaimed inside the unit instead of triggering a global OOM. Slow restarts to RestartSec=10 (the 100ms default re-warmed the caches and fed the loop). Keep the basic-auth password out of the Ansible log with no_log. - swap: add a second 4 GiB swap file (8 GiB total) and raise vm.swappiness to 30. - Concourse web/worker: shield with OOMScoreAdjust=-500 via systemd drop-ins. Pin 8.3.1, which fixes the worker mount-table leak (concourse/concourse#9723), and add the mountinfo_metric exporter that made the leak visible. - Add machines/soda.yml and wire it into site.yml.
Changes proposed by this PR
closes #9722
What
OverlayDriver.Recover()calledbindMount/overlayMountfor everyon-disk volume on startup without checking whether those paths were
already mounted. Linux allows stacking bind mounts silently, so each
in-place process restart (BOSH update, monit, etc.) added a full extra
copy of all volume mounts. After enough restarts the mount table hit
its kernel limit,
mount(2)returned ENOSPC, and the worker entered acrash loop that made things worse on every iteration.
How
bindMountandoverlayMountnow checkmountinfo.Mounted()beforecalling
syscall.Mountand skip silently if already present.Recover()tracks which paths it mounts in the current pass andunmounts them if any later step fails, preventing partial mount state
from compounding on the next restart.
moby/sys/mountinfowas already an indirect dependency; promoted todirect.
Tests
Recover()called N times on already-mounted volumes — mountcount stays flat.
Recover()with a bad volume mid-loop — previously mountedvolumes are rolled back.
volumes recover correctly and mount count does not grow across
repeated bounces.