2d49080056
Commit 6a516acb2e
moved the MemInfo type and
ReadMemInfo() function into the pkg/sysinfo package. In an attempt to assist
consumers of these to migrate to the new location, an alias was added.
Unfortunately, the side effect of this alias is that pkg/system now depends
on pkg/sysinfo, which means that consumers of this (such as docker/cli) now
get all (indirect) dependencies of that package as dependency, which includes
many dependencies that should only be needed for the daemon / runtime;
- github.com/cilium/ebpf
- github.com/containerd/cgroups
- github.com/coreos/go-systemd/v22
- github.com/godbus/dbus/v5
- github.com/moby/sys/mountinfo
- github.com/opencontainers/runtime-spec
This patch moves the MemInfo related code to its own package. As the previous move
was not yet part of a release, we're not adding new aliases in pkg/sysinfo.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
26 lines
775 B
Go
26 lines
775 B
Go
package daemon // import "github.com/docker/docker/daemon"
|
|
|
|
import (
|
|
"runtime"
|
|
"time"
|
|
|
|
"github.com/docker/docker/daemon/stats"
|
|
"github.com/docker/docker/pkg/meminfo"
|
|
)
|
|
|
|
// newStatsCollector returns a new statsCollector that collections
|
|
// stats for a registered container at the specified interval.
|
|
// The collector allows non-running containers to be added
|
|
// and will start processing stats when they are started.
|
|
func (daemon *Daemon) newStatsCollector(interval time.Duration) *stats.Collector {
|
|
// FIXME(vdemeester) move this elsewhere
|
|
if runtime.GOOS == "linux" {
|
|
meminfo, err := meminfo.Read()
|
|
if err == nil && meminfo.MemTotal > 0 {
|
|
daemon.machineMemory = uint64(meminfo.MemTotal)
|
|
}
|
|
}
|
|
s := stats.NewCollector(daemon, interval)
|
|
go s.Run()
|
|
return s
|
|
}
|