containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.98k stars 2.43k forks source link

API v2: delete an image #6261

Closed Edward5hen closed 4 years ago

Edward5hen commented 4 years ago

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

/kind bug

Description As the doc says, /libpod/images/{name:.*}/remove should delete an image with DELETE method. But I get a "no such image" 404 code.

Steps to reproduce the issue:

  1. setup the apiv2 service

  2. podman pull alpine

  3. curl -v -X DELETE http://localhost:8081/v1.40/libpod/images/f70734b6a266/remove

Describe the results you received:

[root@Fedora31 ~]# podman images
REPOSITORY                 TAG      IMAGE ID       CREATED       SIZE
docker.io/library/alpine   latest   f70734b6a266   2 weeks ago   5.88 MB
[root@Fedora31 ~]# curl -v -X DELETE http://localhost:8081/v1.40/libpod/images/f70734b6a266/remove
*   Trying ::1:8081...
* TCP_NODELAY set
* connect to ::1 port 8081 failed: Connection refused
*   Trying 127.0.0.1:8081...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8081 (#0)
> DELETE /v1.40/libpod/images/f70734b6a266/remove HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.66.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Content-Type: application/json
< Date: Thu, 14 May 2020 05:12:53 GMT
< Content-Length: 182
<
{"cause":"no such image","message":"Failed to find image f70734b6a266/remove: unable to find a name and tag match for f70734b6a266/remove in repotags: no such image","response":404}
* Connection #0 to host localhost left intact

Describe the results you expected: Remove the image successfully

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

[root@Fedora31 ~]# podman version
Version:            1.9.1
RemoteAPI Version:  1
Go Version:         go1.13.9
Built:              Mon May 11 06:37:25 2020
OS/Arch:            linux/amd64

Output of podman info --debug:

[root@Fedora31 ~]# podman info --debug
debug:
  compiler: gc
  gitCommit: ""
  goVersion: go1.13.9
  podmanVersion: 1.9.1
host:
  arch: amd64
  buildahVersion: 1.14.8
  cgroupVersion: v2
  conmon:
    package: conmon-2.0.15-1.fc31.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.15, commit: 4152e6044da92e0c5f246e5adf14c85f41443759'
  cpus: 2
  distribution:
    distribution: fedora
    version: "31"
  eventLogger: file
  hostname: Fedora31
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.3.7-301.fc31.x86_64
  memFree: 768737280
  memTotal: 2077401088
  ociRuntime:
    name: crun
    package: crun-0.13-2.fc31.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.13
      commit: e79e4de4ac16da0ce48777afb72c6241de870525
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  rootless: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 2204889088
  swapTotal: 2214588416
  uptime: 145h 26m 36.64s (Approximately 6.04 days)
registries:
  search:
  - docker.io
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - registry.centos.org
  - quay.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "true"
  imageStore:
    number: 1
  runRoot: /var/run/containers/storage
  volumePath: /var/lib/containers/storage/volumes

Additional environment details (AWS, VirtualBox, physical, etc.): KVM vm

mheon commented 4 years ago

@baude PTAL

baude commented 4 years ago

@Edward5hen i can understand this one is a little confusing because we expose both a single and "batch" removal for images.

http://docs.podman.io/en/latest/_static/api.html#operation/libpodRemoveImage is the standard endpoint which removes one image only and the name is in the path of the endpoint. For example, images/foobar ... note there is no remove endpoint, instead the method of DELETE tells the endpoint to remove the image.

http://docs.podman.io/en/latest/_static/api.html#operation/libpodImagesRemove is meant for batch removal of images and is a function on "images". So in that case, it is libpod/images/remove and the names of the images to be removed are passed as a query parameter in type array.

baude commented 4 years ago

actually, there is a bug ... the single endpoint should NOT have a trailing /remove. Fixing now...

baude commented 4 years ago

@Edward5hen thanks for the report!

Edward5hen commented 4 years ago

@baude it's really my pleasure. The fix is so quick!