mirror of https://github.com/containers/podman.git
Merge pull request #3918 from rhatdan/info
Return information about mount_program (fuse-overlayfs)
This commit is contained in:
commit
575ffee2f0
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -17,6 +18,7 @@ import (
|
|||
"github.com/containers/storage"
|
||||
"github.com/containers/storage/pkg/system"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// top-level "host" info
|
||||
|
@ -44,6 +46,20 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
|
|||
"package": r.defaultOCIRuntime.conmonPackage(),
|
||||
"version": conmonVersion,
|
||||
}
|
||||
if rootless.IsRootless() {
|
||||
if path, err := exec.LookPath("slirp4netns"); err == nil {
|
||||
logrus.Warnf("Failed to retrieve program version for %s: %v", path, err)
|
||||
version, err := programVersion(path)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to retrieve program version for %s: %v", path, err)
|
||||
}
|
||||
program := map[string]interface{}{}
|
||||
program["Executable"] = path
|
||||
program["Version"] = version
|
||||
program["Package"] = packageVersion(path)
|
||||
info["slirp4netns"] = program
|
||||
}
|
||||
}
|
||||
info["OCIRuntime"] = map[string]interface{}{
|
||||
"path": r.defaultOCIRuntime.path,
|
||||
"package": r.defaultOCIRuntime.pathPackage(),
|
||||
|
@ -53,7 +69,6 @@ func (r *Runtime) hostInfo() (map[string]interface{}, error) {
|
|||
"distribution": hostDistributionInfo["Distribution"],
|
||||
"version": hostDistributionInfo["Version"],
|
||||
}
|
||||
|
||||
info["BuildahVersion"] = buildah.Version
|
||||
kv, err := readKernelVersion()
|
||||
if err != nil {
|
||||
|
@ -113,7 +128,24 @@ func (r *Runtime) storeInfo() (map[string]interface{}, error) {
|
|||
info["GraphRoot"] = r.store.GraphRoot()
|
||||
info["RunRoot"] = r.store.RunRoot()
|
||||
info["GraphDriverName"] = r.store.GraphDriverName()
|
||||
info["GraphOptions"] = r.store.GraphOptions()
|
||||
graphOptions := map[string]interface{}{}
|
||||
for _, o := range r.store.GraphOptions() {
|
||||
split := strings.SplitN(o, "=", 2)
|
||||
if strings.HasSuffix(split[0], "mount_program") {
|
||||
version, err := programVersion(split[1])
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to retrieve program version for %s: %v", split[1], err)
|
||||
}
|
||||
program := map[string]interface{}{}
|
||||
program["Executable"] = split[1]
|
||||
program["Version"] = version
|
||||
program["Package"] = packageVersion(split[1])
|
||||
graphOptions[split[0]] = program
|
||||
} else {
|
||||
graphOptions[split[0]] = split[1]
|
||||
}
|
||||
}
|
||||
info["GraphOptions"] = graphOptions
|
||||
info["VolumePath"] = r.config.VolumePath
|
||||
|
||||
configFile, err := storage.DefaultConfigFile(rootless.IsRootless())
|
||||
|
|
|
@ -24,8 +24,6 @@ import (
|
|||
"k8s.io/client-go/tools/remotecommand"
|
||||
)
|
||||
|
||||
const unknownPackage = "Unknown"
|
||||
|
||||
// makeAccessible changes the path permission and each parent directory to have --x--x--x
|
||||
func makeAccessible(path string, uid, gid int) error {
|
||||
for ; path != "/"; path = filepath.Dir(path) {
|
||||
|
@ -114,36 +112,12 @@ func (r *OCIRuntime) createContainer(ctr *Container, restoreOptions *ContainerCh
|
|||
return r.createOCIContainer(ctr, restoreOptions)
|
||||
}
|
||||
|
||||
func rpmVersion(path string) string {
|
||||
output := unknownPackage
|
||||
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 dpkgVersion(path string) string {
|
||||
output := unknownPackage
|
||||
cmd := exec.Command("/usr/bin/dpkg", "-S", path)
|
||||
if outp, err := cmd.Output(); err == nil {
|
||||
output = string(outp)
|
||||
}
|
||||
return strings.Trim(output, "\n")
|
||||
}
|
||||
|
||||
func (r *OCIRuntime) pathPackage() string {
|
||||
if out := rpmVersion(r.path); out != unknownPackage {
|
||||
return out
|
||||
}
|
||||
return dpkgVersion(r.path)
|
||||
return packageVersion(r.path)
|
||||
}
|
||||
|
||||
func (r *OCIRuntime) conmonPackage() string {
|
||||
if out := rpmVersion(r.conmonPath); out != unknownPackage {
|
||||
return out
|
||||
}
|
||||
return dpkgVersion(r.conmonPath)
|
||||
return packageVersion(r.conmonPath)
|
||||
}
|
||||
|
||||
// execContainer executes a command in a running container
|
||||
|
|
|
@ -3,6 +3,7 @@ package libpod
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -10,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
"github.com/containers/libpod/utils"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -20,6 +22,8 @@ const (
|
|||
// DefaultTransport is a prefix that we apply to an image name
|
||||
// to check docker hub first for the image
|
||||
DefaultTransport = "docker://"
|
||||
|
||||
unknownPackage = "Unknown"
|
||||
)
|
||||
|
||||
// FuncTimer helps measure the execution time of a function
|
||||
|
@ -152,3 +156,36 @@ func JSONDeepCopy(from, to interface{}) error {
|
|||
}
|
||||
return json.Unmarshal(tmp, to)
|
||||
}
|
||||
|
||||
func dpkgVersion(path string) string {
|
||||
output := unknownPackage
|
||||
cmd := exec.Command("/usr/bin/dpkg", "-S", path)
|
||||
if outp, err := cmd.Output(); err == nil {
|
||||
output = string(outp)
|
||||
}
|
||||
return strings.Trim(output, "\n")
|
||||
}
|
||||
|
||||
func rpmVersion(path string) string {
|
||||
output := unknownPackage
|
||||
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 packageVersion(program string) string {
|
||||
if out := rpmVersion(program); out != unknownPackage {
|
||||
return out
|
||||
}
|
||||
return dpkgVersion(program)
|
||||
}
|
||||
|
||||
func programVersion(mountProgram string) (string, error) {
|
||||
output, err := utils.ExecCmd(mountProgram, "--version")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.TrimSuffix(output, "\n"), nil
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
package varlinkapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
goruntime "runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/containers/libpod/cmd/podman/varlink"
|
||||
|
@ -83,7 +83,7 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error {
|
|||
Images: int64(store["ImageStore"].(map[string]interface{})["number"].(int)),
|
||||
Run_root: store["RunRoot"].(string),
|
||||
Graph_root: store["GraphRoot"].(string),
|
||||
Graph_driver_options: strings.Join(store["GraphOptions"].([]string), ", "),
|
||||
Graph_driver_options: fmt.Sprintf("%v", store["GraphOptions"]),
|
||||
Graph_status: graphStatus,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue