gofmt changes (new)
Formatting in 'utils/machine/machine.go' and 'utils/sysfs/sysfs.go' was incorrect and causing ./build/presubmit.sh script to fail in Travis giving below error: The following files are not properly formatted: $ ./build/presubmit.sh +./build/check_gofmt.sh . utils/machine/machine.go utils/sysfs/sysfs.go utils/machine/machine.go utils/sysfs/sysfs.go Fixed the formatting using below command: gofmt -l -w -s utils/sysfs/sysfs.go gofmt -l -w -s utils/machine/machine.go
This commit is contained in:
parent
be8de942e7
commit
305bb279d8
@ -20,11 +20,11 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
// s390/s390x changes
|
// s390/s390x changes
|
||||||
"syscall"
|
"runtime"
|
||||||
"runtime"
|
"syscall"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
info "github.com/google/cadvisor/info/v1"
|
info "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/google/cadvisor/utils"
|
"github.com/google/cadvisor/utils"
|
||||||
@ -44,10 +44,10 @@ var swapCapacityRegexp = regexp.MustCompile("SwapTotal: *([0-9]+) kB")
|
|||||||
// GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file.
|
// GetClockSpeed returns the CPU clock speed, given a []byte formatted as the /proc/cpuinfo file.
|
||||||
func GetClockSpeed(procInfo []byte) (uint64, error) {
|
func GetClockSpeed(procInfo []byte) (uint64, error) {
|
||||||
// s390/s390x changes
|
// s390/s390x changes
|
||||||
if (true == isSystemZ()) {
|
if true == isSystemZ() {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// First look through sys to find a max supported cpu frequency.
|
// First look through sys to find a max supported cpu frequency.
|
||||||
const maxFreqFile = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
|
const maxFreqFile = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
|
||||||
if utils.FileExists(maxFreqFile) {
|
if utils.FileExists(maxFreqFile) {
|
||||||
@ -128,12 +128,12 @@ func parseCapacity(b []byte, r *regexp.Regexp) (int64, error) {
|
|||||||
|
|
||||||
func GetTopology(sysFs sysfs.SysFs, cpuinfo string) ([]info.Node, int, error) {
|
func GetTopology(sysFs sysfs.SysFs, cpuinfo string) ([]info.Node, int, error) {
|
||||||
nodes := []info.Node{}
|
nodes := []info.Node{}
|
||||||
|
|
||||||
// s390/s390x changes
|
// s390/s390x changes
|
||||||
if true == isSystemZ() {
|
if true == isSystemZ() {
|
||||||
return nodes, getNumCores(), nil
|
return nodes, getNumCores(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
numCores := 0
|
numCores := 0
|
||||||
lastThread := -1
|
lastThread := -1
|
||||||
lastCore := -1
|
lastCore := -1
|
||||||
@ -259,39 +259,39 @@ func addNode(nodes *[]info.Node, id int) (int, error) {
|
|||||||
|
|
||||||
// s390/s390x changes
|
// s390/s390x changes
|
||||||
func getMachineArch() (string, error) {
|
func getMachineArch() (string, error) {
|
||||||
uname := syscall.Utsname{}
|
uname := syscall.Utsname{}
|
||||||
err := syscall.Uname(&uname)
|
err := syscall.Uname(&uname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var arch string
|
var arch string
|
||||||
for _, val := range uname.Machine {
|
for _, val := range uname.Machine {
|
||||||
arch += string(int(val))
|
arch += string(int(val))
|
||||||
}
|
}
|
||||||
|
|
||||||
return arch, nil
|
return arch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// s390/s390x changes
|
// s390/s390x changes
|
||||||
func isSystemZ() bool {
|
func isSystemZ() bool {
|
||||||
arch, err := getMachineArch()
|
arch, err := getMachineArch()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if (true == strings.Contains(arch, "390")) {
|
if true == strings.Contains(arch, "390") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// s390/s390x changes
|
// s390/s390x changes
|
||||||
func getNumCores() int {
|
func getNumCores() int {
|
||||||
maxProcs := runtime.GOMAXPROCS(0)
|
maxProcs := runtime.GOMAXPROCS(0)
|
||||||
numCPU := runtime.NumCPU()
|
numCPU := runtime.NumCPU()
|
||||||
|
|
||||||
if maxProcs < numCPU {
|
if maxProcs < numCPU {
|
||||||
return maxProcs
|
return maxProcs
|
||||||
}
|
}
|
||||||
|
|
||||||
return numCPU
|
return numCPU
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
blockDir = "/sys/block"
|
blockDir = "/sys/block"
|
||||||
cacheDir = "/sys/devices/system/cpu/cpu"
|
cacheDir = "/sys/devices/system/cpu/cpu"
|
||||||
netDir = "/sys/class/net"
|
netDir = "/sys/class/net"
|
||||||
dmiDir = "/sys/class/dmi"
|
dmiDir = "/sys/class/dmi"
|
||||||
ppcDevTree = "/proc/device-tree"
|
ppcDevTree = "/proc/device-tree"
|
||||||
s390xDevTree = "/etc" // s390/s390x changes
|
s390xDevTree = "/etc" // s390/s390x changes
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -235,15 +235,15 @@ func (self *realSysFs) GetCacheInfo(id int, name string) (CacheInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *realSysFs) GetSystemUUID() (string, error) {
|
func (self *realSysFs) GetSystemUUID() (string, error) {
|
||||||
if id, err := ioutil.ReadFile(path.Join(dmiDir, "id", "product_uuid")); err == nil {
|
if id, err := ioutil.ReadFile(path.Join(dmiDir, "id", "product_uuid")); err == nil {
|
||||||
return strings.TrimSpace(string(id)), nil
|
return strings.TrimSpace(string(id)), nil
|
||||||
} else if id, err = ioutil.ReadFile(path.Join(ppcDevTree, "system-id")); err == nil {
|
} else if id, err = ioutil.ReadFile(path.Join(ppcDevTree, "system-id")); err == nil {
|
||||||
return strings.TrimSpace(string(id)), nil
|
return strings.TrimSpace(string(id)), nil
|
||||||
} else if id, err = ioutil.ReadFile(path.Join(ppcDevTree, "vm,uuid")); err == nil {
|
} else if id, err = ioutil.ReadFile(path.Join(ppcDevTree, "vm,uuid")); err == nil {
|
||||||
return strings.TrimSpace(string(id)), nil
|
return strings.TrimSpace(string(id)), nil
|
||||||
} else if id, err = ioutil.ReadFile(path.Join(s390xDevTree, "machine-id")); err == nil {
|
} else if id, err = ioutil.ReadFile(path.Join(s390xDevTree, "machine-id")); err == nil {
|
||||||
return strings.TrimSpace(string(id)), nil
|
return strings.TrimSpace(string(id)), nil
|
||||||
} else {
|
} else {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user