From 70e7fcc595527358f91082e6b196fffc73dd7665 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Fri, 11 Nov 2016 08:02:23 -0800 Subject: [PATCH] Remove extra binaries commit variables from windows build Signed-off-by: Kenfe-Mickael Laventure --- daemon/info.go | 75 ++------------------------------------ daemon/info_unix.go | 81 ++++++++++++++++++++++++++++++++++++++++++ daemon/info_windows.go | 9 +++++ hack/make/.go-autogen | 14 ++++++++ 4 files changed, 106 insertions(+), 73 deletions(-) create mode 100644 daemon/info_unix.go create mode 100644 daemon/info_windows.go diff --git a/daemon/info.go b/daemon/info.go index d0e00ab669..1758fafdc6 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -1,11 +1,8 @@ package daemon import ( - "context" "os" - "os/exec" "runtime" - "strings" "sync/atomic" "time" @@ -135,76 +132,8 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) { Isolation: daemon.defaultIsolation, } - // TODO Windows. Refactor this more once sysinfo is refactored into - // platform specific code. On Windows, sysinfo.cgroupMemInfo and - // sysinfo.cgroupCpuInfo will be nil otherwise and cause a SIGSEGV if - // an attempt is made to access through them. - if runtime.GOOS != "windows" { - v.MemoryLimit = sysInfo.MemoryLimit - v.SwapLimit = sysInfo.SwapLimit - v.KernelMemory = sysInfo.KernelMemory - v.OomKillDisable = sysInfo.OomKillDisable - v.CPUCfsPeriod = sysInfo.CPUCfsPeriod - v.CPUCfsQuota = sysInfo.CPUCfsQuota - v.CPUShares = sysInfo.CPUShares - v.CPUSet = sysInfo.Cpuset - v.Runtimes = daemon.configStore.GetAllRuntimes() - v.DefaultRuntime = daemon.configStore.GetDefaultRuntimeName() - v.InitBinary = daemon.configStore.GetInitPath() - - v.ContainerdCommit.Expected = dockerversion.ContainerdCommitID - if sv, err := daemon.containerd.GetServerVersion(context.Background()); err == nil { - v.ContainerdCommit.ID = sv.Revision - } else { - logrus.Warnf("failed to retrieve containerd version: %v", err) - v.ContainerdCommit.ID = "N/A" - } - - v.RuncCommit.Expected = dockerversion.RuncCommitID - if rv, err := exec.Command(DefaultRuntimeBinary, "--version").Output(); err == nil { - parts := strings.Split(strings.TrimSpace(string(rv)), "\n") - if len(parts) == 3 { - parts = strings.Split(parts[1], ": ") - if len(parts) == 2 { - v.RuncCommit.ID = strings.TrimSpace(parts[1]) - } - } - - if v.RuncCommit.ID == "" { - logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultRuntimeBinary, string(rv)) - v.RuncCommit.ID = "N/A" - } - } else { - logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err) - v.RuncCommit.ID = "N/A" - } - - v.InitCommit.Expected = dockerversion.InitCommitID - if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil { - parts := strings.Split(strings.TrimSpace(string(rv)), " - ") - if len(parts) == 2 { - if dockerversion.InitCommitID[0] == 'v' { - vs := strings.TrimPrefix(parts[0], "tini version ") - v.InitCommit.ID = "v" + vs - } else { - // Get the sha1 - gitParts := strings.Split(parts[1], ".") - if len(gitParts) == 2 && gitParts[0] == "git" { - v.InitCommit.ID = gitParts[1] - v.InitCommit.Expected = dockerversion.InitCommitID[0:len(gitParts[1])] - } - } - } - - if v.InitCommit.ID == "" { - logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultInitBinary, string(rv)) - v.InitCommit.ID = "N/A" - } - } else { - logrus.Warnf("failed to retrieve %s version", DefaultInitBinary) - v.InitCommit.ID = "N/A" - } - } + // Retrieve platform specific info + daemon.FillPlatformInfo(v, sysInfo) hostname := "" if hn, err := os.Hostname(); err != nil { diff --git a/daemon/info_unix.go b/daemon/info_unix.go new file mode 100644 index 0000000000..fd2d1a1c57 --- /dev/null +++ b/daemon/info_unix.go @@ -0,0 +1,81 @@ +// +build !windows + +package daemon + +import ( + "context" + "os/exec" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/docker/docker/api/types" + "github.com/docker/docker/dockerversion" + "github.com/docker/docker/pkg/sysinfo" +) + +func (daemon *Daemon) FillPlatformInfo(v *types.InfoBase, sysInfo *sysinfo.SysInfo) { + v.MemoryLimit = sysInfo.MemoryLimit + v.SwapLimit = sysInfo.SwapLimit + v.KernelMemory = sysInfo.KernelMemory + v.OomKillDisable = sysInfo.OomKillDisable + v.CPUCfsPeriod = sysInfo.CPUCfsPeriod + v.CPUCfsQuota = sysInfo.CPUCfsQuota + v.CPUShares = sysInfo.CPUShares + v.CPUSet = sysInfo.Cpuset + v.Runtimes = daemon.configStore.GetAllRuntimes() + v.DefaultRuntime = daemon.configStore.GetDefaultRuntimeName() + v.InitBinary = daemon.configStore.GetInitPath() + + v.ContainerdCommit.Expected = dockerversion.ContainerdCommitID + if sv, err := daemon.containerd.GetServerVersion(context.Background()); err == nil { + v.ContainerdCommit.ID = sv.Revision + } else { + logrus.Warnf("failed to retrieve containerd version: %v", err) + v.ContainerdCommit.ID = "N/A" + } + + v.RuncCommit.Expected = dockerversion.RuncCommitID + if rv, err := exec.Command(DefaultRuntimeBinary, "--version").Output(); err == nil { + parts := strings.Split(strings.TrimSpace(string(rv)), "\n") + if len(parts) == 3 { + parts = strings.Split(parts[1], ": ") + if len(parts) == 2 { + v.RuncCommit.ID = strings.TrimSpace(parts[1]) + } + } + + if v.RuncCommit.ID == "" { + logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultRuntimeBinary, string(rv)) + v.RuncCommit.ID = "N/A" + } + } else { + logrus.Warnf("failed to retrieve %s version: %v", DefaultRuntimeBinary, err) + v.RuncCommit.ID = "N/A" + } + + v.InitCommit.Expected = dockerversion.InitCommitID + if rv, err := exec.Command(DefaultInitBinary, "--version").Output(); err == nil { + parts := strings.Split(strings.TrimSpace(string(rv)), " - ") + if len(parts) == 2 { + if dockerversion.InitCommitID[0] == 'v' { + vs := strings.TrimPrefix(parts[0], "tini version ") + v.InitCommit.ID = "v" + vs + } else { + // Get the sha1 + gitParts := strings.Split(parts[1], ".") + if len(gitParts) == 2 && gitParts[0] == "git" { + v.InitCommit.ID = gitParts[1] + v.InitCommit.Expected = dockerversion.InitCommitID[0:len(gitParts[1])] + } + } + } + + if v.InitCommit.ID == "" { + logrus.Warnf("failed to retrieve %s version: unknown output format: %s", DefaultInitBinary, string(rv)) + v.InitCommit.ID = "N/A" + } + } else { + logrus.Warnf("failed to retrieve %s version", DefaultInitBinary) + v.InitCommit.ID = "N/A" + } +} diff --git a/daemon/info_windows.go b/daemon/info_windows.go new file mode 100644 index 0000000000..783062e89b --- /dev/null +++ b/daemon/info_windows.go @@ -0,0 +1,9 @@ +package daemon + +import ( + "github.com/docker/docker/api/types" + "github.com/docker/docker/pkg/sysinfo" +) + +func (daemon *Daemon) FillPlatformInfo(v *types.InfoBase, sysInfo *sysinfo.SysInfo) { +} diff --git a/hack/make/.go-autogen b/hack/make/.go-autogen index e954778ce3..4d26052bb7 100644 --- a/hack/make/.go-autogen +++ b/hack/make/.go-autogen @@ -17,6 +17,20 @@ const ( Version string = "$VERSION" BuildTime string = "$BUILDTIME" IAmStatic string = "${IAMSTATIC:-true}" +) + +// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen +DVEOF + +cat > dockerversion/version_autogen_unix.go <