Merge pull request #44949 from thaJeztah/remove_system_meminfo_alias
pkg/sysinfo: move MemInfo and ReadMemInfo to a separate package
This commit is contained in:
commit
e828895f20
8 changed files with 22 additions and 19 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package sysinfo
|
||||
package meminfo
|
||||
|
||||
import (
|
||||
"bufio"
|
|
@ -1,7 +1,7 @@
|
|||
//go:build linux || freebsd
|
||||
// +build linux freebsd
|
||||
|
||||
package sysinfo
|
||||
package meminfo
|
||||
|
||||
import (
|
||||
"strings"
|
|
@ -1,7 +1,7 @@
|
|||
//go:build !linux && !windows
|
||||
// +build !linux,!windows
|
||||
|
||||
package sysinfo
|
||||
package meminfo
|
||||
|
||||
import "errors"
|
||||
|
|
@ -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{
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue