Fix/Add comments on cadvisor implementations
Fix lint issues. Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
parent
ee84c95bdb
commit
a626a2972e
@ -148,8 +148,6 @@ pkg/kubelet
|
|||||||
pkg/kubelet/apis/config
|
pkg/kubelet/apis/config
|
||||||
pkg/kubelet/apis/config/v1beta1
|
pkg/kubelet/apis/config/v1beta1
|
||||||
pkg/kubelet/apis/deviceplugin/v1beta1
|
pkg/kubelet/apis/deviceplugin/v1beta1
|
||||||
pkg/kubelet/cadvisor
|
|
||||||
pkg/kubelet/cadvisor/testing
|
|
||||||
pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1
|
pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1
|
||||||
pkg/kubelet/client
|
pkg/kubelet/client
|
||||||
pkg/kubelet/cm
|
pkg/kubelet/cm
|
||||||
|
@ -82,6 +82,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// New creates a new cAdvisor Interface for linux systems.
|
||||||
func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupRoots []string, usingLegacyStats bool) (Interface, error) {
|
func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupRoots []string, usingLegacyStats bool) (Interface, error) {
|
||||||
sysFs := sysfs.NewRealSysFs()
|
sysFs := sysfs.NewRealSysFs()
|
||||||
|
|
||||||
@ -98,7 +99,7 @@ func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupRoots [
|
|||||||
includedMetrics[cadvisormetrics.DiskUsageMetrics] = struct{}{}
|
includedMetrics[cadvisormetrics.DiskUsageMetrics] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and start the cAdvisor container manager.
|
// Create the cAdvisor container manager.
|
||||||
m, err := manager.New(memory.New(statsCacheDuration, nil), sysFs, maxHousekeepingInterval, allowDynamicHousekeeping, includedMetrics, http.DefaultClient, cgroupRoots)
|
m, err := manager.New(memory.New(statsCacheDuration, nil), sysFs, maxHousekeepingInterval, allowDynamicHousekeeping, includedMetrics, http.DefaultClient, cgroupRoots)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -114,13 +115,11 @@ func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupRoots [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cadvisorClient := &cadvisorClient{
|
return &cadvisorClient{
|
||||||
imageFsInfoProvider: imageFsInfoProvider,
|
imageFsInfoProvider: imageFsInfoProvider,
|
||||||
rootPath: rootPath,
|
rootPath: rootPath,
|
||||||
Manager: m,
|
Manager: m,
|
||||||
}
|
}, nil
|
||||||
|
|
||||||
return cadvisorClient, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) Start() error {
|
func (cc *cadvisorClient) Start() error {
|
||||||
|
@ -31,50 +31,51 @@ type cadvisorUnsupported struct {
|
|||||||
|
|
||||||
var _ Interface = new(cadvisorUnsupported)
|
var _ Interface = new(cadvisorUnsupported)
|
||||||
|
|
||||||
|
// New creates a new cAdvisor Interface for unsupported systems.
|
||||||
func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupsRoots []string, usingLegacyStats bool) (Interface, error) {
|
func New(imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupsRoots []string, usingLegacyStats bool) (Interface, error) {
|
||||||
return &cadvisorUnsupported{}, nil
|
return &cadvisorUnsupported{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var unsupportedErr = errors.New("cAdvisor is unsupported in this build")
|
var errUnsupported = errors.New("cAdvisor is unsupported in this build")
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) Start() error {
|
func (cu *cadvisorUnsupported) Start() error {
|
||||||
return unsupportedErr
|
return errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
|
func (cu *cadvisorUnsupported) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
|
||||||
return cadvisorapi.ContainerInfo{}, unsupportedErr
|
return cadvisorapi.ContainerInfo{}, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
func (cu *cadvisorUnsupported) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
func (cu *cadvisorUnsupported) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
func (cu *cadvisorUnsupported) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
func (cu *cadvisorUnsupported) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
func (cu *cadvisorUnsupported) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (cu *cadvisorUnsupported) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorapiv2.FsInfo{}, unsupportedErr
|
return cadvisorapiv2.FsInfo{}, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (cu *cadvisorUnsupported) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorapiv2.FsInfo{}, unsupportedErr
|
return cadvisorapiv2.FsInfo{}, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (cu *cadvisorUnsupported) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
return nil, unsupportedErr
|
return nil, errUnsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
func (cu *cadvisorUnsupported) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
||||||
|
@ -53,6 +53,7 @@ func (cu *cadvisorClient) ContainerInfo(name string, req *cadvisorapi.ContainerI
|
|||||||
return &cadvisorapi.ContainerInfo{}, nil
|
return &cadvisorapi.ContainerInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerInfoV2 is only expected to be used for the root container. Returns info for all containers in the node.
|
||||||
func (cu *cadvisorClient) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
func (cu *cadvisorClient) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
||||||
return cu.winStatsClient.WinContainerInfos()
|
return cu.winStatsClient.WinContainerInfos()
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Kubelet interactions with cAdvisor.
|
// Package cadvisor provides an interface for Kubelet interactions with cAdvisor.
|
||||||
package cadvisor // import "k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
package cadvisor // import "k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||||
|
@ -23,71 +23,85 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fake cAdvisor implementation.
|
// Fake cadvisor.Interface implementation.
|
||||||
type Fake struct {
|
type Fake struct {
|
||||||
NodeName string
|
NodeName string
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FakeNumCores = 1
|
// FakeKernelVersion is a fake kernel version for testing.
|
||||||
FakeMemoryCapacity = 4026531840
|
FakeKernelVersion = "3.16.0-0.bpo.4-amd64"
|
||||||
FakeKernelVersion = "3.16.0-0.bpo.4-amd64"
|
// FakeContainerOSVersion is a fake OS version for testing.
|
||||||
FakeContainerOsVersion = "Debian GNU/Linux 7 (wheezy)"
|
FakeContainerOSVersion = "Debian GNU/Linux 7 (wheezy)"
|
||||||
FakeDockerVersion = "1.13.1"
|
|
||||||
|
fakeNumCores = 1
|
||||||
|
fakeMemoryCapacity = 4026531840
|
||||||
|
fakeDockerVersion = "1.13.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ cadvisor.Interface = new(Fake)
|
var _ cadvisor.Interface = new(Fake)
|
||||||
|
|
||||||
|
// Start is a fake implementation of Interface.Start.
|
||||||
func (c *Fake) Start() error {
|
func (c *Fake) Start() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerInfo is a fake implementation of Interface.ContainerInfo.
|
||||||
func (c *Fake) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
func (c *Fake) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return new(cadvisorapi.ContainerInfo), nil
|
return new(cadvisorapi.ContainerInfo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerInfoV2 is a fake implementation of Interface.ContainerInfoV2.
|
||||||
func (c *Fake) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
func (c *Fake) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error) {
|
||||||
return map[string]cadvisorapiv2.ContainerInfo{}, nil
|
return map[string]cadvisorapiv2.ContainerInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SubcontainerInfo is a fake implementation of Interface.SubcontainerInfo.
|
||||||
func (c *Fake) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
func (c *Fake) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
return map[string]*cadvisorapi.ContainerInfo{}, nil
|
return map[string]*cadvisorapi.ContainerInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DockerContainer is a fake implementation of Interface.DockerContainer.
|
||||||
func (c *Fake) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
|
func (c *Fake) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
|
||||||
return cadvisorapi.ContainerInfo{}, nil
|
return cadvisorapi.ContainerInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MachineInfo is a fake implementation of Interface.MachineInfo.
|
||||||
func (c *Fake) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
func (c *Fake) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
// Simulate a machine with 1 core and 3.75GB of memory.
|
// Simulate a machine with 1 core and 3.75GB of memory.
|
||||||
// We set it to non-zero values to make non-zero-capacity machines in Kubemark.
|
// We set it to non-zero values to make non-zero-capacity machines in Kubemark.
|
||||||
return &cadvisorapi.MachineInfo{
|
return &cadvisorapi.MachineInfo{
|
||||||
NumCores: FakeNumCores,
|
NumCores: fakeNumCores,
|
||||||
InstanceID: cadvisorapi.InstanceID(c.NodeName),
|
InstanceID: cadvisorapi.InstanceID(c.NodeName),
|
||||||
MemoryCapacity: FakeMemoryCapacity,
|
MemoryCapacity: fakeMemoryCapacity,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VersionInfo is a fake implementation of Interface.VersionInfo.
|
||||||
func (c *Fake) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
func (c *Fake) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
||||||
return &cadvisorapi.VersionInfo{
|
return &cadvisorapi.VersionInfo{
|
||||||
KernelVersion: FakeKernelVersion,
|
KernelVersion: FakeKernelVersion,
|
||||||
ContainerOsVersion: FakeContainerOsVersion,
|
ContainerOsVersion: FakeContainerOSVersion,
|
||||||
DockerVersion: FakeDockerVersion,
|
DockerVersion: fakeDockerVersion,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImagesFsInfo is a fake implementation of Interface.ImagesFsInfo.
|
||||||
func (c *Fake) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (c *Fake) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorapiv2.FsInfo{}, nil
|
return cadvisorapiv2.FsInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RootFsInfo is a fake implementation of Interface.RootFsInfo.
|
||||||
func (c *Fake) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (c *Fake) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorapiv2.FsInfo{}, nil
|
return cadvisorapiv2.FsInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WatchEvents is a fake implementation of Interface.WatchEvents.
|
||||||
func (c *Fake) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (c *Fake) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
return new(events.EventChannel), nil
|
return new(events.EventChannel), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDirFsInfo is a fake implementation of Interface.GetDirFsInfo.
|
||||||
func (c *Fake) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
func (c *Fake) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorapiv2.FsInfo{}, nil
|
return cadvisorapiv2.FsInfo{}, nil
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,14 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Mock cadvisor.Interface implementation.
|
||||||
type Mock struct {
|
type Mock struct {
|
||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ cadvisor.Interface = new(Mock)
|
var _ cadvisor.Interface = new(Mock)
|
||||||
|
|
||||||
|
// Start is a mock implementation of Interface.Start.
|
||||||
func (c *Mock) Start() error {
|
func (c *Mock) Start() error {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Error(0)
|
return args.Error(0)
|
||||||
@ -47,6 +49,7 @@ func (c *Mock) ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions
|
|||||||
return args.Get(0).(map[string]cadvisorapiv2.ContainerInfo), args.Error(1)
|
return args.Get(0).(map[string]cadvisorapiv2.ContainerInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SubcontainerInfo is a mock implementation of Interface.SubcontainerInfo.
|
||||||
func (c *Mock) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
func (c *Mock) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
args := c.Called(name, req)
|
args := c.Called(name, req)
|
||||||
return args.Get(0).(map[string]*cadvisorapi.ContainerInfo), args.Error(1)
|
return args.Get(0).(map[string]*cadvisorapi.ContainerInfo), args.Error(1)
|
||||||
@ -64,26 +67,31 @@ func (c *Mock) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
|||||||
return args.Get(0).(*cadvisorapi.MachineInfo), args.Error(1)
|
return args.Get(0).(*cadvisorapi.MachineInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VersionInfo is a mock implementation of Interface.VersionInfo.
|
||||||
func (c *Mock) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
func (c *Mock) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Get(0).(*cadvisorapi.VersionInfo), args.Error(1)
|
return args.Get(0).(*cadvisorapi.VersionInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImagesFsInfo is a mock implementation of Interface.ImagesFsInfo.
|
||||||
func (c *Mock) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (c *Mock) ImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Get(0).(cadvisorapiv2.FsInfo), args.Error(1)
|
return args.Get(0).(cadvisorapiv2.FsInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RootFsInfo is a mock implementation of Interface.RootFsInfo.
|
||||||
func (c *Mock) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
func (c *Mock) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Get(0).(cadvisorapiv2.FsInfo), args.Error(1)
|
return args.Get(0).(cadvisorapiv2.FsInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WatchEvents is a mock implementation of Interface.WatchEvents.
|
||||||
func (c *Mock) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (c *Mock) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Get(0).(*events.EventChannel), args.Error(1)
|
return args.Get(0).(*events.EventChannel), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDirFsInfo is a mock implementation of Interface.GetDirFsInfo.
|
||||||
func (c *Mock) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
func (c *Mock) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
|
||||||
args := c.Called(path)
|
args := c.Called(path)
|
||||||
return args.Get(0).(cadvisorapiv2.FsInfo), args.Error(1)
|
return args.Get(0).(cadvisorapiv2.FsInfo), args.Error(1)
|
||||||
|
@ -28,11 +28,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// CrioSocket is the path to the CRI-O socket.
|
||||||
// Please keep this in sync with the one in:
|
// Please keep this in sync with the one in:
|
||||||
// github.com/google/cadvisor/container/crio/client.go
|
// github.com/google/cadvisor/container/crio/client.go
|
||||||
CrioSocket = "/var/run/crio/crio.sock"
|
CrioSocket = "/var/run/crio/crio.sock"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CapacityFromMachineInfo returns the capacity of the resources from the machine info.
|
||||||
func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) v1.ResourceList {
|
func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) v1.ResourceList {
|
||||||
c := v1.ResourceList{
|
c := v1.ResourceList{
|
||||||
v1.ResourceCPU: *resource.NewMilliQuantity(
|
v1.ResourceCPU: *resource.NewMilliQuantity(
|
||||||
@ -54,6 +56,7 @@ func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) v1.ResourceList {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EphemeralStorageCapacityFromFsInfo returns the capacity of the ephemeral storage from the FsInfo.
|
||||||
func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceList {
|
func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceList {
|
||||||
c := v1.ResourceList{
|
c := v1.ResourceList{
|
||||||
v1.ResourceEphemeralStorage: *resource.NewQuantity(
|
v1.ResourceEphemeralStorage: *resource.NewQuantity(
|
||||||
@ -63,13 +66,13 @@ func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceLis
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UsingLegacyCadvisorStats returns true if container stats are provided by cadvisor instead of through the CRI.
|
||||||
// CRI integrations should get container metrics via CRI. Docker
|
// CRI integrations should get container metrics via CRI. Docker
|
||||||
// uses the built-in cadvisor to gather such metrics on Linux for
|
// uses the built-in cadvisor to gather such metrics on Linux for
|
||||||
// historical reasons.
|
// historical reasons.
|
||||||
// cri-o relies on cadvisor as a temporary workaround. The code should
|
// cri-o relies on cadvisor as a temporary workaround. The code should
|
||||||
// be removed. Related issue:
|
// be removed. Related issue:
|
||||||
// https://github.com/kubernetes/kubernetes/issues/51798
|
// https://github.com/kubernetes/kubernetes/issues/51798
|
||||||
// UsingLegacyCadvisorStats returns true if container stats are provided by cadvisor instead of through the CRI
|
|
||||||
func UsingLegacyCadvisorStats(runtime, runtimeEndpoint string) bool {
|
func UsingLegacyCadvisorStats(runtime, runtimeEndpoint string) bool {
|
||||||
return (runtime == kubetypes.DockerContainerRuntime && goruntime.GOOS == "linux") ||
|
return (runtime == kubetypes.DockerContainerRuntime && goruntime.GOOS == "linux") ||
|
||||||
runtimeEndpoint == CrioSocket || runtimeEndpoint == "unix://"+CrioSocket
|
runtimeEndpoint == CrioSocket || runtimeEndpoint == "unix://"+CrioSocket
|
||||||
|
@ -271,7 +271,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
|||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
KernelVersion: cadvisortest.FakeKernelVersion,
|
KernelVersion: cadvisortest.FakeKernelVersion,
|
||||||
OSImage: cadvisortest.FakeContainerOsVersion,
|
OSImage: cadvisortest.FakeContainerOSVersion,
|
||||||
OperatingSystem: goruntime.GOOS,
|
OperatingSystem: goruntime.GOOS,
|
||||||
Architecture: goruntime.GOARCH,
|
Architecture: goruntime.GOARCH,
|
||||||
ContainerRuntimeVersion: "test://1.5.0",
|
ContainerRuntimeVersion: "test://1.5.0",
|
||||||
@ -449,7 +449,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
|
|||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
KernelVersion: cadvisortest.FakeKernelVersion,
|
KernelVersion: cadvisortest.FakeKernelVersion,
|
||||||
OSImage: cadvisortest.FakeContainerOsVersion,
|
OSImage: cadvisortest.FakeContainerOSVersion,
|
||||||
OperatingSystem: goruntime.GOOS,
|
OperatingSystem: goruntime.GOOS,
|
||||||
Architecture: goruntime.GOARCH,
|
Architecture: goruntime.GOARCH,
|
||||||
ContainerRuntimeVersion: "test://1.5.0",
|
ContainerRuntimeVersion: "test://1.5.0",
|
||||||
@ -647,7 +647,7 @@ func TestUpdateNodeStatusWithRuntimeStateError(t *testing.T) {
|
|||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
KernelVersion: cadvisortest.FakeKernelVersion,
|
KernelVersion: cadvisortest.FakeKernelVersion,
|
||||||
OSImage: cadvisortest.FakeContainerOsVersion,
|
OSImage: cadvisortest.FakeContainerOSVersion,
|
||||||
OperatingSystem: goruntime.GOOS,
|
OperatingSystem: goruntime.GOOS,
|
||||||
Architecture: goruntime.GOARCH,
|
Architecture: goruntime.GOARCH,
|
||||||
ContainerRuntimeVersion: "test://1.5.0",
|
ContainerRuntimeVersion: "test://1.5.0",
|
||||||
@ -877,7 +877,7 @@ func TestUpdateNodeStatusWithLease(t *testing.T) {
|
|||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
KernelVersion: cadvisortest.FakeKernelVersion,
|
KernelVersion: cadvisortest.FakeKernelVersion,
|
||||||
OSImage: cadvisortest.FakeContainerOsVersion,
|
OSImage: cadvisortest.FakeContainerOSVersion,
|
||||||
OperatingSystem: goruntime.GOOS,
|
OperatingSystem: goruntime.GOOS,
|
||||||
Architecture: goruntime.GOARCH,
|
Architecture: goruntime.GOARCH,
|
||||||
ContainerRuntimeVersion: "test://1.5.0",
|
ContainerRuntimeVersion: "test://1.5.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user