diff --git a/daemon/info.go b/daemon/info.go index 00b9d9b500..26c5851a50 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -14,6 +14,7 @@ import ( "github.com/docker/docker/daemon/logger" "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/fileutils" + "github.com/docker/docker/pkg/meminfo" "github.com/docker/docker/pkg/parsers/kernel" "github.com/docker/docker/pkg/parsers/operatingsystem" "github.com/docker/docker/pkg/platform" @@ -249,11 +250,11 @@ func kernelVersion() string { return kernelVersion } -func memInfo() *sysinfo.Memory { - memInfo, err := sysinfo.ReadMemInfo() +func memInfo() *meminfo.Memory { + memInfo, err := meminfo.Read() if err != nil { logrus.Errorf("Could not read system memory info: %v", err) - memInfo = &sysinfo.Memory{} + memInfo = &meminfo.Memory{} } return memInfo } diff --git a/daemon/stats_collector.go b/daemon/stats_collector.go index 3516f44b0b..f71992e7d5 100644 --- a/daemon/stats_collector.go +++ b/daemon/stats_collector.go @@ -5,7 +5,7 @@ import ( "time" "github.com/docker/docker/daemon/stats" - "github.com/docker/docker/pkg/sysinfo" + "github.com/docker/docker/pkg/meminfo" ) // newStatsCollector returns a new statsCollector that collections @@ -15,7 +15,7 @@ import ( func (daemon *Daemon) newStatsCollector(interval time.Duration) *stats.Collector { // FIXME(vdemeester) move this elsewhere if runtime.GOOS == "linux" { - meminfo, err := sysinfo.ReadMemInfo() + meminfo, err := meminfo.Read() if err == nil && meminfo.MemTotal > 0 { daemon.machineMemory = uint64(meminfo.MemTotal) } diff --git a/pkg/sysinfo/meminfo.go b/pkg/meminfo/meminfo.go similarity index 70% rename from pkg/sysinfo/meminfo.go rename to pkg/meminfo/meminfo.go index 6b9f8e5505..4f33ad26bf 100644 --- a/pkg/sysinfo/meminfo.go +++ b/pkg/meminfo/meminfo.go @@ -1,9 +1,11 @@ -package sysinfo +// Package meminfo provides utilites to retrieve memory statistics of +// the host system. +package meminfo -// ReadMemInfo retrieves memory statistics of the host system and returns a +// Read retrieves memory statistics of the host system and returns a // Memory type. It is only supported on Linux and Windows, and returns an // error on other platforms. -func ReadMemInfo() (*Memory, error) { +func Read() (*Memory, error) { return readMemInfo() } diff --git a/pkg/sysinfo/meminfo_linux.go b/pkg/meminfo/meminfo_linux.go similarity index 98% rename from pkg/sysinfo/meminfo_linux.go rename to pkg/meminfo/meminfo_linux.go index 993be58450..0c1cd21d49 100644 --- a/pkg/sysinfo/meminfo_linux.go +++ b/pkg/meminfo/meminfo_linux.go @@ -1,4 +1,4 @@ -package sysinfo +package meminfo import ( "bufio" diff --git a/pkg/sysinfo/meminfo_unix_test.go b/pkg/meminfo/meminfo_unix_test.go similarity index 98% rename from pkg/sysinfo/meminfo_unix_test.go rename to pkg/meminfo/meminfo_unix_test.go index bfbb6cdd06..8bb9eb191b 100644 --- a/pkg/sysinfo/meminfo_unix_test.go +++ b/pkg/meminfo/meminfo_unix_test.go @@ -1,7 +1,7 @@ //go:build linux || freebsd // +build linux freebsd -package sysinfo +package meminfo import ( "strings" diff --git a/pkg/sysinfo/meminfo_unsupported.go b/pkg/meminfo/meminfo_unsupported.go similarity index 94% rename from pkg/sysinfo/meminfo_unsupported.go rename to pkg/meminfo/meminfo_unsupported.go index 42472dda71..ebfadd5343 100644 --- a/pkg/sysinfo/meminfo_unsupported.go +++ b/pkg/meminfo/meminfo_unsupported.go @@ -1,7 +1,7 @@ //go:build !linux && !windows // +build !linux,!windows -package sysinfo +package meminfo import "errors" diff --git a/pkg/sysinfo/meminfo_windows.go b/pkg/meminfo/meminfo_windows.go similarity index 93% rename from pkg/sysinfo/meminfo_windows.go rename to pkg/meminfo/meminfo_windows.go index 553c1f3f4c..aa7d9375be 100644 --- a/pkg/sysinfo/meminfo_windows.go +++ b/pkg/meminfo/meminfo_windows.go @@ -1,4 +1,4 @@ -package sysinfo +package meminfo import ( "unsafe" @@ -26,7 +26,7 @@ type memorystatusex struct { ullAvailExtendedVirtual uint64 } -// ReadMemInfo retrieves memory statistics of the host system and returns a +// readMemInfo retrieves memory statistics of the host system and returns a // Memory type. func readMemInfo() (*Memory, error) { msi := &memorystatusex{ diff --git a/pkg/system/meminfo_deprecated.go b/pkg/system/meminfo_deprecated.go index 00e40352a9..216519923e 100644 --- a/pkg/system/meminfo_deprecated.go +++ b/pkg/system/meminfo_deprecated.go @@ -1,16 +1,16 @@ package system -import "github.com/docker/docker/pkg/sysinfo" +import "github.com/docker/docker/pkg/meminfo" // MemInfo contains memory statistics of the host system. // -// Deprecated: use [sysinfo.Memory]. -type MemInfo = sysinfo.Memory +// Deprecated: use [meminfo.Memory]. +type MemInfo = meminfo.Memory // ReadMemInfo retrieves memory statistics of the host system and returns a // MemInfo type. // -// Deprecated: use [sysinfo.ReadMemInfo]. -func ReadMemInfo() (*sysinfo.Memory, error) { - return sysinfo.ReadMemInfo() +// Deprecated: use [meminfo.Read]. +func ReadMemInfo() (*meminfo.Memory, error) { + return meminfo.Read() }