Skip to content

Commit

Permalink
Merge pull request #23203 from Luap99/systemd-ctr-leak
Browse files Browse the repository at this point in the history
libpod: first delete container then cidfile
  • Loading branch information
openshift-merge-bot[bot] authored Jul 5, 2024
2 parents cf98506 + 62956ac commit c476c3a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libpod/runtime_ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,6 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO
reportErrorf("cleaning up storage: %w", err)
}

// Remove the container's CID file on container removal.
if cidFile, ok := c.config.Spec.Annotations[define.InspectAnnotationCIDFile]; ok {
if err := os.Remove(cidFile); err != nil && !errors.Is(err, os.ErrNotExist) {
reportErrorf("cleaning up CID file: %w", err)
}
}
// Remove the container from the state
if c.config.Pod != "" {
// If we're removing the pod, the container will be evicted
Expand All @@ -1011,6 +1005,13 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO
}
removedCtrs[c.ID()] = nil

// Remove the container's CID file on container removal.
if cidFile, ok := c.config.Spec.Annotations[define.InspectAnnotationCIDFile]; ok {
if err := os.Remove(cidFile); err != nil && !errors.Is(err, os.ErrNotExist) {
reportErrorf("cleaning up CID file: %w", err)
}
}

// Deallocate the container's lock
if err := c.lock.Free(); err != nil && !errors.Is(err, fs.ErrNotExist) {
reportErrorf("freeing lock for container %s: %w", c.ID(), err)
Expand Down

0 comments on commit c476c3a

Please sign in to comment.