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

Containers should be pruned before pods #4346

Closed
QuLogic opened this issue Oct 25, 2019 · 3 comments · Fixed by #4443
Closed

Containers should be pruned before pods #4346

QuLogic opened this issue Oct 25, 2019 · 3 comments · Fixed by #4443
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@QuLogic
Copy link

QuLogic commented Oct 25, 2019

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

Say we're running through a Podman tutorial and want to clean up afterwards. Using podman system prune fails because pods are deleted before containers.

Steps to reproduce the issue:

  1. podman run -dt --pod new:nginx -p 32597:80 quay.io/libpod/alpine_nginx:latest
  2. podman pod stop nginx
  3. podman system prune

Describe the results you received:


WARNING! This will remove:
        - all stopped containers
        - all stopped pods
        - all dangling images
        - all build cache
Are you sure you want to continue? [y/N] y
Deleted Pods
Error: pod 764aea25e5feca61a840898c78445f990358495c39cd2ba26b893ae1f048b4d0 contains containers and cannot be removed: container already exists

Describe the results you expected:
Pruning should remove the stopped containers in a fully stopped pod before removing the pod. If only parts of a pod are stopped, then it should skip deleting the pod entirely.

The error message is also a bit weird; I'm not creating a new container so it should not "already" exist.

Output of podman version:

Version:            1.6.1
RemoteAPI Version:  1
Go Version:         go1.12.9
OS/Arch:            linux/amd64

Output of podman info --debug:

debug:
  compiler: gc
  git commit: ""
  go version: go1.12.9
  podman version: 1.6.1
host:
  BuildahVersion: 1.11.2
  CgroupVersion: v1
  Conmon:
    package: conmon-2.0.1-1.fc30.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.1, commit: 4346fbe0b2634b05857973bdf663598081240374'
  Distribution:
    distribution: fedora
    version: "30"
  MemFree: 249163776
  MemTotal: 4042072064
  OCIRuntime:
    package: runc-1.0.0-95.rc9.gitc1485a1.fc30.x86_64
    path: /usr/bin/runc
    version: |-
      runc version 1.0.0-rc9+dev
      commit: 0840802d505e28d3adcbc7a275cbeadbdf64ddec
      spec: 1.0.1-dev
  SwapFree: 4001206272
  SwapTotal: 4278185984
  arch: amd64
  cpus: 4
  eventlogger: journald
  hostname: TerraNova
  kernel: 5.2.17-200.fc30.x86_64
  os: linux
  rootless: true
  slirp4netns:
    Executable: /usr/bin/slirp4netns
    Package: slirp4netns-0.4.0-4.git19d199a.fc30.x86_64
    Version: |-
      slirp4netns version 0.4.0-beta.2
      commit: 19d199a6ca424fcf9516320a327cedad85cf4dfb
  uptime: 72h 3m 4.52s (Approximately 3.00 days)
registries:
  blocked: null
  insecure: null
  search:
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  ConfigFile: ~/.config/containers/storage.conf
  ContainerStore:
    number: 2
  GraphDriverName: overlay
  GraphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: fuse-overlayfs-0.6.4-2.fc30.x86_64
      Version: |-
        fusermount3 version: 3.6.2
        fuse-overlayfs: version 0.6.4
        FUSE library version 3.6.2
        using FUSE kernel interface version 7.29
  GraphRoot: ~/.local/share/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 4
  RunRoot: /run/user/$ID
  VolumePath: ~/.local/share/containers/storage/volumes

Package info (e.g. output of rpm -q podman or apt list podman):

podman-1.6.1-2.fc30.x86_64
@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 25, 2019
@QuLogic
Copy link
Author

QuLogic commented Oct 25, 2019

Note: I need to podman rm the stopped nginx container for podman system prune to work on the pod. It does not appear necessary to remove the infra container explicitly.

@rhatdan
Copy link
Member

rhatdan commented Oct 25, 2019

@QiWang19 PTAL

QiWang19 added a commit to QiWang19/podman that referenced this issue Nov 1, 2019
fix containers#4346
This PR sets c.Force to true if user reply 'y' to system prune confirmation question.

Signed-off-by: Qi Wang <[email protected]>
@QiWang19
Copy link
Contributor

QiWang19 commented Nov 1, 2019

Note: I need to podman rm the stopped nginx container for podman system prune to work on the pod. It does not appear necessary to remove the infra container explicitly.

we can't prune containers before pod because the pod may have infra container. https://github.com/containers/libpod/blob/04e8bf3dba50e079278ac33b43ecc2ebb8f4a156/cmd/podman/system_prune.go#L81

After looking through the tutorial I think the stopped nginx container is not the infra container, it's a container created by podman run -dt.
I open a PR may be can fix this issue.

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
4 participants