summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-06 16:45:25 +0200
committerGitHub <noreply@github.com>2019-09-06 16:45:25 +0200
commit575ffee2f05dc607d32da2d0bfd1b82f47aab8bb (patch)
tree1808f264855e5277034a2da4ac79a0bc2f278d9f
parent88980859eccacf7a5752952b4dfba6d25374ec2d (diff)
parentb2b284111e49d3d953f71a794f25aa9ddfbb8568 (diff)
downloadpodman-575ffee2f05dc607d32da2d0bfd1b82f47aab8bb.tar.gz
podman-575ffee2f05dc607d32da2d0bfd1b82f47aab8bb.tar.bz2
podman-575ffee2f05dc607d32da2d0bfd1b82f47aab8bb.zip
Merge pull request #3918 from rhatdan/info
Return information about mount_program (fuse-overlayfs)
-rw-r--r--libpod/info.go36
-rw-r--r--libpod/oci_linux.go30
-rw-r--r--libpod/util.go37
-rw-r--r--pkg/varlinkapi/system.go4
4 files changed, 75 insertions, 32 deletions
diff --git a/libpod/info.go b/libpod/info.go
index 9ab6f7e52..e5132b5f6 100644
--- a/libpod/info.go
+++ b/libpod/info.go
@@ -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())
diff --git a/libpod/oci_linux.go b/libpod/oci_linux.go
index 1613c3e68..6dba1260c 100644
--- a/libpod/oci_linux.go
+++ b/libpod/oci_linux.go
@@ -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
diff --git a/libpod/util.go b/libpod/util.go
index 164800af4..84fd490bf 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -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
+}
diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go
index 2de785b79..f6057f5fc 100644
--- a/pkg/varlinkapi/system.go
+++ b/pkg/varlinkapi/system.go
@@ -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,
}