Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove exit file from persistent storage #24399

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ func (c *Container) exitFilePath() (string, error) {
return c.ociRuntime.ExitFilePath(c)
}

func (c *Container) persistExitFilePath() (string, error) {
return c.ociRuntime.PersistExitFilePath(c)
}

func (c *Container) oomFilePath() (string, error) {
return c.ociRuntime.OOMFilePath(c)
}
Expand Down Expand Up @@ -759,6 +763,7 @@ func (c *Container) removeConmonFiles() error {

// Remove the exit file so we don't leak memory in tmpfs
exitFile, err := c.exitFilePath()

if err != nil {
return err
}
Expand All @@ -775,6 +780,15 @@ func (c *Container) removeConmonFiles() error {
return fmt.Errorf("removing container %s oom file: %w", c.ID(), err)
}

// Remove exit file from persistent storage
persistExitFilePath, err := c.persistExitFilePath()
if err != nil {
return err
}
if err := os.Remove(persistExitFilePath); err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("removing container %s persist exit file: %w", c.ID(), err)
}

return nil
}

Expand Down
3 changes: 3 additions & 0 deletions libpod/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ type OCIRuntime interface { //nolint:interfacebloat
// This is the path to that file for a given container.
ExitFilePath(ctr *Container) (string, error)

// PersistExitFilePath is the path to a container's persistent exit file.
PersistExitFilePath(ctr *Container) (string, error)

// OOMFilePath is the path to a container's oom file if it was oom killed.
// An oom file is only created when the container is oom killed. The existence
// of this file means that the container was oom killed.
Expand Down
4 changes: 4 additions & 0 deletions libpod/oci_conmon_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ func (r *ConmonOCIRuntime) OOMFilePath(ctr *Container) (string, error) {
return filepath.Join(r.persistDir, ctr.ID(), "oom"), nil
}

func (r *ConmonOCIRuntime) PersistExitFilePath(ctr *Container) (string, error) {
return filepath.Join(r.persistDir, ctr.ID(), "exit"), nil
}

// RuntimeInfo provides information on the runtime.
func (r *ConmonOCIRuntime) RuntimeInfo() (*define.ConmonInfo, *define.OCIRuntimeInfo, error) {
runtimePackage := version.Package(r.path)
Expand Down
4 changes: 4 additions & 0 deletions libpod/oci_missing.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ func (r *MissingRuntime) ExitFilePath(ctr *Container) (string, error) {
return filepath.Join(r.exitsDir, ctr.ID()), nil
}

func (r *MissingRuntime) PersistExitFilePath(ctr *Container) (string, error) {
return filepath.Join(r.persistDir, ctr.ID(), "exit"), nil
}

// OOMFilePath returns the oom file path for a container.
// The oom file will only exist if the container was oom killed.
func (r *MissingRuntime) OOMFilePath(ctr *Container) (string, error) {
Expand Down