Skip to content

decode spec in ctr c info#2688

Merged
crosbymichael merged 1 commit intocontainerd:masterfrom
crosbymichael:ctrdecodespec
Oct 16, 2018
Merged

decode spec in ctr c info#2688
crosbymichael merged 1 commit intocontainerd:masterfrom
crosbymichael:ctrdecodespec

Conversation

@crosbymichael
Copy link
Copy Markdown
Member

Closes #2568

Signed-off-by: Lifubang [email protected]

Before this commit, the Spec.value field are incomprehensible:

root@dockerdemo:/opt/runctest/redis# ctr c info busybox
{
    "ID": "busybox",
    "Labels": null,
    "Image": "docker.acmcoder.com/public/busybox:latest",
    "Runtime": {
        "Name": "io.containerd.runtime.v1.linux",
        "Options": null
    },
    "Spec": {
        "type_url": "types.containerd.io/opencontainers/runtime-spec/1/Spec",
        "value": "eyJvY2lWZXJzaW9uIjoiM*************"
    },
    "SnapshotKey": "busybox",
    "Snapshotter": "overlayfs",
    "CreatedAt": "2018-08-23T05:16:17.371767147Z",
    "UpdatedAt": "2018-08-23T05:16:17.371767147Z",
    "Extensions": null
}

After the commit, there are some useful information for us:

root@dockerdemo:/opt/runctest/redis# ~/gocode/src/github.com/containerd/containerd/bin/ctr c info busybox
{
    "ID": "busybox",
    "Labels": null,
    "Image": "docker.acmcoder.com/public/busybox:latest",
    "Runtime": {
        "Name": "io.containerd.runtime.v1.linux",
        "Options": null
    },
    "SnapshotKey": "busybox",
    "Snapshotter": "overlayfs",
    "CreatedAt": "2018-08-23T05:16:17.371767147Z",
    "UpdatedAt": "2018-08-23T05:16:17.371767147Z",
    "Extensions": null,
    "Spec": {
        "type_url": "types.containerd.io/opencontainers/runtime-spec/1/Spec",
        "value": {
            "linux": {
                "cgroupsPath": "/default/busybox",
                "maskedPaths": [
                    "/proc/acpi",
                    "/proc/kcore",
                    "/proc/keys",
                    "/proc/latency_stats",
                    "/proc/timer_list",
                    "/proc/timer_stats",
                    "/proc/sched_debug",
                    "/sys/firmware",
                    "/proc/scsi"
                ],
                "namespaces": [
                    {
                        "type": "pid"
                    },
                    {
                        "type": "ipc"
                    },
                    {
                        "type": "uts"
                    },
                    {
                        "type": "mount"
                    },
                    {
                        "type": "network"
                    }
                ],
                "readonlyPaths": [
                    "/proc/asound",
                    "/proc/bus",
                    "/proc/fs",
                    "/proc/irq",
                    "/proc/sys",
                    "/proc/sysrq-trigger"
                ],
                "resources": {
                    "devices": [
                        {
                            "access": "rwm",
                            "allow": false
                        }
                    ]
                }
            },
            "mounts": [
                {
                    "destination": "/proc",
                    "source": "proc",
                    "type": "proc"
                },
                {
                    "destination": "/dev",
                    "options": [
                        "nosuid",
                        "strictatime",
                        "mode=755",
                        "size=65536k"
                    ],
                    "source": "tmpfs",
                    "type": "tmpfs"
                },
                {
                    "destination": "/dev/pts",
                    "options": [
                        "nosuid",
                        "noexec",
                        "newinstance",
                        "ptmxmode=0666",
                        "mode=0620",
                        "gid=5"
                    ],
                    "source": "devpts",
                    "type": "devpts"
                },
                {
                    "destination": "/dev/shm",
                    "options": [
                        "nosuid",
                        "noexec",
                        "nodev",
                        "mode=1777",
                        "size=65536k"
                    ],
                    "source": "shm",
                    "type": "tmpfs"
                },
                {
                    "destination": "/dev/mqueue",
                    "options": [
                        "nosuid",
                        "noexec",
                        "nodev"
                    ],
                    "source": "mqueue",
                    "type": "mqueue"
                },
                {
                    "destination": "/sys",
                    "options": [
                        "nosuid",
                        "noexec",
                        "nodev",
                        "ro"
                    ],
                    "source": "sysfs",
                    "type": "sysfs"
                },
                {
                    "destination": "/run",
                    "options": [
                        "nosuid",
                        "strictatime",
                        "mode=755",
                        "size=65536k"
                    ],
                    "source": "tmpfs",
                    "type": "tmpfs"
                }
            ],
            "ociVersion": "1.0.1",
            "process": {
                "args": [
                    "sh"
                ],
                "capabilities": {
                    "bounding": [
                        "CAP_CHOWN",
                        "CAP_DAC_OVERRIDE",
                        "CAP_FSETID",
                        "CAP_FOWNER",
                        "CAP_MKNOD",
                        "CAP_NET_RAW",
                        "CAP_SETGID",
                        "CAP_SETUID",
                        "CAP_SETFCAP",
                        "CAP_SETPCAP",
                        "CAP_NET_BIND_SERVICE",
                        "CAP_SYS_CHROOT",
                        "CAP_KILL",
                        "CAP_AUDIT_WRITE"
                    ],
                    "effective": [
                        "CAP_CHOWN",
                        "CAP_DAC_OVERRIDE",
                        "CAP_FSETID",
                        "CAP_FOWNER",
                        "CAP_MKNOD",
                        "CAP_NET_RAW",
                        "CAP_SETGID",
                        "CAP_SETUID",
                        "CAP_SETFCAP",
                        "CAP_SETPCAP",
                        "CAP_NET_BIND_SERVICE",
                        "CAP_SYS_CHROOT",
                        "CAP_KILL",
                        "CAP_AUDIT_WRITE"
                    ],
                    "inheritable": [
                        "CAP_CHOWN",
                        "CAP_DAC_OVERRIDE",
                        "CAP_FSETID",
                        "CAP_FOWNER",
                        "CAP_MKNOD",
                        "CAP_NET_RAW",
                        "CAP_SETGID",
                        "CAP_SETUID",
                        "CAP_SETFCAP",
                        "CAP_SETPCAP",
                        "CAP_NET_BIND_SERVICE",
                        "CAP_SYS_CHROOT",
                        "CAP_KILL",
                        "CAP_AUDIT_WRITE"
                    ],
                    "permitted": [
                        "CAP_CHOWN",
                        "CAP_DAC_OVERRIDE",
                        "CAP_FSETID",
                        "CAP_FOWNER",
                        "CAP_MKNOD",
                        "CAP_NET_RAW",
                        "CAP_SETGID",
                        "CAP_SETUID",
                        "CAP_SETFCAP",
                        "CAP_SETPCAP",
                        "CAP_NET_BIND_SERVICE",
                        "CAP_SYS_CHROOT",
                        "CAP_KILL",
                        "CAP_AUDIT_WRITE"
                    ]
                },
                "cwd": "/",
                "env": [
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "TERM=xterm"
                ],
                "noNewPrivileges": true,
                "rlimits": [
                    {
                        "hard": 1024,
                        "soft": 1024,
                        "type": "RLIMIT_NOFILE"
                    }
                ],
                "terminal": true,
                "user": {
                    "gid": 0,
                    "uid": 0
                }
            },
            "root": {
                "path": "rootfs"
            }
        }
    }
}

Signed-off-by: Lifubang <[email protected]>

fix some errors

use typeurl.UnmarshalAny instead json.Unmarshal to interface{}

Signed-off-by: Lifubang <[email protected]>
Signed-off-by: Michael Crosby <[email protected]>
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2688 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #2688   +/-   ##
======================================
  Coverage      45%     45%           
======================================
  Files          92      92           
  Lines       10114   10114           
======================================
  Hits         4552    4552           
  Misses       4842    4842           
  Partials      720     720
Flag Coverage Δ
#linux 48.74% <ø> (ø) ⬆️
#windows 41.76% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75d7d6e...cb0eed8. Read the comment docs.

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lifubang
Copy link
Copy Markdown
Contributor

LGTM

@AkihiroSuda
Copy link
Copy Markdown
Member

I think the decoded value should be printed with a different name. e.g. value_decoded

@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Oct 2, 2018

I think the decoded value should be printed with a different name. e.g. value_decoded

Maybe, just make a --raw option, rather than introduce a new field.

@AkihiroSuda
Copy link
Copy Markdown
Member

Maybe, just make a --raw option, rather than introduce a new field.

Either is fine to me, but if we reuse the existing value field for different representation of the spec, we also need to change the value of type_url.

e.g. "types.containerd.io/opencontainers/runtime-spec/1/Spec" -> "types.containerd.io/opencontainers/runtime-spec/1/Spec/Decoded"

@crosbymichael
Copy link
Copy Markdown
Member Author

I think ya'll are making this more complicated than it needs to be. All this does is "dereference" the value and prints it out in ctr. This is for UX/display, nothing more.

@fuweid
Copy link
Copy Markdown
Member

fuweid commented Oct 16, 2018

any update on this pr? I think it is good to move on. 😄

@crosbymichael crosbymichael merged commit f1dfe86 into containerd:master Oct 16, 2018
@crosbymichael crosbymichael deleted the ctrdecodespec branch October 16, 2018 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants