Skip to content

ctr image check does not report the check result #5352

@dmitry-irtegov

Description

@dmitry-irtegov

ctr image check return code is always 0

I am trying to implement a smart pull script that checks the image existence before pulling. I tried to use ctr image check subcommand

Steps to reproduce the issue:

fat@blackcat:~/# ctr image check name==docker.io/library/alpine:latest
REF                             TYPE                                                      DIGEST                                                                  STATUS         SIZE            UNPACKED 
docker.io/library/alpine:latest application/vnd.docker.distribution.manifest.list.v2+json sha256:ec14c7992a97fc11425907e908340c6c3d6ff602f5f13d899e6b7027c9b4133a complete (2/2) 2.7 MiB/2.7 MiB true
fat@blackcat:~/# echo $?
0
fat@blackcat:~/# ctr image check name==docker.io/library/alpine:qq
REF TYPE DIGEST STATUS SIZE UNPACKED 
fat@blackcat:~/work/src/src.kublr.io/kublr/agent$ echo $?
0

Describe the results you received:

As you can see, ctr image check return code is zero independent of the check result.

Describe the results you expected:

ctr image check returns non-zero code if the filter result is empty, so it can be used in a script.

What version of containerd are you using:

$ containerd --version
containerd github.com/containerd/containerd 1.3.3-0ubuntu2.3 
$ ctr version
Client:
  Version:  1.3.3-0ubuntu2.3
  Revision: 

Server:
  Version:  1.3.3-0ubuntu2.3
  Revision: 
  UUID: b30cdc1a-9264-4014-baa3-37b3ee2b1689
uname -a
$ uname -a

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions