Add buildah version and distribution to info

For the sake of debug and problem reporting, we would benefit from knowing
what buildah version was vendored into podman.  Also, knowing the distribution
and distribution version would also be handy.

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude 2018-09-27 12:45:01 -05:00
parent ca8469aace
commit 6db7027e97
5 changed files with 116 additions and 48 deletions

13
API.md
View File

@ -141,6 +141,8 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
[type ImageSearch](#ImageSearch) [type ImageSearch](#ImageSearch)
[type InfoDistribution](#InfoDistribution)
[type InfoGraphStatus](#InfoGraphStatus) [type InfoGraphStatus](#InfoGraphStatus)
[type InfoHost](#InfoHost) [type InfoHost](#InfoHost)
@ -1115,6 +1117,13 @@ is_automated [bool](https://godoc.org/builtin#bool)
name [string](https://godoc.org/builtin#string) name [string](https://godoc.org/builtin#string)
star_count [int](https://godoc.org/builtin#int) star_count [int](https://godoc.org/builtin#int)
### <a name="InfoDistribution"></a>type InfoDistribution
InfoDistribution describes the the host's distribution
distribution [string](https://godoc.org/builtin#string)
version [string](https://godoc.org/builtin#string)
### <a name="InfoGraphStatus"></a>type InfoGraphStatus ### <a name="InfoGraphStatus"></a>type InfoGraphStatus
InfoGraphStatus describes the detailed status of the storage driver InfoGraphStatus describes the detailed status of the storage driver
@ -1128,6 +1137,10 @@ supports_d_type [string](https://godoc.org/builtin#string)
InfoHost describes the host stats portion of PodmanInfo InfoHost describes the host stats portion of PodmanInfo
buildah_version [string](https://godoc.org/builtin#string)
distribution [InfoDistribution](#InfoDistribution)
mem_free [int](https://godoc.org/builtin#int) mem_free [int](https://godoc.org/builtin#int)
mem_total [int](https://godoc.org/builtin#int) mem_total [int](https://godoc.org/builtin#int)

View File

@ -124,8 +124,16 @@ type ContainerNameSpace (
ipc: string ipc: string
) )
# InfoDistribution describes the the host's distribution
type InfoDistribution (
distribution: string,
version: string
)
# InfoHost describes the host stats portion of PodmanInfo # InfoHost describes the host stats portion of PodmanInfo
type InfoHost ( type InfoHost (
buildah_version: string,
distribution: InfoDistribution,
mem_free: int, mem_free: int,
mem_total: int, mem_total: int,
swap_free: int, swap_free: int,

View File

@ -30,111 +30,116 @@ Run podman info with plain text response:
``` ```
$ podman info $ podman info
host: host:
BuildahVersion: 1.4-dev
Conmon: Conmon:
package: conmon-1.10.3-1.gite558bd5.fc28.x86_64 package: Unknown
path: /usr/libexec/crio/conmon path: /usr/libexec/podman/conmon
version: 'conmon version 1.10.3, commit: 55022fb3be4382a61599b7024a677f9a642ae0a7' version: 'conmon version 1.12.0-dev, commit: d724f3d54ad2d95b6de741085d4990190ebfd7ff'
MemFree: 2428579840 Distribution:
MemTotal: 16679260160 distribution: fedora
version: "28"
MemFree: 1271083008
MemTotal: 33074233344
OCIRuntime: OCIRuntime:
package: runc-1.0.0-46.dev.gitb4e2ecb.fc28.x86_64 package: runc-1.0.0-51.dev.gitfdd8055.fc28.x86_64
path: /usr/bin/runc path: /usr/bin/runc
version: 'runc version spec: 1.0.0' version: 'runc version spec: 1.0.0'
SwapFree: 0 SwapFree: 34309664768
SwapTotal: 0 SwapTotal: 34359734272
arch: amd64 arch: amd64
cpus: 4 cpus: 8
hostname: localhost.localdomain hostname: localhost.localdomain
kernel: 4.17.11-200.fc28.x86_64 kernel: 4.18.7-200.fc28.x86_64
os: linux os: linux
uptime: 23h 16m 57.86s (Approximately 0.96 days) uptime: 218h 49m 33.66s (Approximately 9.08 days)
insecure registries: insecure registries:
registries: [] registries: []
registries: registries:
registries: registries:
- docker.io
- quay.io - quay.io
- registry.fedoraproject.org - registry.fedoraproject.org
- docker.io
- registry.access.redhat.com - registry.access.redhat.com
store: store:
ContainerStore: ContainerStore:
number: 3 number: 37
GraphDriverName: overlay GraphDriverName: overlay
GraphOptions: GraphOptions:
- overlay.mountopt=nodev - overlay.mountopt=nodev
- overlay.override_kernel_check=true
GraphRoot: /var/lib/containers/storage GraphRoot: /var/lib/containers/storage
GraphStatus: GraphStatus:
Backing Filesystem: xfs Backing Filesystem: extfs
Native Overlay Diff: "true" Native Overlay Diff: "true"
Supports d_type: "true" Supports d_type: "true"
ImageStore: ImageStore:
number: 2 number: 17
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
{ {
"debug": {
"compiler": "gc",
"git commit": "",
"go version": "go1.10",
"podman version": "0.8.2-dev"
},
"host": { "host": {
"BuildahVersion": "1.4-dev",
"Conmon": { "Conmon": {
"package": "conmon-1.10.3-1.gite558bd5.fc28.x86_64", "package": "Unknown",
"path": "/usr/libexec/crio/conmon", "path": "/usr/libexec/podman/conmon",
"version": "conmon version 1.10.3, commit: 55022fb3be4382a61599b7024a677f9a642ae0a7" "version": "conmon version 1.12.0-dev, commit: d724f3d54ad2d95b6de741085d4990190ebfd7ff"
}, },
"MemFree": 2484420608, "Distribution": {
"MemTotal": 16679260160, "distribution": "fedora",
"version": "28"
},
"MemFree": 1204109312,
"MemTotal": 33074233344,
"OCIRuntime": { "OCIRuntime": {
"package": "runc-1.0.0-46.dev.gitb4e2ecb.fc28.x86_64", "package": "runc-1.0.0-51.dev.gitfdd8055.fc28.x86_64",
"path": "/usr/bin/runc", "path": "/usr/bin/runc",
"version": "runc version spec: 1.0.0" "version": "runc version spec: 1.0.0"
}, },
"SwapFree": 0, "SwapFree": 34309664768,
"SwapTotal": 0, "SwapTotal": 34359734272,
"arch": "amd64", "arch": "amd64",
"cpus": 4, "cpus": 8,
"hostname": "localhost.localdomain", "hostname": "localhost.localdomain",
"kernel": "4.17.11-200.fc28.x86_64", "kernel": "4.18.7-200.fc28.x86_64",
"os": "linux", "os": "linux",
"uptime": "23h 14m 45.48s (Approximately 0.96 days)" "uptime": "218h 50m 35.02s (Approximately 9.08 days)"
}, },
"insecure registries": { "insecure registries": {
"registries": [] "registries": []
}, },
"registries": { "registries": {
"registries": [ "registries": [
"docker.io",
"quay.io", "quay.io",
"registry.fedoraproject.org", "registry.fedoraproject.org",
"docker.io",
"registry.access.redhat.com" "registry.access.redhat.com"
] ]
}, },
"store": { "store": {
"ContainerStore": { "ContainerStore": {
"number": 3 "number": 37
}, },
"GraphDriverName": "overlay", "GraphDriverName": "overlay",
"GraphOptions": [ "GraphOptions": [
"overlay.mountopt=nodev" "overlay.mountopt=nodev",
"overlay.override_kernel_check=true"
], ],
"GraphRoot": "/var/lib/containers/storage", "GraphRoot": "/var/lib/containers/storage",
"GraphStatus": { "GraphStatus": {
"Backing Filesystem": "xfs", "Backing Filesystem": "extfs",
"Native Overlay Diff": "true", "Native Overlay Diff": "true",
"Supports d_type": "true" "Supports d_type": "true"
}, },
"ImageStore": { "ImageStore": {
"number": 2 "number": 17
}, },
"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"}}

View File

@ -1,8 +1,10 @@
package libpod package libpod
import ( import (
"bufio"
"bytes" "bytes"
"fmt" "fmt"
"github.com/containers/buildah"
"io/ioutil" "io/ioutil"
"os" "os"
"runtime" "runtime"
@ -39,6 +41,7 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
info["SwapFree"] = mi.SwapFree info["SwapFree"] = mi.SwapFree
conmonVersion, _ := r.GetConmonVersion() conmonVersion, _ := r.GetConmonVersion()
ociruntimeVersion, _ := r.GetOCIRuntimeVersion() ociruntimeVersion, _ := r.GetOCIRuntimeVersion()
hostDistributionInfo := r.GetHostDistributionInfo()
info["Conmon"] = map[string]interface{}{ info["Conmon"] = map[string]interface{}{
"path": r.conmonPath, "path": r.conmonPath,
"package": r.ociRuntime.conmonPackage(), "package": r.ociRuntime.conmonPackage(),
@ -49,7 +52,12 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
"package": r.ociRuntime.pathPackage(), "package": r.ociRuntime.pathPackage(),
"version": ociruntimeVersion, "version": ociruntimeVersion,
} }
info["Distribution"] = map[string]interface{}{
"distribution": hostDistributionInfo["Distribution"],
"version": hostDistributionInfo["Version"],
}
info["BuildahVersion"] = buildah.Version
kv, err := readKernelVersion() kv, err := readKernelVersion()
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error reading kernel version") return nil, errors.Wrapf(err, "error reading kernel version")
@ -178,3 +186,30 @@ func (r *Runtime) GetOCIRuntimeVersion() (string, error) {
} }
return strings.TrimSuffix(output, "\n"), nil return strings.TrimSuffix(output, "\n"), nil
} }
// GetHostDistributionInfo returns a map containing the host's distribution and version
func (r *Runtime) GetHostDistributionInfo() map[string]string {
dist := make(map[string]string)
// Populate values in case we cannot find the values
// or the file
dist["Distribution"] = "unknown"
dist["Version"] = "unknown"
f, err := os.Open("/etc/os-release")
if err != nil {
return dist
}
defer f.Close()
l := bufio.NewScanner(f)
for l.Scan() {
if strings.HasPrefix(l.Text(), "ID=") {
dist["Distribution"] = strings.TrimPrefix(l.Text(), "ID=")
}
if strings.HasPrefix(l.Text(), "VERSION_ID=") {
dist["Version"] = strings.Trim(strings.TrimPrefix(l.Text(), "VERSION_ID="), "\"")
}
}
return dist
}

View File

@ -42,8 +42,15 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error {
if err != nil { if err != nil {
return call.ReplyErrorOccurred(err.Error()) return call.ReplyErrorOccurred(err.Error())
} }
host := info[0].Data host := info[0].Data
distribution := iopodman.InfoDistribution{
Distribution: host["Distribution"].(map[string]interface{})["distribution"].(string),
Version: host["Distribution"].(map[string]interface{})["version"].(string),
}
infoHost := iopodman.InfoHost{ infoHost := iopodman.InfoHost{
Buildah_version: host["BuildahVersion"].(string),
Distribution: distribution,
Mem_free: host["MemFree"].(int64), Mem_free: host["MemFree"].(int64),
Mem_total: host["MemTotal"].(int64), Mem_total: host["MemTotal"].(int64),
Swap_free: host["SwapFree"].(int64), Swap_free: host["SwapFree"].(int64),