mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Remove persist directory when cleaning up Conmon files
This seems to have been added as part of the cleanup of our handling of OOM files, but code was never added to remove it, so we leaked a single directory with an exit file and OOM file per container run. Apparently have been doing this for a while - I'd guess since March of '23 - so I'm surprised more people didn't notice. Fixes #25291 Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
@ -153,6 +153,10 @@ func (c *Container) oomFilePath() (string, error) {
|
||||
return c.ociRuntime.OOMFilePath(c)
|
||||
}
|
||||
|
||||
func (c *Container) persistDirPath() (string, error) {
|
||||
return c.ociRuntime.PersistDirectoryPath(c)
|
||||
}
|
||||
|
||||
// Wait for the container's exit file to appear.
|
||||
// When it does, update our state based on it.
|
||||
func (c *Container) waitForExitFileAndSync() error {
|
||||
@ -766,13 +770,15 @@ func (c *Container) removeConmonFiles() error {
|
||||
return fmt.Errorf("removing container %s exit file: %w", c.ID(), err)
|
||||
}
|
||||
|
||||
// Remove the oom file
|
||||
oomFile, err := c.oomFilePath()
|
||||
// Remove the persist directory
|
||||
persistDir, err := c.persistDirPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Remove(oomFile); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
return fmt.Errorf("removing container %s oom file: %w", c.ID(), err)
|
||||
if persistDir != "" {
|
||||
if err := os.RemoveAll(persistDir); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||
return fmt.Errorf("removing container %s persist directory: %w", c.ID(), err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user