Skip to content
New issue

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

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

Already on GitHub? # to your account

add crictl history command #879

Closed
kong62 opened this issue Jan 19, 2022 · 9 comments
Closed

add crictl history command #879

kong62 opened this issue Jan 19, 2022 · 9 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. sig/node Categorizes an issue or PR as relevant to SIG Node.

Comments

@kong62
Copy link

kong62 commented Jan 19, 2022

What would you like to be added:

crictl history command

Why is this needed:

we need show image build information

# docker history harbor.sit.hupu.io/base/nodejs:v10.24.1
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
31753265f7ab        2 months ago        /bin/sh -c #(nop)  LABEL BUILD=harbor.sit.hu…   0B                  
64b8df6dbb84        2 months ago        /bin/sh -c yum fs filter documentation &&   …   73.7MB              
3bf97ae86d46        2 months ago        /bin/sh -c npm config set registry https://r…   96B                 
171f086d101e        2 months ago        /bin/sh -c #(nop)  ENV PATH=/usr/local/node-…   0B                  
1953873a64f1        2 months ago        /bin/sh -c #(nop)  ENV NODE_HOME=/usr/local/…   0B                  
f09b2ba7c2e8        2 months ago        /bin/sh -c ln -s /usr/local/node-v${NODE_VER…   85B                 
1c6ffb3c8d56        2 months ago        /bin/sh -c #(nop) ADD file:5c18aa917ce9184d9…   66.3MB              
8fb28aff30ee        2 months ago        /bin/sh -c #(nop)  ENV NODE_VERSION=10.24.1     0B                  
cf5920ee60ba        2 months ago        /bin/sh -c #(nop)  LABEL FROM=harbor.sit.hup…   0B                  
609afb8cd583        12 months ago       /bin/sh -c #(nop)  ENV BUILD=harbor.sit.hupu…   0B                  
<missing>           12 months ago       /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B                  
<missing>           12 months ago       /bin/sh -c #(nop)  ENV LC_ALL=en_US.utf8        0B                  
<missing>           12 months ago       /bin/sh -c #(nop)  ENV LANG=en_US.UTF-8         0B                  
<missing>           12 months ago       /bin/sh -c #(nop)  ENV LESSCHARSET=utf-8        0B                  
<missing>           12 months ago       /bin/sh -c #(nop) COPY file:b44634315f99c9c7…   96.2kB              
<missing>           12 months ago       /bin/sh -c #(nop) COPY file:f8f4443f80fb63a7…   97.7kB              
<missing>           12 months ago       /bin/sh -c #(nop) COPY file:6751a0bcc60a8349…   6.57MB              
<missing>           12 months ago       /bin/sh -c #(nop) COPY file:f881e1f2f358f02c…   7.32MB              
<missing>           12 months ago       /bin/sh -c set -ex     && rm -rf /etc/yum.re…   42.3MB              
<missing>           13 months ago       /bin/sh -c #(nop) COPY file:8c3bb27911909c61…   1.03kB              
<missing>           13 months ago       /bin/sh -c #(nop)  LABEL org.label-schema.sc…   0B                  
<missing>           13 months ago       /bin/sh -c #(nop) ADD file:c4c7334c2caba18f4…   204MB               
@kong62 kong62 added kind/feature Categorizes issue or PR as related to a new feature. sig/node Categorizes an issue or PR as relevant to SIG Node. labels Jan 19, 2022
@feiskyer
Copy link
Member

crictl talks only with CRI API. If the features from docker is not part of CRI API, then it's not possible to add that in crictl.

@saschagrunert
Copy link
Member

Some container runtimes like CRI-O return an additional image info which contains the history:

> sudo crictl inspecti alpine | jq .info.imageSpec.history
[
  {
    "created": "2021-11-24T20:19:40.199700946Z",
    "created_by": "/bin/sh -c #(nop) ADD file:9233f6f2237d79659a9521f7e390df217cec49f1a8aa3a12147bbca1956acdb9 in / "
  },
  {
    "created": "2021-11-24T20:19:40.483367546Z",
    "created_by": "/bin/sh -c #(nop)  CMD [\"/bin/sh\"]",
    "empty_layer": true
  }
]

@afbjorklund
Copy link
Contributor

afbjorklund commented Jan 21, 2022

Some container runtimes like CRI-O return an additional image info which contains the history:

And containerd also does this. But docker (over CRI) does not, so it must be different API ?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 21, 2022
@afbjorklund
Copy link
Contributor

afbjorklund commented Apr 22, 2022

I implemented "info", including "history", for docker:

It looks almost the same, then again CRI doesn't really have any standardization in a lot of different places.

sudo crictl pull alpine
sudo crictl inspecti alpine

vs containerd

@@ -1,48 +1,47 @@
 {
   "status": {
     "id": "sha256:0ac33e5f5afa79e084075e8698a22d574816eea8d7b7d480586835657c3e1c8b",
     "repoTags": [
-      "docker.io/library/alpine:latest"
+      "alpine:latest"
     ],
     "repoDigests": [
-      "docker.io/library/alpine@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454"
+      "alpine@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454"
     ],
-    "size": "2818197",
+    "size": "5574964",
     "uid": null,
     "username": "",
     "spec": null
   },
   "info": {
-    "chainID": "sha256:4fc242d58285699eca05db3cc7c7122a2b8e014d9481f323bd9277baacfa0628",
     "imageSpec": {
       "created": "2022-04-05T00:19:59.912662499Z",
       "architecture": "amd64",
       "os": "linux",
       "config": {
         "Env": [
           "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
         ],
         "Cmd": [
           "/bin/sh"
         ]
       },
       "rootfs": {
         "type": "layers",
         "diff_ids": [
           "sha256:4fc242d58285699eca05db3cc7c7122a2b8e014d9481f323bd9277baacfa0628"
         ]
       },
       "history": [
         {
-          "created": "2022-04-05T00:19:59.790636867Z",
+          "created": "2022-04-05T00:19:59Z",
           "created_by": "/bin/sh -c #(nop) ADD file:5d673d25da3a14ce1f6cf66e4c7fd4f4b85a3759a9d93efb3fd9ff852b5b56e4 in / "
         },
         {
-          "created": "2022-04-05T00:19:59.912662499Z",
+          "created": "2022-04-05T00:19:59Z",
           "created_by": "/bin/sh -c #(nop)  CMD [\"/bin/sh\"]",
           "empty_layer": true
         }
       ]
     }
   }
 }

vs cri-o

@@ -1,48 +1,47 @@
 {
   "status": {
-    "id": "0ac33e5f5afa79e084075e8698a22d574816eea8d7b7d480586835657c3e1c8b",
+    "id": "sha256:0ac33e5f5afa79e084075e8698a22d574816eea8d7b7d480586835657c3e1c8b",
     "repoTags": [
-      "docker.io/library/alpine:latest"
+      "alpine:latest"
     ],
     "repoDigests": [
-      "docker.io/library/alpine@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454",
-      "docker.io/library/alpine@sha256:a777c9c66ba177ccfea23f2a216ff6721e78a662cd17019488c417135299cd89"
+      "alpine@sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454"
     ],
-    "size": "5859398",
+    "size": "5574964",
     "uid": null,
     "username": "",
     "spec": null
   },
   "info": {
     "imageSpec": {
       "created": "2022-04-05T00:19:59.912662499Z",
       "architecture": "amd64",
       "os": "linux",
       "config": {
         "Env": [
           "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
         ],
         "Cmd": [
           "/bin/sh"
         ]
       },
       "rootfs": {
         "type": "layers",
         "diff_ids": [
           "sha256:4fc242d58285699eca05db3cc7c7122a2b8e014d9481f323bd9277baacfa0628"
         ]
       },
       "history": [
         {
-          "created": "2022-04-05T00:19:59.790636867Z",
+          "created": "2022-04-05T00:19:59Z",
           "created_by": "/bin/sh -c #(nop) ADD file:5d673d25da3a14ce1f6cf66e4c7fd4f4b85a3759a9d93efb3fd9ff852b5b56e4 in / "
         },
         {
-          "created": "2022-04-05T00:19:59.912662499Z",
+          "created": "2022-04-05T00:19:59Z",
           "created_by": "/bin/sh -c #(nop)  CMD [\"/bin/sh\"]",
           "empty_layer": true
         }
       ]
     }
   }
 }

The main difference is the timestamps, docker only does Unix (int64)

@ningmingxiao
Copy link

you can use nerdctl image history

@ningmingxiao
Copy link

ningmingxiao commented Apr 28, 2022

root# nerdctl -n k8s.io history busybox:1.28
SNAPSHOT                                                                   CREATED        CREATED BY                                       SIZE       COMMENT
<missing>                                                                  3 years ago    /bin/sh -c #(nop)  CMD ["sh"]                    0.0 B
sha256:432b65032b9466b4dadcc5c7b11701e71d21c18400aae946b101ad16be62333a    3 years ago    /bin/sh -c #(nop) ADD file:5f0439d8328ab58c0…    1.1 MiB

@saschagrunert
Copy link
Member

Let's close this for now since it's not supported by cri-tools.

@saschagrunert saschagrunert removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 2, 2022
@afbjorklund
Copy link
Contributor

Let's close this for now since it's not supported by cri-tools.

It is supported by inspecti, no ? Just not fully standardized.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. sig/node Categorizes an issue or PR as relevant to SIG Node.
Projects
None yet
Development

No branches or pull requests

7 participants