Have info print conmon/oci runtime information

We need into to identify the OCI runtime and conmon used by podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1224
Approved by: baude
This commit is contained in:
Daniel J Walsh
2018-08-06 11:35:29 -04:00
committed by Atomic Bot
parent b1de943eea
commit 33d6221ae3
4 changed files with 89 additions and 34 deletions

View File

@ -30,57 +30,78 @@ Run podman info with plain text response:
``` ```
$ podman info $ podman info
host: host:
MemFree: 28464242688 Conmon:
MemTotal: 33147686912 package: conmon-1.10.3-1.gite558bd5.fc28.x86_64
OCIRuntimeVersion: 'runc version spec: 1.0.0' path: /usr/libexec/crio/conmon
SwapFree: 34359734272 version: 'conmon version 1.10.3, commit: 55022fb3be4382a61599b7024a677f9a642ae0a7'
SwapTotal: 34359734272 MemFree: 2428579840
MemTotal: 16679260160
OCIRuntime:
package: runc-1.0.0-46.dev.gitb4e2ecb.fc28.x86_64
path: /usr/bin/runc
version: 'runc version spec: 1.0.0'
SwapFree: 0
SwapTotal: 0
arch: amd64 arch: amd64
conmonVersion: 'conmon version 1.11.0-dev, commit: 42209340c7abcab66f47e9161fa0f1b16ea8c134' cpus: 4
cpus: 8
hostname: localhost.localdomain hostname: localhost.localdomain
kernel: 4.17.9-200.fc28.x86_64 kernel: 4.17.11-200.fc28.x86_64
os: linux os: linux
uptime: 47m 34.95s uptime: 23h 16m 57.86s (Approximately 0.96 days)
insecure registries: insecure registries:
registries: [] registries: []
registries: registries:
registries: registries:
- docker.io - docker.io
- quay.io
- registry.fedoraproject.org - registry.fedoraproject.org
- registry.access.redhat.com - registry.access.redhat.com
store: store:
ContainerStore: ContainerStore:
number: 40 number: 3
GraphDriverName: overlay GraphDriverName: overlay
GraphOptions: GraphOptions:
- overlay.override_kernel_check=true - overlay.mountopt=nodev
GraphRoot: /var/lib/containers/storage GraphRoot: /var/lib/containers/storage
GraphStatus: GraphStatus:
Backing Filesystem: extfs Backing Filesystem: xfs
Native Overlay Diff: "true" Native Overlay Diff: "true"
Supports d_type: "true" Supports d_type: "true"
ImageStore: ImageStore:
number: 10 number: 2
RunRoot: /var/run/containers/storage RunRoot: /var/run/containers/storage
``` ```
Run podman info with JSON formatted response: Run podman info with JSON formatted response:
``` ```
$ podman info --debug --format json $ podman info --debug --format json
{ {
"debug": {
"compiler": "gc",
"git commit": "",
"go version": "go1.10",
"podman version": "0.8.2-dev"
},
"host": { "host": {
"MemFree": 28421324800, "Conmon": {
"MemTotal": 33147686912, "package": "conmon-1.10.3-1.gite558bd5.fc28.x86_64",
"OCIRuntimeVersion": "runc version spec: 1.0.0", "path": "/usr/libexec/crio/conmon",
"SwapFree": 34359734272, "version": "conmon version 1.10.3, commit: 55022fb3be4382a61599b7024a677f9a642ae0a7"
"SwapTotal": 34359734272, },
"MemFree": 2484420608,
"MemTotal": 16679260160,
"OCIRuntime": {
"package": "runc-1.0.0-46.dev.gitb4e2ecb.fc28.x86_64",
"path": "/usr/bin/runc",
"version": "runc version spec: 1.0.0"
},
"SwapFree": 0,
"SwapTotal": 0,
"arch": "amd64", "arch": "amd64",
"conmonVersion": "conmon version 1.11.0-dev, commit: 42209340c7abcab66f47e9161fa0f1b16ea8c134", "cpus": 4,
"cpus": 8,
"hostname": "localhost.localdomain", "hostname": "localhost.localdomain",
"kernel": "4.17.9-200.fc28.x86_64", "kernel": "4.17.11-200.fc28.x86_64",
"os": "linux", "os": "linux",
"uptime": "50m 20.27s" "uptime": "23h 14m 45.48s (Approximately 0.96 days)"
}, },
"insecure registries": { "insecure registries": {
"registries": [] "registries": []
@ -88,35 +109,36 @@ $ podman info --debug --format json
"registries": { "registries": {
"registries": [ "registries": [
"docker.io", "docker.io",
"quay.io",
"registry.fedoraproject.org", "registry.fedoraproject.org",
"registry.access.redhat.com", "registry.access.redhat.com"
] ]
}, },
"store": { "store": {
"ContainerStore": { "ContainerStore": {
"number": 40 "number": 3
}, },
"GraphDriverName": "overlay", "GraphDriverName": "overlay",
"GraphOptions": [ "GraphOptions": [
"overlay.override_kernel_check=true" "overlay.mountopt=nodev"
], ],
"GraphRoot": "/var/lib/containers/storage", "GraphRoot": "/var/lib/containers/storage",
"GraphStatus": { "GraphStatus": {
"Backing Filesystem": "extfs", "Backing Filesystem": "xfs",
"Native Overlay Diff": "true", "Native Overlay Diff": "true",
"Supports d_type": "true" "Supports d_type": "true"
}, },
"ImageStore": { "ImageStore": {
"number": 10 "number": 2
}, },
"RunRoot": "/var/run/containers/storage" "RunRoot": "/var/run/containers/storage"
} }
} }
``` ```
Run podman info and only get the registries information. Run podman info and only get the registries information.
``` ```
$ podman info --format={{".registries"}} $ podman info --format={{".registries"}}
map[registries:[docker.io registry.fedoraproject.org registry.access.redhat.com]] map[registries:[docker.io quay.io registry.fedoraproject.org registry.access.redhat.com]]
``` ```
## SEE ALSO ## SEE ALSO

View File

@ -37,6 +37,18 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
info["MemFree"] = mi.MemFree info["MemFree"] = mi.MemFree
info["SwapTotal"] = mi.SwapTotal info["SwapTotal"] = mi.SwapTotal
info["SwapFree"] = mi.SwapFree info["SwapFree"] = mi.SwapFree
conmonVersion, _ := r.GetConmonVersion()
ociruntimeVersion, _ := r.GetOCIRuntimeVersion()
info["Conmon"] = map[string]interface{}{
"path": r.conmonPath,
"package": r.ociRuntime.conmonPackage(),
"version": conmonVersion,
}
info["OCIRuntime"] = map[string]interface{}{
"path": r.ociRuntime.path,
"package": r.ociRuntime.pathPackage(),
"version": ociruntimeVersion,
}
kv, err := readKernelVersion() kv, err := readKernelVersion()
if err != nil { if err != nil {
@ -86,11 +98,6 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
} }
info["hostname"] = host info["hostname"] = host
// Don't think this should be catastrophic if we cannot get the versions
conmonVersion, _ := r.GetConmonVersion()
ociruntimeVersion, _ := r.GetOCIRuntimeVersion()
info["conmonVersion"] = conmonVersion
info["OCIRuntimeVersion"] = ociruntimeVersion
return info, nil return info, nil
} }

View File

@ -8,6 +8,7 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings"
"sync" "sync"
"github.com/containerd/cgroups" "github.com/containerd/cgroups"
@ -102,3 +103,20 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err e
return err return err
} }
func rpmVersion(path string) string {
output := "Unknown"
cmd := exec.Command("/usr/bin/rpm", "-q", "-f", path)
if outp, err := cmd.Output(); err == nil {
output = string(outp)
}
return strings.Trim(output, "\n")
}
func (r *OCIRuntime) pathPackage() string {
return rpmVersion(r.path)
}
func (r *OCIRuntime) conmonPackage() string {
return rpmVersion(r.conmonPath)
}

View File

@ -18,3 +18,11 @@ func newPipe() (parent *os.File, child *os.File, err error) {
func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err error) { func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err error) {
return ErrNotImplemented return ErrNotImplemented
} }
func (r *OCIRuntime) pathPackage() string {
return ""
}
func (r *OCIRuntime) conmonPackage() string {
return ""
}