Files
containerd/core/mount
Rodrigo Campos dd7fe0b76f core/mount: Properly cleanup on doPrepareIDMappedOverlay errors
Before this patch, the cleanup was unconditionally trying an unmount,
which is not needed if the mount never succeeded in the first place.
This causes logs of failed stuff, that should never be there.
Also, one function was creating the tmpDir and the nested one removing
it (in the cleanup function), which complicates the reasoning about
not leaking resources.

This patch on one hand moves the creation of the tmpDir into the
function that will remove it later and renames the parameter. On the
other hand, it also separates the cleanup function in two functions:
cleanDir() and cleanMount(). Each one will clean the directory or the
mount, only if needed, and a new cleanup function that just calls
cleanDir() and cleanMount() is returned as the cleanup function handler.

Because we now create the tmp directory inside the function, we need to
adjust the test: the directory passed as param now will exist, but it
shoild be empty. Therefore, we change the os.Stat() to an os.Remove().
If it's not empty (the cleanup didn't work), the remove will fail.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2025-08-19 14:58:09 +02:00
..
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00
2024-01-17 09:52:12 -08:00