Remove unused code (via deadcode linter)
This commit is contained in:
parent
a40b67f80f
commit
82810f13cd
@ -87,7 +87,6 @@ func RootDir() string {
|
|||||||
type storageDriver string
|
type storageDriver string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
devicemapperStorageDriver storageDriver = "devicemapper"
|
|
||||||
aufsStorageDriver storageDriver = "aufs"
|
aufsStorageDriver storageDriver = "aufs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ package libcontainer
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -146,8 +145,6 @@ func isIgnoredDevice(ifName string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const netstatsLine = `%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d`
|
|
||||||
|
|
||||||
func scanInterfaceStats(netStatsFile string) ([]info.InterfaceStats, error) {
|
func scanInterfaceStats(netStatsFile string) ([]info.InterfaceStats, error) {
|
||||||
file, err := os.Open(netStatsFile)
|
file, err := os.Open(netStatsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -213,6 +210,7 @@ func setInterfaceStatValues(fields []string, pointers []*uint64) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func tcpStatsFromProc(rootFs string, pid int, file string) (info.TcpStat, error) {
|
func tcpStatsFromProc(rootFs string, pid int, file string) (info.TcpStat, error) {
|
||||||
tcpStatsFile := path.Join(rootFs, "proc", strconv.Itoa(pid), file)
|
tcpStatsFile := path.Join(rootFs, "proc", strconv.Itoa(pid), file)
|
||||||
|
|
||||||
@ -287,6 +285,7 @@ func scanTcpStats(tcpStatsFile string) (info.TcpStat, error) {
|
|||||||
|
|
||||||
return stats, nil
|
return stats, nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func GetProcesses(cgroupManager cgroups.Manager) ([]int, error) {
|
func GetProcesses(cgroupManager cgroups.Manager) ([]int, error) {
|
||||||
pids, err := cgroupManager.GetPids()
|
pids, err := cgroupManager.GetPids()
|
||||||
|
@ -476,17 +476,6 @@ func timeEq(t1, t2 time.Time, tolerance time.Duration) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func durationEq(a, b time.Duration, tolerance time.Duration) bool {
|
|
||||||
if a > b {
|
|
||||||
a, b = b, a
|
|
||||||
}
|
|
||||||
diff := a - b
|
|
||||||
if diff <= tolerance {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// 10ms, i.e. 0.01s
|
// 10ms, i.e. 0.01s
|
||||||
timePrecision time.Duration = 10 * time.Millisecond
|
timePrecision time.Duration = 10 * time.Millisecond
|
||||||
@ -522,14 +511,6 @@ func (a *ContainerStats) StatsEq(b *ContainerStats) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saturate CPU usage to 0.
|
|
||||||
func calculateCpuUsage(prev, cur uint64) uint64 {
|
|
||||||
if prev > cur {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return cur - prev
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event contains information general to events such as the time at which they
|
// Event contains information general to events such as the time at which they
|
||||||
// occurred, their specific type, and the actual event. Event types are
|
// occurred, their specific type, and the actual event. Event types are
|
||||||
// differentiated by the EventType field of Event.
|
// differentiated by the EventType field of Event.
|
||||||
|
@ -144,10 +144,6 @@ func printShares(shares *uint64) string {
|
|||||||
return fmt.Sprintf("%d", *shares)
|
return fmt.Sprintf("%d", *shares)
|
||||||
}
|
}
|
||||||
|
|
||||||
func toMegabytes(bytes uint64) float64 {
|
|
||||||
return float64(bytes) / (1 << 20)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Size after which we consider memory to be "unlimited". This is not
|
// Size after which we consider memory to be "unlimited". This is not
|
||||||
// MaxInt64 due to rounding by the kernel.
|
// MaxInt64 due to rounding by the kernel.
|
||||||
const maxMemorySize = uint64(1 << 62)
|
const maxMemorySize = uint64(1 << 62)
|
||||||
@ -166,16 +162,6 @@ func printUnit(bytes uint64) string {
|
|||||||
return ByteSize(bytes).Unit()
|
return ByteSize(bytes).Unit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func toMemoryPercent(usage uint64, spec *info.ContainerSpec, machine *info.MachineInfo) int {
|
|
||||||
// Saturate limit to the machine size.
|
|
||||||
limit := uint64(spec.Memory.Limit)
|
|
||||||
if limit > uint64(machine.MemoryCapacity) {
|
|
||||||
limit = uint64(machine.MemoryCapacity)
|
|
||||||
}
|
|
||||||
|
|
||||||
return int((usage * 100) / limit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) error {
|
func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) error {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ var (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
errAlreadyExists string = "Error 409: Already Exists"
|
errAlreadyExists string = "Error 409: Already Exists"
|
||||||
queryLimit int64 = 200
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
@ -77,17 +77,6 @@ func TimeEq(t1, t2 time.Time, tolerance time.Duration) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func durationEq(a, b time.Duration, tolerance time.Duration) bool {
|
|
||||||
if a > b {
|
|
||||||
a, b = b, a
|
|
||||||
}
|
|
||||||
diff := a - b
|
|
||||||
if diff <= tolerance {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// 10ms, i.e. 0.01s
|
// 10ms, i.e. 0.01s
|
||||||
timePrecision time.Duration = 10 * time.Millisecond
|
timePrecision time.Duration = 10 * time.Millisecond
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
// Copyright 2014 Google Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package fs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
type osFS struct{}
|
|
||||||
|
|
||||||
func (osFS) Open(name string) (File, error) { return os.Open(name) }
|
|
||||||
func (osFS) Stat(name string) (os.FileInfo, error) { return os.Stat(name) }
|
|
||||||
|
|
||||||
var fs FileSystem = osFS{}
|
|
||||||
|
|
||||||
type FileSystem interface {
|
|
||||||
Open(name string) (File, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type File interface {
|
|
||||||
io.ReadWriteCloser
|
|
||||||
}
|
|
||||||
|
|
||||||
// Useful for tests. Not thread safe.
|
|
||||||
func ChangeFileSystem(filesystem FileSystem) {
|
|
||||||
fs = filesystem
|
|
||||||
}
|
|
||||||
|
|
||||||
func Open(name string) (File, error) {
|
|
||||||
return fs.Open(name)
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
// Copyright 2014 Google Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package mockfs
|
|
||||||
|
|
||||||
import "bytes"
|
|
||||||
|
|
||||||
type FakeFile struct {
|
|
||||||
bytes.Buffer
|
|
||||||
Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *FakeFile) Close() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddTextFile(mockfs *MockFileSystem, name, content string) *FakeFile {
|
|
||||||
f := &FakeFile{
|
|
||||||
Name: name,
|
|
||||||
Buffer: *bytes.NewBufferString(content),
|
|
||||||
}
|
|
||||||
mockfs.EXPECT().Open(name).Return(f, nil).AnyTimes()
|
|
||||||
return f
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
// Copyright 2014 Google Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// Automatically generated by MockGen. DO NOT EDIT!
|
|
||||||
// Source: github.com/google/cadvisor/utils/fs (interfaces: FileSystem)
|
|
||||||
|
|
||||||
package mockfs
|
|
||||||
|
|
||||||
import (
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
fs "github.com/google/cadvisor/utils/fs"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Mock of FileSystem interface
|
|
||||||
type MockFileSystem struct {
|
|
||||||
ctrl *gomock.Controller
|
|
||||||
recorder *_MockFileSystemRecorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recorder for MockFileSystem (not exported)
|
|
||||||
type _MockFileSystemRecorder struct {
|
|
||||||
mock *MockFileSystem
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMockFileSystem(ctrl *gomock.Controller) *MockFileSystem {
|
|
||||||
mock := &MockFileSystem{ctrl: ctrl}
|
|
||||||
mock.recorder = &_MockFileSystemRecorder{mock}
|
|
||||||
return mock
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_m *MockFileSystem) EXPECT() *_MockFileSystemRecorder {
|
|
||||||
return _m.recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_m *MockFileSystem) Open(_param0 string) (fs.File, error) {
|
|
||||||
ret := _m.ctrl.Call(_m, "Open", _param0)
|
|
||||||
ret0, _ := ret[0].(fs.File)
|
|
||||||
ret1, _ := ret[1].(error)
|
|
||||||
return ret0, ret1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (_mr *_MockFileSystemRecorder) Open(arg0 interface{}) *gomock.Call {
|
|
||||||
return _mr.mock.ctrl.RecordCall(_mr.mock, "Open", arg0)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user