mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #15755 from zhengguoyong/del_capatical_packagename_for_cadvisorApi2
Auto commit by PR queue bot
This commit is contained in:
commit
09a3871506
@ -19,7 +19,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MesosCadvisor struct {
|
type MesosCadvisor struct {
|
||||||
@ -36,7 +36,7 @@ func NewMesosCadvisor(cores int, mem int64, port uint) (*MesosCadvisor, error) {
|
|||||||
return &MesosCadvisor{c, cores, mem}, nil
|
return &MesosCadvisor{c, cores, mem}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MesosCadvisor) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (mc *MesosCadvisor) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
mi, err := mc.Interface.MachineInfo()
|
mi, err := mc.Interface.MachineInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -25,16 +25,16 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContainerInfoGetter interface {
|
type ContainerInfoGetter interface {
|
||||||
// GetContainerInfo returns information about a container.
|
// GetContainerInfo returns information about a container.
|
||||||
GetContainerInfo(host, podID, containerID string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
GetContainerInfo(host, podID, containerID string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
|
||||||
// GetRootInfo returns information about the root container on a machine.
|
// GetRootInfo returns information about the root container on a machine.
|
||||||
GetRootInfo(host string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
GetRootInfo(host string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
|
||||||
// GetMachineInfo returns the machine's information like number of cores, memory capacity.
|
// GetMachineInfo returns the machine's information like number of cores, memory capacity.
|
||||||
GetMachineInfo(host string) (*cadvisorApi.MachineInfo, error)
|
GetMachineInfo(host string) (*cadvisorapi.MachineInfo, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPContainerInfoGetter struct {
|
type HTTPContainerInfoGetter struct {
|
||||||
@ -42,7 +42,7 @@ type HTTPContainerInfoGetter struct {
|
|||||||
Port int
|
Port int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*cadvisorApi.MachineInfo, error) {
|
func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*cadvisorapi.MachineInfo, error) {
|
||||||
request, err := http.NewRequest(
|
request, err := http.NewRequest(
|
||||||
"GET",
|
"GET",
|
||||||
fmt.Sprintf("http://%v/spec",
|
fmt.Sprintf("http://%v/spec",
|
||||||
@ -63,7 +63,7 @@ func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*cadvisorApi.M
|
|||||||
return nil, fmt.Errorf("trying to get machine spec from %v; received status %v",
|
return nil, fmt.Errorf("trying to get machine spec from %v; received status %v",
|
||||||
host, response.Status)
|
host, response.Status)
|
||||||
}
|
}
|
||||||
var minfo cadvisorApi.MachineInfo
|
var minfo cadvisorapi.MachineInfo
|
||||||
err = json.NewDecoder(response.Body).Decode(&minfo)
|
err = json.NewDecoder(response.Body).Decode(&minfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -71,7 +71,7 @@ func (self *HTTPContainerInfoGetter) GetMachineInfo(host string) (*cadvisorApi.M
|
|||||||
return &minfo, nil
|
return &minfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *HTTPContainerInfoGetter) getContainerInfo(host, path string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (self *HTTPContainerInfoGetter) getContainerInfo(host, path string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
var body io.Reader
|
var body io.Reader
|
||||||
if req != nil {
|
if req != nil {
|
||||||
content, err := json.Marshal(req)
|
content, err := json.Marshal(req)
|
||||||
@ -102,7 +102,7 @@ func (self *HTTPContainerInfoGetter) getContainerInfo(host, path string, req *ca
|
|||||||
return nil, fmt.Errorf("trying to get info for %v from %v; received status %v",
|
return nil, fmt.Errorf("trying to get info for %v from %v; received status %v",
|
||||||
path, host, response.Status)
|
path, host, response.Status)
|
||||||
}
|
}
|
||||||
var cinfo cadvisorApi.ContainerInfo
|
var cinfo cadvisorapi.ContainerInfo
|
||||||
err = json.NewDecoder(response.Body).Decode(&cinfo)
|
err = json.NewDecoder(response.Body).Decode(&cinfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -110,7 +110,7 @@ func (self *HTTPContainerInfoGetter) getContainerInfo(host, path string, req *ca
|
|||||||
return &cinfo, nil
|
return &cinfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return self.getContainerInfo(
|
return self.getContainerInfo(
|
||||||
host,
|
host,
|
||||||
fmt.Sprintf("%v/%v", podID, containerID),
|
fmt.Sprintf("%v/%v", podID, containerID),
|
||||||
@ -118,6 +118,6 @@ func (self *HTTPContainerInfoGetter) GetContainerInfo(host, podID, containerID s
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *HTTPContainerInfoGetter) GetRootInfo(host string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (self *HTTPContainerInfoGetter) GetRootInfo(host string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return self.getContainerInfo(host, "", req)
|
return self.getContainerInfo(host, "", req)
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiTest "github.com/google/cadvisor/info/v1/test"
|
cadvisorapitest "github.com/google/cadvisor/info/v1/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testHTTPContainerInfoGetter(
|
func testHTTPContainerInfoGetter(
|
||||||
req *cadvisorApi.ContainerInfoRequest,
|
req *cadvisorapi.ContainerInfoRequest,
|
||||||
cinfo *cadvisorApi.ContainerInfo,
|
cinfo *cadvisorapi.ContainerInfo,
|
||||||
podID string,
|
podID string,
|
||||||
containerID string,
|
containerID string,
|
||||||
status int,
|
status int,
|
||||||
@ -53,7 +53,7 @@ func testHTTPContainerInfoGetter(
|
|||||||
expectedPath, r.URL.Path)
|
expectedPath, r.URL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
var receivedReq cadvisorApi.ContainerInfoRequest
|
var receivedReq cadvisorapi.ContainerInfoRequest
|
||||||
err := json.NewDecoder(r.Body).Decode(&receivedReq)
|
err := json.NewDecoder(r.Body).Decode(&receivedReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -87,7 +87,7 @@ func testHTTPContainerInfoGetter(
|
|||||||
Port: port,
|
Port: port,
|
||||||
}
|
}
|
||||||
|
|
||||||
var receivedContainerInfo *cadvisorApi.ContainerInfo
|
var receivedContainerInfo *cadvisorapi.ContainerInfo
|
||||||
if len(podID) > 0 && len(containerID) > 0 {
|
if len(podID) > 0 && len(containerID) > 0 {
|
||||||
receivedContainerInfo, err = containerInfoGetter.GetContainerInfo(parts[0], podID, containerID, req)
|
receivedContainerInfo, err = containerInfoGetter.GetContainerInfo(parts[0], podID, containerID, req)
|
||||||
} else {
|
} else {
|
||||||
@ -109,10 +109,10 @@ func testHTTPContainerInfoGetter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) {
|
func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) {
|
||||||
req := &cadvisorApi.ContainerInfoRequest{
|
req := &cadvisorapi.ContainerInfoRequest{
|
||||||
NumStats: 10,
|
NumStats: 10,
|
||||||
}
|
}
|
||||||
cinfo := cadvisorApiTest.GenerateRandomContainerInfo(
|
cinfo := cadvisorapitest.GenerateRandomContainerInfo(
|
||||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||||
2, // Number of cores
|
2, // Number of cores
|
||||||
req,
|
req,
|
||||||
@ -122,10 +122,10 @@ func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPContainerInfoGetterGetRootInfoSuccessfully(t *testing.T) {
|
func TestHTTPContainerInfoGetterGetRootInfoSuccessfully(t *testing.T) {
|
||||||
req := &cadvisorApi.ContainerInfoRequest{
|
req := &cadvisorapi.ContainerInfoRequest{
|
||||||
NumStats: 10,
|
NumStats: 10,
|
||||||
}
|
}
|
||||||
cinfo := cadvisorApiTest.GenerateRandomContainerInfo(
|
cinfo := cadvisorapitest.GenerateRandomContainerInfo(
|
||||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||||
2, // Number of cores
|
2, // Number of cores
|
||||||
req,
|
req,
|
||||||
@ -135,10 +135,10 @@ func TestHTTPContainerInfoGetterGetRootInfoSuccessfully(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPContainerInfoGetterGetContainerInfoWithError(t *testing.T) {
|
func TestHTTPContainerInfoGetterGetContainerInfoWithError(t *testing.T) {
|
||||||
req := &cadvisorApi.ContainerInfoRequest{
|
req := &cadvisorapi.ContainerInfoRequest{
|
||||||
NumStats: 10,
|
NumStats: 10,
|
||||||
}
|
}
|
||||||
cinfo := cadvisorApiTest.GenerateRandomContainerInfo(
|
cinfo := cadvisorapitest.GenerateRandomContainerInfo(
|
||||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||||
2, // Number of cores
|
2, // Number of cores
|
||||||
req,
|
req,
|
||||||
@ -148,10 +148,10 @@ func TestHTTPContainerInfoGetterGetContainerInfoWithError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPContainerInfoGetterGetRootInfoWithError(t *testing.T) {
|
func TestHTTPContainerInfoGetterGetRootInfoWithError(t *testing.T) {
|
||||||
req := &cadvisorApi.ContainerInfoRequest{
|
req := &cadvisorapi.ContainerInfoRequest{
|
||||||
NumStats: 10,
|
NumStats: 10,
|
||||||
}
|
}
|
||||||
cinfo := cadvisorApiTest.GenerateRandomContainerInfo(
|
cinfo := cadvisorapitest.GenerateRandomContainerInfo(
|
||||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||||
2, // Number of cores
|
2, // Number of cores
|
||||||
req,
|
req,
|
||||||
@ -161,7 +161,7 @@ func TestHTTPContainerInfoGetterGetRootInfoWithError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPGetMachineInfo(t *testing.T) {
|
func TestHTTPGetMachineInfo(t *testing.T) {
|
||||||
mspec := &cadvisorApi.MachineInfo{
|
mspec := &cadvisorapi.MachineInfo{
|
||||||
NumCores: 4,
|
NumCores: 4,
|
||||||
MemoryCapacity: 2048,
|
MemoryCapacity: 2048,
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ package cadvisor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiV2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fake cAdvisor implementation.
|
// Fake cAdvisor implementation.
|
||||||
@ -32,32 +32,32 @@ func (c *Fake) Start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Fake) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (c *Fake) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
return new(cadvisorApi.MachineInfo), nil
|
return new(cadvisorapi.MachineInfo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Fake) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
func (c *Fake) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
||||||
return new(cadvisorApi.VersionInfo), nil
|
return new(cadvisorapi.VersionInfo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Fake) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (c *Fake) DockerImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorApiV2.FsInfo{}, nil
|
return cadvisorapiv2.FsInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Fake) RootFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (c *Fake) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorApiV2.FsInfo{}, nil
|
return cadvisorapiv2.FsInfo{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Fake) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (c *Fake) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
|
@ -28,8 +28,8 @@ import (
|
|||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
cadvisorFs "github.com/google/cadvisor/fs"
|
cadvisorFs "github.com/google/cadvisor/fs"
|
||||||
cadvisorHttp "github.com/google/cadvisor/http"
|
cadvisorHttp "github.com/google/cadvisor/http"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiV2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
"github.com/google/cadvisor/utils/sysfs"
|
"github.com/google/cadvisor/utils/sysfs"
|
||||||
"k8s.io/kubernetes/pkg/util"
|
"k8s.io/kubernetes/pkg/util"
|
||||||
@ -109,46 +109,46 @@ func (cc *cadvisorClient) exportHTTP(port uint) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (cc *cadvisorClient) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return cc.GetContainerInfo(name, req)
|
return cc.GetContainerInfo(name, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
func (cc *cadvisorClient) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
||||||
return cc.GetVersionInfo()
|
return cc.GetVersionInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) SubcontainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (map[string]*cadvisorApi.ContainerInfo, error) {
|
func (cc *cadvisorClient) SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
infos, err := cc.SubcontainersInfo(name, req)
|
infos, err := cc.SubcontainersInfo(name, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := make(map[string]*cadvisorApi.ContainerInfo, len(infos))
|
result := make(map[string]*cadvisorapi.ContainerInfo, len(infos))
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
result[info.Name] = info
|
result[info.Name] = info
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (cc *cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
return cc.GetMachineInfo()
|
return cc.GetMachineInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (cc *cadvisorClient) DockerImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cc.getFsInfo(cadvisorFs.LabelDockerImages)
|
return cc.getFsInfo(cadvisorFs.LabelDockerImages)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) RootFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (cc *cadvisorClient) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cc.getFsInfo(cadvisorFs.LabelSystemRoot)
|
return cc.getFsInfo(cadvisorFs.LabelSystemRoot)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *cadvisorClient) getFsInfo(label string) (cadvisorApiV2.FsInfo, error) {
|
func (cc *cadvisorClient) getFsInfo(label string) (cadvisorapiv2.FsInfo, error) {
|
||||||
res, err := cc.GetFsInfo(label)
|
res, err := cc.GetFsInfo(label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cadvisorApiV2.FsInfo{}, err
|
return cadvisorapiv2.FsInfo{}, err
|
||||||
}
|
}
|
||||||
if len(res) == 0 {
|
if len(res) == 0 {
|
||||||
return cadvisorApiV2.FsInfo{}, fmt.Errorf("failed to find information for the filesystem labeled %q", label)
|
return cadvisorapiv2.FsInfo{}, fmt.Errorf("failed to find information for the filesystem labeled %q", label)
|
||||||
}
|
}
|
||||||
// TODO(vmarmol): Handle this better when a label has more than one image filesystem.
|
// TODO(vmarmol): Handle this better when a label has more than one image filesystem.
|
||||||
if len(res) > 1 {
|
if len(res) > 1 {
|
||||||
|
@ -18,8 +18,8 @@ package cadvisor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiV2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,41 +35,41 @@ func (c *Mock) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ContainerInfo is a mock implementation of Interface.ContainerInfo.
|
// ContainerInfo is a mock implementation of Interface.ContainerInfo.
|
||||||
func (c *Mock) ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (c *Mock) ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
args := c.Called(name, req)
|
args := c.Called(name, req)
|
||||||
return args.Get(0).(*cadvisorApi.ContainerInfo), args.Error(1)
|
return args.Get(0).(*cadvisorapi.ContainerInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerContainer is a mock implementation of Interface.DockerContainer.
|
// DockerContainer is a mock implementation of Interface.DockerContainer.
|
||||||
func (c *Mock) DockerContainer(name string, req *cadvisorApi.ContainerInfoRequest) (cadvisorApi.ContainerInfo, error) {
|
func (c *Mock) DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error) {
|
||||||
args := c.Called(name, req)
|
args := c.Called(name, req)
|
||||||
return args.Get(0).(cadvisorApi.ContainerInfo), args.Error(1)
|
return args.Get(0).(cadvisorapi.ContainerInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MachineInfo is a mock implementation of Interface.MachineInfo.
|
// MachineInfo is a mock implementation of Interface.MachineInfo.
|
||||||
func (c *Mock) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (c *Mock) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Get(0).(*cadvisorApi.MachineInfo), args.Error(1)
|
return args.Get(0).(*cadvisorapi.MachineInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Mock) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (c *Mock) DockerImagesFsInfo() (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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Mock) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (c *Mock) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiV2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cadvisorUnsupported struct {
|
type cadvisorUnsupported struct {
|
||||||
@ -41,32 +41,32 @@ func (cu *cadvisorUnsupported) Start() error {
|
|||||||
return unsupportedErr
|
return unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
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{}, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
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, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
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, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (cu *cadvisorUnsupported) MachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
func (cu *cadvisorUnsupported) VersionInfo() (*cadvisorapi.VersionInfo, error) {
|
||||||
return nil, unsupportedErr
|
return nil, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (cu *cadvisorUnsupported) DockerImagesFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorApiV2.FsInfo{}, unsupportedErr
|
return cadvisorapiv2.FsInfo{}, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) RootFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (cu *cadvisorUnsupported) RootFsInfo() (cadvisorapiv2.FsInfo, error) {
|
||||||
return cadvisorApiV2.FsInfo{}, unsupportedErr
|
return cadvisorapiv2.FsInfo{}, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cu *cadvisorUnsupported) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
func (cu *cadvisorUnsupported) WatchEvents(request *events.Request) (*events.EventChannel, error) {
|
||||||
|
@ -18,25 +18,25 @@ package cadvisor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiV2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Interface is an abstract interface for testability. It abstracts the interface to cAdvisor.
|
// Interface is an abstract interface for testability. It abstracts the interface to cAdvisor.
|
||||||
type Interface interface {
|
type Interface interface {
|
||||||
Start() error
|
Start() error
|
||||||
DockerContainer(name string, req *cadvisorApi.ContainerInfoRequest) (cadvisorApi.ContainerInfo, error)
|
DockerContainer(name string, req *cadvisorapi.ContainerInfoRequest) (cadvisorapi.ContainerInfo, error)
|
||||||
ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
ContainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
|
||||||
SubcontainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (map[string]*cadvisorApi.ContainerInfo, error)
|
SubcontainerInfo(name string, req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error)
|
||||||
MachineInfo() (*cadvisorApi.MachineInfo, error)
|
MachineInfo() (*cadvisorapi.MachineInfo, error)
|
||||||
|
|
||||||
VersionInfo() (*cadvisorApi.VersionInfo, error)
|
VersionInfo() (*cadvisorapi.VersionInfo, error)
|
||||||
|
|
||||||
// Returns usage information about the filesystem holding Docker images.
|
// Returns usage information about the filesystem holding Docker images.
|
||||||
DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error)
|
DockerImagesFsInfo() (cadvisorapiv2.FsInfo, error)
|
||||||
|
|
||||||
// Returns usage information about the root filesystem.
|
// Returns usage information about the root filesystem.
|
||||||
RootFsInfo() (cadvisorApiV2.FsInfo, error)
|
RootFsInfo() (cadvisorapiv2.FsInfo, error)
|
||||||
|
|
||||||
// Get events streamed through passedChannel that fit the request.
|
// Get events streamed through passedChannel that fit the request.
|
||||||
WatchEvents(request *events.Request) (*events.EventChannel, error)
|
WatchEvents(request *events.Request) (*events.EventChannel, error)
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
"k8s.io/kubernetes/pkg/credentialprovider"
|
"k8s.io/kubernetes/pkg/credentialprovider"
|
||||||
@ -671,7 +671,7 @@ func TestFindContainersByPod(t *testing.T) {
|
|||||||
fakeClient := &FakeDockerClient{}
|
fakeClient := &FakeDockerClient{}
|
||||||
np, _ := network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
|
np, _ := network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
|
||||||
// image back-off is set to nil, this test shouldnt pull images
|
// image back-off is set to nil, this test shouldnt pull images
|
||||||
containerManager := NewFakeDockerManager(fakeClient, &record.FakeRecorder{}, nil, nil, &cadvisorApi.MachineInfo{}, PodInfraContainerImage, 0, 0, "", kubecontainer.FakeOS{}, np, nil, nil, nil)
|
containerManager := NewFakeDockerManager(fakeClient, &record.FakeRecorder{}, nil, nil, &cadvisorapi.MachineInfo{}, PodInfraContainerImage, 0, 0, "", kubecontainer.FakeOS{}, np, nil, nil, nil)
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
fakeClient.ContainerList = test.containerList
|
fakeClient.ContainerList = test.containerList
|
||||||
fakeClient.ExitedContainerList = test.exitedContainerList
|
fakeClient.ExitedContainerList = test.exitedContainerList
|
||||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package dockertools
|
package dockertools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/network"
|
"k8s.io/kubernetes/pkg/kubelet/network"
|
||||||
@ -33,7 +33,7 @@ func NewFakeDockerManager(
|
|||||||
recorder record.EventRecorder,
|
recorder record.EventRecorder,
|
||||||
prober prober.Prober,
|
prober prober.Prober,
|
||||||
containerRefManager *kubecontainer.RefManager,
|
containerRefManager *kubecontainer.RefManager,
|
||||||
machineInfo *cadvisorApi.MachineInfo,
|
machineInfo *cadvisorapi.MachineInfo,
|
||||||
podInfraContainerImage string,
|
podInfraContainerImage string,
|
||||||
qps float32,
|
qps float32,
|
||||||
burst int,
|
burst int,
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/golang/groupcache/lru"
|
"github.com/golang/groupcache/lru"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/latest"
|
"k8s.io/kubernetes/pkg/api/latest"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
@ -89,7 +89,7 @@ type DockerManager struct {
|
|||||||
recorder record.EventRecorder
|
recorder record.EventRecorder
|
||||||
containerRefManager *kubecontainer.RefManager
|
containerRefManager *kubecontainer.RefManager
|
||||||
os kubecontainer.OSInterface
|
os kubecontainer.OSInterface
|
||||||
machineInfo *cadvisorApi.MachineInfo
|
machineInfo *cadvisorapi.MachineInfo
|
||||||
|
|
||||||
// The image name of the pod infra container.
|
// The image name of the pod infra container.
|
||||||
podInfraContainerImage string
|
podInfraContainerImage string
|
||||||
@ -149,7 +149,7 @@ func NewDockerManager(
|
|||||||
recorder record.EventRecorder,
|
recorder record.EventRecorder,
|
||||||
prober prober.Prober,
|
prober prober.Prober,
|
||||||
containerRefManager *kubecontainer.RefManager,
|
containerRefManager *kubecontainer.RefManager,
|
||||||
machineInfo *cadvisorApi.MachineInfo,
|
machineInfo *cadvisorapi.MachineInfo,
|
||||||
podInfraContainerImage string,
|
podInfraContainerImage string,
|
||||||
qps float32,
|
qps float32,
|
||||||
burst int,
|
burst int,
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/testapi"
|
"k8s.io/kubernetes/pkg/api/testapi"
|
||||||
@ -85,7 +85,7 @@ func newTestDockerManagerWithHTTPClient(fakeHTTPClient *fakeHTTP) (*DockerManage
|
|||||||
fakeRecorder,
|
fakeRecorder,
|
||||||
prober.FakeProber{},
|
prober.FakeProber{},
|
||||||
containerRefManager,
|
containerRefManager,
|
||||||
&cadvisorApi.MachineInfo{},
|
&cadvisorapi.MachineInfo{},
|
||||||
PodInfraContainerImage,
|
PodInfraContainerImage,
|
||||||
0, 0, "",
|
0, 0, "",
|
||||||
kubecontainer.FakeOS{},
|
kubecontainer.FakeOS{},
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
apierrors "k8s.io/kubernetes/pkg/api/errors"
|
apierrors "k8s.io/kubernetes/pkg/api/errors"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
@ -530,7 +530,7 @@ type Kubelet struct {
|
|||||||
diskSpaceManager diskSpaceManager
|
diskSpaceManager diskSpaceManager
|
||||||
|
|
||||||
// Cached MachineInfo returned by cadvisor.
|
// Cached MachineInfo returned by cadvisor.
|
||||||
machineInfo *cadvisorApi.MachineInfo
|
machineInfo *cadvisorapi.MachineInfo
|
||||||
|
|
||||||
// Syncs pods statuses with apiserver; also used as a cache of statuses.
|
// Syncs pods statuses with apiserver; also used as a cache of statuses.
|
||||||
statusManager status.Manager
|
statusManager status.Manager
|
||||||
@ -2769,7 +2769,7 @@ func (kl *Kubelet) ResyncInterval() time.Duration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerInfo returns stats (from Cadvisor) for a container.
|
// GetContainerInfo returns stats (from Cadvisor) for a container.
|
||||||
func (kl *Kubelet) GetContainerInfo(podFullName string, podUID types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (kl *Kubelet) GetContainerInfo(podFullName string, podUID types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
|
|
||||||
podUID = kl.podManager.TranslatePodUID(podUID)
|
podUID = kl.podManager.TranslatePodUID(podUID)
|
||||||
|
|
||||||
@ -2791,7 +2791,7 @@ func (kl *Kubelet) GetContainerInfo(podFullName string, podUID types.UID, contai
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns stats (from Cadvisor) for a non-Kubernetes container.
|
// Returns stats (from Cadvisor) for a non-Kubernetes container.
|
||||||
func (kl *Kubelet) GetRawContainerInfo(containerName string, req *cadvisorApi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorApi.ContainerInfo, error) {
|
func (kl *Kubelet) GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
if subcontainers {
|
if subcontainers {
|
||||||
return kl.cadvisor.SubcontainerInfo(containerName, req)
|
return kl.cadvisor.SubcontainerInfo(containerName, req)
|
||||||
} else {
|
} else {
|
||||||
@ -2799,14 +2799,14 @@ func (kl *Kubelet) GetRawContainerInfo(containerName string, req *cadvisorApi.Co
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return map[string]*cadvisorApi.ContainerInfo{
|
return map[string]*cadvisorapi.ContainerInfo{
|
||||||
containerInfo.Name: containerInfo,
|
containerInfo.Name: containerInfo,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCachedMachineInfo assumes that the machine info can't change without a reboot
|
// GetCachedMachineInfo assumes that the machine info can't change without a reboot
|
||||||
func (kl *Kubelet) GetCachedMachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (kl *Kubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
if kl.machineInfo == nil {
|
if kl.machineInfo == nil {
|
||||||
info, err := kl.cadvisor.MachineInfo()
|
info, err := kl.cadvisor.MachineInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,8 +31,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
cadvisorApiv2 "github.com/google/cadvisor/info/v2"
|
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
apierrors "k8s.io/kubernetes/pkg/api/errors"
|
apierrors "k8s.io/kubernetes/pkg/api/errors"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
@ -318,7 +318,7 @@ var emptyPodUIDs map[types.UID]kubetypes.SyncPodType
|
|||||||
|
|
||||||
func TestSyncLoopTimeUpdate(t *testing.T) {
|
func TestSyncLoopTimeUpdate(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
|
|
||||||
loopTime1 := kubelet.LatestLoopEntryTime()
|
loopTime1 := kubelet.LatestLoopEntryTime()
|
||||||
@ -340,7 +340,7 @@ func TestSyncLoopTimeUpdate(t *testing.T) {
|
|||||||
|
|
||||||
func TestSyncLoopAbort(t *testing.T) {
|
func TestSyncLoopAbort(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
kubelet.lastTimestampRuntimeUp = time.Now()
|
kubelet.lastTimestampRuntimeUp = time.Now()
|
||||||
kubelet.networkConfigured = true
|
kubelet.networkConfigured = true
|
||||||
@ -363,9 +363,9 @@ func TestSyncLoopAbort(t *testing.T) {
|
|||||||
|
|
||||||
func TestSyncPodsStartPod(t *testing.T) {
|
func TestSyncPodsStartPod(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
@ -392,9 +392,9 @@ func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) {
|
|||||||
|
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
kubelet.sourcesReady = func(_ sets.String) bool { return ready }
|
kubelet.sourcesReady = func(_ sets.String) bool { return ready }
|
||||||
|
|
||||||
@ -569,8 +569,8 @@ func TestMakeVolumeMounts(t *testing.T) {
|
|||||||
func TestGetContainerInfo(t *testing.T) {
|
func TestGetContainerInfo(t *testing.T) {
|
||||||
containerID := "ab2cdf"
|
containerID := "ab2cdf"
|
||||||
containerPath := fmt.Sprintf("/docker/%v", containerID)
|
containerPath := fmt.Sprintf("/docker/%v", containerID)
|
||||||
containerInfo := cadvisorApi.ContainerInfo{
|
containerInfo := cadvisorapi.ContainerInfo{
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: containerPath,
|
Name: containerPath,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -578,7 +578,7 @@ func TestGetContainerInfo(t *testing.T) {
|
|||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
cadvisorReq := &cadvisorApi.ContainerInfoRequest{}
|
cadvisorReq := &cadvisorapi.ContainerInfoRequest{}
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
mockCadvisor.On("DockerContainer", containerID, cadvisorReq).Return(containerInfo, nil)
|
mockCadvisor.On("DockerContainer", containerID, cadvisorReq).Return(containerInfo, nil)
|
||||||
fakeRuntime.PodList = []*kubecontainer.Pod{
|
fakeRuntime.PodList = []*kubecontainer.Pod{
|
||||||
@ -606,15 +606,15 @@ func TestGetContainerInfo(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetRawContainerInfoRoot(t *testing.T) {
|
func TestGetRawContainerInfoRoot(t *testing.T) {
|
||||||
containerPath := "/"
|
containerPath := "/"
|
||||||
containerInfo := &cadvisorApi.ContainerInfo{
|
containerInfo := &cadvisorapi.ContainerInfo{
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: containerPath,
|
Name: containerPath,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
cadvisorReq := &cadvisorApi.ContainerInfoRequest{}
|
cadvisorReq := &cadvisorapi.ContainerInfoRequest{}
|
||||||
mockCadvisor.On("ContainerInfo", containerPath, cadvisorReq).Return(containerInfo, nil)
|
mockCadvisor.On("ContainerInfo", containerPath, cadvisorReq).Return(containerInfo, nil)
|
||||||
|
|
||||||
_, err := kubelet.GetRawContainerInfo(containerPath, cadvisorReq, false)
|
_, err := kubelet.GetRawContainerInfo(containerPath, cadvisorReq, false)
|
||||||
@ -626,14 +626,14 @@ func TestGetRawContainerInfoRoot(t *testing.T) {
|
|||||||
|
|
||||||
func TestGetRawContainerInfoSubcontainers(t *testing.T) {
|
func TestGetRawContainerInfoSubcontainers(t *testing.T) {
|
||||||
containerPath := "/kubelet"
|
containerPath := "/kubelet"
|
||||||
containerInfo := map[string]*cadvisorApi.ContainerInfo{
|
containerInfo := map[string]*cadvisorapi.ContainerInfo{
|
||||||
containerPath: {
|
containerPath: {
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: containerPath,
|
Name: containerPath,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"/kubelet/sub": {
|
"/kubelet/sub": {
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: "/kubelet/sub",
|
Name: "/kubelet/sub",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -641,7 +641,7 @@ func TestGetRawContainerInfoSubcontainers(t *testing.T) {
|
|||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
cadvisorReq := &cadvisorApi.ContainerInfoRequest{}
|
cadvisorReq := &cadvisorapi.ContainerInfoRequest{}
|
||||||
mockCadvisor.On("SubcontainerInfo", containerPath, cadvisorReq).Return(containerInfo, nil)
|
mockCadvisor.On("SubcontainerInfo", containerPath, cadvisorReq).Return(containerInfo, nil)
|
||||||
|
|
||||||
result, err := kubelet.GetRawContainerInfo(containerPath, cadvisorReq, true)
|
result, err := kubelet.GetRawContainerInfo(containerPath, cadvisorReq, true)
|
||||||
@ -661,8 +661,8 @@ func TestGetContainerInfoWhenCadvisorFailed(t *testing.T) {
|
|||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
cadvisorApiFailure := fmt.Errorf("cAdvisor failure")
|
cadvisorApiFailure := fmt.Errorf("cAdvisor failure")
|
||||||
containerInfo := cadvisorApi.ContainerInfo{}
|
containerInfo := cadvisorapi.ContainerInfo{}
|
||||||
cadvisorReq := &cadvisorApi.ContainerInfoRequest{}
|
cadvisorReq := &cadvisorapi.ContainerInfoRequest{}
|
||||||
mockCadvisor.On("DockerContainer", containerID, cadvisorReq).Return(containerInfo, cadvisorApiFailure)
|
mockCadvisor.On("DockerContainer", containerID, cadvisorReq).Return(containerInfo, cadvisorApiFailure)
|
||||||
fakeRuntime.PodList = []*kubecontainer.Pod{
|
fakeRuntime.PodList = []*kubecontainer.Pod{
|
||||||
{
|
{
|
||||||
@ -2185,9 +2185,9 @@ func TestGetHostPortConflicts(t *testing.T) {
|
|||||||
func TestHandlePortConflicts(t *testing.T) {
|
func TestHandlePortConflicts(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
|
|
||||||
spec := api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 80}}}}}
|
spec := api.PodSpec{Containers: []api.Container{{Ports: []api.ContainerPort{{HostPort: 80}}}}}
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
@ -2232,9 +2232,9 @@ func TestHandleNodeSelector(t *testing.T) {
|
|||||||
kl.nodeLister = testNodeLister{nodes: []api.Node{
|
kl.nodeLister = testNodeLister{nodes: []api.Node{
|
||||||
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname, Labels: map[string]string{"key": "B"}}},
|
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname, Labels: map[string]string{"key": "B"}}},
|
||||||
}}
|
}}
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
{
|
{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
@ -2271,9 +2271,9 @@ func TestHandleNodeSelector(t *testing.T) {
|
|||||||
func TestHandleMemExceeded(t *testing.T) {
|
func TestHandleMemExceeded(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{MemoryCapacity: 100}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{MemoryCapacity: 100}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
|
|
||||||
spec := api.PodSpec{Containers: []api.Container{{Resources: api.ResourceRequirements{
|
spec := api.PodSpec{Containers: []api.Container{{Resources: api.ResourceRequirements{
|
||||||
Requests: api.ResourceList{
|
Requests: api.ResourceList{
|
||||||
@ -2318,9 +2318,9 @@ func TestHandleMemExceeded(t *testing.T) {
|
|||||||
// TODO(filipg): This test should be removed once StatusSyncer can do garbage collection without external signal.
|
// TODO(filipg): This test should be removed once StatusSyncer can do garbage collection without external signal.
|
||||||
func TestPurgingObsoleteStatusMapEntries(t *testing.T) {
|
func TestPurgingObsoleteStatusMapEntries(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
|
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
@ -2449,7 +2449,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
|||||||
kubeClient.ReactionChain = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{
|
kubeClient.ReactionChain = testclient.NewSimpleFake(&api.NodeList{Items: []api.Node{
|
||||||
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}},
|
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}},
|
||||||
}}).ReactionChain
|
}}).ReactionChain
|
||||||
machineInfo := &cadvisorApi.MachineInfo{
|
machineInfo := &cadvisorapi.MachineInfo{
|
||||||
MachineID: "123",
|
MachineID: "123",
|
||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
@ -2458,7 +2458,7 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
||||||
versionInfo := &cadvisorApi.VersionInfo{
|
versionInfo := &cadvisorapi.VersionInfo{
|
||||||
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
||||||
DockerVersion: "1.5.0",
|
DockerVersion: "1.5.0",
|
||||||
@ -2556,7 +2556,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}}).ReactionChain
|
}}).ReactionChain
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
machineInfo := &cadvisorApi.MachineInfo{
|
machineInfo := &cadvisorapi.MachineInfo{
|
||||||
MachineID: "123",
|
MachineID: "123",
|
||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
@ -2564,7 +2564,7 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
|
|||||||
MemoryCapacity: 1024,
|
MemoryCapacity: 1024,
|
||||||
}
|
}
|
||||||
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
||||||
versionInfo := &cadvisorApi.VersionInfo{
|
versionInfo := &cadvisorapi.VersionInfo{
|
||||||
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
||||||
DockerVersion: "1.5.0",
|
DockerVersion: "1.5.0",
|
||||||
@ -2650,7 +2650,7 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
|
|||||||
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}},
|
{ObjectMeta: api.ObjectMeta{Name: testKubeletHostname}},
|
||||||
}}).ReactionChain
|
}}).ReactionChain
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
machineInfo := &cadvisorApi.MachineInfo{
|
machineInfo := &cadvisorapi.MachineInfo{
|
||||||
MachineID: "123",
|
MachineID: "123",
|
||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
@ -2658,7 +2658,7 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
|
|||||||
MemoryCapacity: 1024,
|
MemoryCapacity: 1024,
|
||||||
}
|
}
|
||||||
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
||||||
versionInfo := &cadvisorApi.VersionInfo{
|
versionInfo := &cadvisorapi.VersionInfo{
|
||||||
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
||||||
DockerVersion: "1.5.0",
|
DockerVersion: "1.5.0",
|
||||||
@ -2778,9 +2778,9 @@ func TestCreateMirrorPod(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeleteOutdatedMirrorPod(t *testing.T) {
|
func TestDeleteOutdatedMirrorPod(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
manager := testKubelet.fakeMirrorClient
|
manager := testKubelet.fakeMirrorClient
|
||||||
pod := &api.Pod{
|
pod := &api.Pod{
|
||||||
@ -2831,9 +2831,9 @@ func TestDeleteOutdatedMirrorPod(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeleteOrphanedMirrorPods(t *testing.T) {
|
func TestDeleteOrphanedMirrorPods(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
manager := testKubelet.fakeMirrorClient
|
manager := testKubelet.fakeMirrorClient
|
||||||
orphanPods := []*api.Pod{
|
orphanPods := []*api.Pod{
|
||||||
@ -2915,8 +2915,8 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
|
|||||||
|
|
||||||
containerID := "ab2cdf"
|
containerID := "ab2cdf"
|
||||||
containerPath := fmt.Sprintf("/docker/%v", containerID)
|
containerPath := fmt.Sprintf("/docker/%v", containerID)
|
||||||
containerInfo := cadvisorApi.ContainerInfo{
|
containerInfo := cadvisorapi.ContainerInfo{
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: containerPath,
|
Name: containerPath,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -2924,7 +2924,7 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
|
|||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
cadvisorReq := &cadvisorApi.ContainerInfoRequest{}
|
cadvisorReq := &cadvisorapi.ContainerInfoRequest{}
|
||||||
mockCadvisor.On("DockerContainer", containerID, cadvisorReq).Return(containerInfo, nil)
|
mockCadvisor.On("DockerContainer", containerID, cadvisorReq).Return(containerInfo, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
|
|
||||||
@ -2956,9 +2956,9 @@ func TestGetContainerInfoForMirrorPods(t *testing.T) {
|
|||||||
|
|
||||||
func TestDoNotCacheStatusForStaticPods(t *testing.T) {
|
func TestDoNotCacheStatusForStaticPods(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
|
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
@ -3144,7 +3144,7 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
|
|||||||
kubeClient.AddReactor("*", "*", func(action testclient.Action) (bool, runtime.Object, error) {
|
kubeClient.AddReactor("*", "*", func(action testclient.Action) (bool, runtime.Object, error) {
|
||||||
return true, nil, fmt.Errorf("no reaction implemented for %s", action)
|
return true, nil, fmt.Errorf("no reaction implemented for %s", action)
|
||||||
})
|
})
|
||||||
machineInfo := &cadvisorApi.MachineInfo{
|
machineInfo := &cadvisorapi.MachineInfo{
|
||||||
MachineID: "123",
|
MachineID: "123",
|
||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
@ -3153,7 +3153,7 @@ func TestRegisterExistingNodeWithApiserver(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mockCadvisor := testKubelet.fakeCadvisor
|
mockCadvisor := testKubelet.fakeCadvisor
|
||||||
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
||||||
versionInfo := &cadvisorApi.VersionInfo{
|
versionInfo := &cadvisorapi.VersionInfo{
|
||||||
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
||||||
DockerVersion: "1.5.0",
|
DockerVersion: "1.5.0",
|
||||||
@ -3277,7 +3277,7 @@ func TestIsPodPastActiveDeadline(t *testing.T) {
|
|||||||
func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
|
func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
|
|
||||||
now := unversioned.Now()
|
now := unversioned.Now()
|
||||||
@ -3328,7 +3328,7 @@ func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
|
|||||||
func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
|
func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
fakeRuntime := testKubelet.fakeRuntime
|
fakeRuntime := testKubelet.fakeRuntime
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
kubelet := testKubelet.kubelet
|
kubelet := testKubelet.kubelet
|
||||||
|
|
||||||
now := unversioned.Now()
|
now := unversioned.Now()
|
||||||
@ -3378,9 +3378,9 @@ func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeletePodDirsForDeletedPods(t *testing.T) {
|
func TestDeletePodDirsForDeletedPods(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
{
|
{
|
||||||
@ -3437,9 +3437,9 @@ func syncAndVerifyPodDir(t *testing.T, testKubelet *TestKubelet, pods []*api.Pod
|
|||||||
|
|
||||||
func TestDoesNotDeletePodDirsForTerminatedPods(t *testing.T) {
|
func TestDoesNotDeletePodDirsForTerminatedPods(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
pods := []*api.Pod{
|
pods := []*api.Pod{
|
||||||
{
|
{
|
||||||
@ -3475,9 +3475,9 @@ func TestDoesNotDeletePodDirsForTerminatedPods(t *testing.T) {
|
|||||||
|
|
||||||
func TestDoesNotDeletePodDirsIfContainerIsRunning(t *testing.T) {
|
func TestDoesNotDeletePodDirsIfContainerIsRunning(t *testing.T) {
|
||||||
testKubelet := newTestKubelet(t)
|
testKubelet := newTestKubelet(t)
|
||||||
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
testKubelet.fakeCadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("DockerImagesFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorApiv2.FsInfo{}, nil)
|
testKubelet.fakeCadvisor.On("RootFsInfo").Return(cadvisorapiv2.FsInfo{}, nil)
|
||||||
runningPod := &kubecontainer.Pod{
|
runningPod := &kubecontainer.Pod{
|
||||||
ID: "12345678",
|
ID: "12345678",
|
||||||
Name: "pod1",
|
Name: "pod1",
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
@ -154,7 +154,7 @@ func newTestDockerManager() (*dockertools.DockerManager, *dockertools.FakeDocker
|
|||||||
fakeRecorder,
|
fakeRecorder,
|
||||||
prober.FakeProber{},
|
prober.FakeProber{},
|
||||||
containerRefManager,
|
containerRefManager,
|
||||||
&cadvisorApi.MachineInfo{},
|
&cadvisorapi.MachineInfo{},
|
||||||
dockertools.PodInfraContainerImage,
|
dockertools.PodInfraContainerImage,
|
||||||
0, 0, "",
|
0, 0, "",
|
||||||
kubecontainer.FakeOS{},
|
kubecontainer.FakeOS{},
|
||||||
|
@ -19,7 +19,7 @@ package kubelet
|
|||||||
import (
|
import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
@ -48,8 +48,8 @@ const systemOOMEvent = "SystemOOM"
|
|||||||
// Watches cadvisor for system oom's and records an event for every system oom encountered.
|
// Watches cadvisor for system oom's and records an event for every system oom encountered.
|
||||||
func (ow *realOOMWatcher) Start(ref *api.ObjectReference) error {
|
func (ow *realOOMWatcher) Start(ref *api.ObjectReference) error {
|
||||||
request := events.Request{
|
request := events.Request{
|
||||||
EventType: map[cadvisorApi.EventType]bool{
|
EventType: map[cadvisorapi.EventType]bool{
|
||||||
cadvisorApi.EventOom: true,
|
cadvisorapi.EventOom: true,
|
||||||
},
|
},
|
||||||
ContainerName: "/",
|
ContainerName: "/",
|
||||||
IncludeSubcontainers: false,
|
IncludeSubcontainers: false,
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
@ -46,7 +46,7 @@ func newPod(uid, name string) *api.Pod {
|
|||||||
func createFakeRuntimeCache(fakeRecorder *record.FakeRecorder) kubecontainer.RuntimeCache {
|
func createFakeRuntimeCache(fakeRecorder *record.FakeRecorder) kubecontainer.RuntimeCache {
|
||||||
fakeDocker := &dockertools.FakeDockerClient{}
|
fakeDocker := &dockertools.FakeDockerClient{}
|
||||||
np, _ := network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
|
np, _ := network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
|
||||||
dockerManager := dockertools.NewFakeDockerManager(fakeDocker, fakeRecorder, nil, nil, &cadvisorApi.MachineInfo{}, dockertools.PodInfraContainerImage, 0, 0, "", kubecontainer.FakeOS{}, np, nil, nil, nil)
|
dockerManager := dockertools.NewFakeDockerManager(fakeDocker, fakeRecorder, nil, nil, &cadvisorapi.MachineInfo{}, dockertools.PodInfraContainerImage, 0, 0, "", kubecontainer.FakeOS{}, np, nil, nil, nil)
|
||||||
return kubecontainer.NewFakeRuntimeCache(dockerManager)
|
return kubecontainer.NewFakeRuntimeCache(dockerManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ func TestFakePodWorkers(t *testing.T) {
|
|||||||
fakeDocker := &dockertools.FakeDockerClient{}
|
fakeDocker := &dockertools.FakeDockerClient{}
|
||||||
fakeRecorder := &record.FakeRecorder{}
|
fakeRecorder := &record.FakeRecorder{}
|
||||||
np, _ := network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
|
np, _ := network.InitNetworkPlugin([]network.NetworkPlugin{}, "", network.NewFakeHost(nil))
|
||||||
dockerManager := dockertools.NewFakeDockerManager(fakeDocker, fakeRecorder, nil, nil, &cadvisorApi.MachineInfo{}, dockertools.PodInfraContainerImage, 0, 0, "", kubecontainer.FakeOS{}, np, nil, nil, nil)
|
dockerManager := dockertools.NewFakeDockerManager(fakeDocker, fakeRecorder, nil, nil, &cadvisorapi.MachineInfo{}, dockertools.PodInfraContainerImage, 0, 0, "", kubecontainer.FakeOS{}, np, nil, nil, nil)
|
||||||
fakeRuntimeCache := kubecontainer.NewFakeRuntimeCache(dockerManager)
|
fakeRuntimeCache := kubecontainer.NewFakeRuntimeCache(dockerManager)
|
||||||
|
|
||||||
kubeletForRealWorkers := &simpleFakeKubelet{}
|
kubeletForRealWorkers := &simpleFakeKubelet{}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/client/record"
|
"k8s.io/kubernetes/pkg/client/record"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
|
||||||
@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
func TestRunOnce(t *testing.T) {
|
func TestRunOnce(t *testing.T) {
|
||||||
cadvisor := &cadvisor.Mock{}
|
cadvisor := &cadvisor.Mock{}
|
||||||
cadvisor.On("MachineInfo").Return(&cadvisorApi.MachineInfo{}, nil)
|
cadvisor.On("MachineInfo").Return(&cadvisorapi.MachineInfo{}, nil)
|
||||||
podManager := kubepod.NewBasicPodManager(kubepod.NewFakeMirrorClient())
|
podManager := kubepod.NewBasicPodManager(kubepod.NewFakeMirrorClient())
|
||||||
diskSpaceManager, _ := newDiskSpaceManager(cadvisor, DiskSpacePolicy{})
|
diskSpaceManager, _ := newDiskSpaceManager(cadvisor, DiskSpacePolicy{})
|
||||||
fakeRuntime := &kubecontainer.FakeRuntime{}
|
fakeRuntime := &kubecontainer.FakeRuntime{}
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
|
|
||||||
restful "github.com/emicklei/go-restful"
|
restful "github.com/emicklei/go-restful"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
@ -137,10 +137,10 @@ type AuthInterface interface {
|
|||||||
// HostInterface contains all the kubelet methods required by the server.
|
// HostInterface contains all the kubelet methods required by the server.
|
||||||
// For testablitiy.
|
// For testablitiy.
|
||||||
type HostInterface interface {
|
type HostInterface interface {
|
||||||
GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
|
||||||
GetContainerRuntimeVersion() (kubecontainer.Version, error)
|
GetContainerRuntimeVersion() (kubecontainer.Version, error)
|
||||||
GetRawContainerInfo(containerName string, req *cadvisorApi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorApi.ContainerInfo, error)
|
GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error)
|
||||||
GetCachedMachineInfo() (*cadvisorApi.MachineInfo, error)
|
GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error)
|
||||||
GetPods() []*api.Pod
|
GetPods() []*api.Pod
|
||||||
GetRunningPods() ([]*api.Pod, error)
|
GetRunningPods() ([]*api.Pod, error)
|
||||||
GetPodByName(namespace, name string) (*api.Pod, bool)
|
GetPodByName(namespace, name string) (*api.Pod, bool)
|
||||||
@ -232,7 +232,7 @@ func (s *Server) InstallDefaultHandlers() {
|
|||||||
ws.Route(ws.GET("").
|
ws.Route(ws.GET("").
|
||||||
To(s.getSpec).
|
To(s.getSpec).
|
||||||
Operation("getSpec").
|
Operation("getSpec").
|
||||||
Writes(cadvisorApi.MachineInfo{}))
|
Writes(cadvisorapi.MachineInfo{}))
|
||||||
s.restfulCont.Add(ws)
|
s.restfulCont.Add(ws)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,7 +1101,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
|
|||||||
s.error(w, err)
|
s.error(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cadvisorRequest := cadvisorApi.ContainerInfoRequest{
|
cadvisorRequest := cadvisorapi.ContainerInfoRequest{
|
||||||
NumStats: query.NumStats,
|
NumStats: query.NumStats,
|
||||||
Start: query.Start,
|
Start: query.Start,
|
||||||
End: query.End,
|
End: query.End,
|
||||||
@ -1110,7 +1110,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
|
|||||||
switch len(components) {
|
switch len(components) {
|
||||||
case 1:
|
case 1:
|
||||||
// Root container stats.
|
// Root container stats.
|
||||||
var statsMap map[string]*cadvisorApi.ContainerInfo
|
var statsMap map[string]*cadvisorapi.ContainerInfo
|
||||||
statsMap, err = s.host.GetRawContainerInfo("/", &cadvisorRequest, false)
|
statsMap, err = s.host.GetRawContainerInfo("/", &cadvisorRequest, false)
|
||||||
stats = statsMap["/"]
|
stats = statsMap["/"]
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
apierrs "k8s.io/kubernetes/pkg/api/errors"
|
||||||
"k8s.io/kubernetes/pkg/auth/authorizer"
|
"k8s.io/kubernetes/pkg/auth/authorizer"
|
||||||
@ -49,9 +49,9 @@ import (
|
|||||||
|
|
||||||
type fakeKubelet struct {
|
type fakeKubelet struct {
|
||||||
podByNameFunc func(namespace, name string) (*api.Pod, bool)
|
podByNameFunc func(namespace, name string) (*api.Pod, bool)
|
||||||
containerInfoFunc func(podFullName string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
containerInfoFunc func(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error)
|
||||||
rawInfoFunc func(query *cadvisorApi.ContainerInfoRequest) (map[string]*cadvisorApi.ContainerInfo, error)
|
rawInfoFunc func(query *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error)
|
||||||
machineInfoFunc func() (*cadvisorApi.MachineInfo, error)
|
machineInfoFunc func() (*cadvisorapi.MachineInfo, error)
|
||||||
podsFunc func() []*api.Pod
|
podsFunc func() []*api.Pod
|
||||||
runningPodsFunc func() ([]*api.Pod, error)
|
runningPodsFunc func() ([]*api.Pod, error)
|
||||||
logFunc func(w http.ResponseWriter, req *http.Request)
|
logFunc func(w http.ResponseWriter, req *http.Request)
|
||||||
@ -79,11 +79,11 @@ func (fk *fakeKubelet) GetPodByName(namespace, name string) (*api.Pod, bool) {
|
|||||||
return fk.podByNameFunc(namespace, name)
|
return fk.podByNameFunc(namespace, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
func (fk *fakeKubelet) GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return fk.containerInfoFunc(podFullName, uid, containerName, req)
|
return fk.containerInfoFunc(podFullName, uid, containerName, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) GetRawContainerInfo(containerName string, req *cadvisorApi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorApi.ContainerInfo, error) {
|
func (fk *fakeKubelet) GetRawContainerInfo(containerName string, req *cadvisorapi.ContainerInfoRequest, subcontainers bool) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
return fk.rawInfoFunc(req)
|
return fk.rawInfoFunc(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ func (fk *fakeKubelet) GetContainerRuntimeVersion() (kubecontainer.Version, erro
|
|||||||
return fk.containerVersionFunc()
|
return fk.containerVersionFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) GetCachedMachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (fk *fakeKubelet) GetCachedMachineInfo() (*cadvisorapi.MachineInfo, error) {
|
||||||
return fk.machineInfoFunc()
|
return fk.machineInfoFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,11 +218,11 @@ func getPodName(name, namespace string) string {
|
|||||||
|
|
||||||
func TestContainerInfo(t *testing.T) {
|
func TestContainerInfo(t *testing.T) {
|
||||||
fw := newServerTest()
|
fw := newServerTest()
|
||||||
expectedInfo := &cadvisorApi.ContainerInfo{}
|
expectedInfo := &cadvisorapi.ContainerInfo{}
|
||||||
podID := "somepod"
|
podID := "somepod"
|
||||||
expectedPodID := getPodName(podID, "")
|
expectedPodID := getPodName(podID, "")
|
||||||
expectedContainerName := "goodcontainer"
|
expectedContainerName := "goodcontainer"
|
||||||
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
if podID != expectedPodID || containerName != expectedContainerName {
|
if podID != expectedPodID || containerName != expectedContainerName {
|
||||||
return nil, fmt.Errorf("bad podID or containerName: podID=%v; containerName=%v", podID, containerName)
|
return nil, fmt.Errorf("bad podID or containerName: podID=%v; containerName=%v", podID, containerName)
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ func TestContainerInfo(t *testing.T) {
|
|||||||
t.Fatalf("Got error GETing: %v", err)
|
t.Fatalf("Got error GETing: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
var receivedInfo cadvisorApi.ContainerInfo
|
var receivedInfo cadvisorapi.ContainerInfo
|
||||||
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("received invalid json data: %v", err)
|
t.Fatalf("received invalid json data: %v", err)
|
||||||
@ -246,13 +246,13 @@ func TestContainerInfo(t *testing.T) {
|
|||||||
|
|
||||||
func TestContainerInfoWithUidNamespace(t *testing.T) {
|
func TestContainerInfoWithUidNamespace(t *testing.T) {
|
||||||
fw := newServerTest()
|
fw := newServerTest()
|
||||||
expectedInfo := &cadvisorApi.ContainerInfo{}
|
expectedInfo := &cadvisorapi.ContainerInfo{}
|
||||||
podID := "somepod"
|
podID := "somepod"
|
||||||
expectedNamespace := "custom"
|
expectedNamespace := "custom"
|
||||||
expectedPodID := getPodName(podID, expectedNamespace)
|
expectedPodID := getPodName(podID, expectedNamespace)
|
||||||
expectedContainerName := "goodcontainer"
|
expectedContainerName := "goodcontainer"
|
||||||
expectedUid := "9b01b80f-8fb4-11e4-95ab-4200af06647"
|
expectedUid := "9b01b80f-8fb4-11e4-95ab-4200af06647"
|
||||||
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
if podID != expectedPodID || string(uid) != expectedUid || containerName != expectedContainerName {
|
if podID != expectedPodID || string(uid) != expectedUid || containerName != expectedContainerName {
|
||||||
return nil, fmt.Errorf("bad podID or uid or containerName: podID=%v; uid=%v; containerName=%v", podID, uid, containerName)
|
return nil, fmt.Errorf("bad podID or uid or containerName: podID=%v; uid=%v; containerName=%v", podID, uid, containerName)
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ func TestContainerInfoWithUidNamespace(t *testing.T) {
|
|||||||
t.Fatalf("Got error GETing: %v", err)
|
t.Fatalf("Got error GETing: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
var receivedInfo cadvisorApi.ContainerInfo
|
var receivedInfo cadvisorapi.ContainerInfo
|
||||||
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("received invalid json data: %v", err)
|
t.Fatalf("received invalid json data: %v", err)
|
||||||
@ -280,7 +280,7 @@ func TestContainerNotFound(t *testing.T) {
|
|||||||
expectedNamespace := "custom"
|
expectedNamespace := "custom"
|
||||||
expectedContainerName := "slowstartcontainer"
|
expectedContainerName := "slowstartcontainer"
|
||||||
expectedUid := "9b01b80f-8fb4-11e4-95ab-4200af06647"
|
expectedUid := "9b01b80f-8fb4-11e4-95ab-4200af06647"
|
||||||
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error) {
|
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *cadvisorapi.ContainerInfoRequest) (*cadvisorapi.ContainerInfo, error) {
|
||||||
return nil, ErrContainerNotFound
|
return nil, ErrContainerNotFound
|
||||||
}
|
}
|
||||||
resp, err := http.Get(fw.testHTTPServer.URL + fmt.Sprintf("/stats/%v/%v/%v/%v", expectedNamespace, podID, expectedUid, expectedContainerName))
|
resp, err := http.Get(fw.testHTTPServer.URL + fmt.Sprintf("/stats/%v/%v/%v/%v", expectedNamespace, podID, expectedUid, expectedContainerName))
|
||||||
@ -295,13 +295,13 @@ func TestContainerNotFound(t *testing.T) {
|
|||||||
|
|
||||||
func TestRootInfo(t *testing.T) {
|
func TestRootInfo(t *testing.T) {
|
||||||
fw := newServerTest()
|
fw := newServerTest()
|
||||||
expectedInfo := &cadvisorApi.ContainerInfo{
|
expectedInfo := &cadvisorapi.ContainerInfo{
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: "/",
|
Name: "/",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
fw.fakeKubelet.rawInfoFunc = func(req *cadvisorApi.ContainerInfoRequest) (map[string]*cadvisorApi.ContainerInfo, error) {
|
fw.fakeKubelet.rawInfoFunc = func(req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
return map[string]*cadvisorApi.ContainerInfo{
|
return map[string]*cadvisorapi.ContainerInfo{
|
||||||
expectedInfo.Name: expectedInfo,
|
expectedInfo.Name: expectedInfo,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -311,7 +311,7 @@ func TestRootInfo(t *testing.T) {
|
|||||||
t.Fatalf("Got error GETing: %v", err)
|
t.Fatalf("Got error GETing: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
var receivedInfo cadvisorApi.ContainerInfo
|
var receivedInfo cadvisorapi.ContainerInfo
|
||||||
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("received invalid json data: %v", err)
|
t.Fatalf("received invalid json data: %v", err)
|
||||||
@ -325,19 +325,19 @@ func TestSubcontainerContainerInfo(t *testing.T) {
|
|||||||
fw := newServerTest()
|
fw := newServerTest()
|
||||||
const kubeletContainer = "/kubelet"
|
const kubeletContainer = "/kubelet"
|
||||||
const kubeletSubContainer = "/kubelet/sub"
|
const kubeletSubContainer = "/kubelet/sub"
|
||||||
expectedInfo := map[string]*cadvisorApi.ContainerInfo{
|
expectedInfo := map[string]*cadvisorapi.ContainerInfo{
|
||||||
kubeletContainer: {
|
kubeletContainer: {
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: kubeletContainer,
|
Name: kubeletContainer,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
kubeletSubContainer: {
|
kubeletSubContainer: {
|
||||||
ContainerReference: cadvisorApi.ContainerReference{
|
ContainerReference: cadvisorapi.ContainerReference{
|
||||||
Name: kubeletSubContainer,
|
Name: kubeletSubContainer,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
fw.fakeKubelet.rawInfoFunc = func(req *cadvisorApi.ContainerInfoRequest) (map[string]*cadvisorApi.ContainerInfo, error) {
|
fw.fakeKubelet.rawInfoFunc = func(req *cadvisorapi.ContainerInfoRequest) (map[string]*cadvisorapi.ContainerInfo, error) {
|
||||||
return expectedInfo, nil
|
return expectedInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ func TestSubcontainerContainerInfo(t *testing.T) {
|
|||||||
t.Fatalf("Got error GETing: %v", err)
|
t.Fatalf("Got error GETing: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
var receivedInfo map[string]*cadvisorApi.ContainerInfo
|
var receivedInfo map[string]*cadvisorapi.ContainerInfo
|
||||||
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Received invalid json data: %v", err)
|
t.Fatalf("Received invalid json data: %v", err)
|
||||||
@ -368,11 +368,11 @@ func TestSubcontainerContainerInfo(t *testing.T) {
|
|||||||
|
|
||||||
func TestMachineInfo(t *testing.T) {
|
func TestMachineInfo(t *testing.T) {
|
||||||
fw := newServerTest()
|
fw := newServerTest()
|
||||||
expectedInfo := &cadvisorApi.MachineInfo{
|
expectedInfo := &cadvisorapi.MachineInfo{
|
||||||
NumCores: 4,
|
NumCores: 4,
|
||||||
MemoryCapacity: 1024,
|
MemoryCapacity: 1024,
|
||||||
}
|
}
|
||||||
fw.fakeKubelet.machineInfoFunc = func() (*cadvisorApi.MachineInfo, error) {
|
fw.fakeKubelet.machineInfoFunc = func() (*cadvisorapi.MachineInfo, error) {
|
||||||
return expectedInfo, nil
|
return expectedInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ func TestMachineInfo(t *testing.T) {
|
|||||||
t.Fatalf("Got error GETing: %v", err)
|
t.Fatalf("Got error GETing: %v", err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
var receivedInfo cadvisorApi.MachineInfo
|
var receivedInfo cadvisorapi.MachineInfo
|
||||||
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
err = json.NewDecoder(resp.Body).Decode(&receivedInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("received invalid json data: %v", err)
|
t.Fatalf("received invalid json data: %v", err)
|
||||||
|
@ -19,7 +19,7 @@ package kubelet
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
cadvisorApi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
"k8s.io/kubernetes/pkg/capabilities"
|
"k8s.io/kubernetes/pkg/capabilities"
|
||||||
@ -27,7 +27,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/securitycontext"
|
"k8s.io/kubernetes/pkg/securitycontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CapacityFromMachineInfo(info *cadvisorApi.MachineInfo) api.ResourceList {
|
func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) api.ResourceList {
|
||||||
c := api.ResourceList{
|
c := api.ResourceList{
|
||||||
api.ResourceCPU: *resource.NewMilliQuantity(
|
api.ResourceCPU: *resource.NewMilliQuantity(
|
||||||
int64(info.NumCores*1000),
|
int64(info.NumCores*1000),
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisor "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||||
@ -149,7 +149,7 @@ func HighLatencyKubeletOperations(c *client.Client, threshold time.Duration, nod
|
|||||||
|
|
||||||
// getContainerInfo contacts kubelet for the container informaton. The "Stats"
|
// getContainerInfo contacts kubelet for the container informaton. The "Stats"
|
||||||
// in the returned ContainerInfo is subject to the requirements in statsRequest.
|
// in the returned ContainerInfo is subject to the requirements in statsRequest.
|
||||||
func getContainerInfo(c *client.Client, nodeName string, req *kubelet.StatsRequest) (map[string]cadvisor.ContainerInfo, error) {
|
func getContainerInfo(c *client.Client, nodeName string, req *kubelet.StatsRequest) (map[string]cadvisorapi.ContainerInfo, error) {
|
||||||
reqBody, err := json.Marshal(req)
|
reqBody, err := json.Marshal(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -163,7 +163,7 @@ func getContainerInfo(c *client.Client, nodeName string, req *kubelet.StatsReque
|
|||||||
Body(reqBody).
|
Body(reqBody).
|
||||||
Do().Raw()
|
Do().Raw()
|
||||||
|
|
||||||
var containers map[string]cadvisor.ContainerInfo
|
var containers map[string]cadvisorapi.ContainerInfo
|
||||||
err = json.Unmarshal(data, &containers)
|
err = json.Unmarshal(data, &containers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -332,7 +332,7 @@ func GetKubeletPods(c *client.Client, node string) (*api.PodList, error) {
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func computeContainerResourceUsage(name string, oldStats, newStats *cadvisor.ContainerStats) *containerResourceUsage {
|
func computeContainerResourceUsage(name string, oldStats, newStats *cadvisorapi.ContainerStats) *containerResourceUsage {
|
||||||
return &containerResourceUsage{
|
return &containerResourceUsage{
|
||||||
Name: name,
|
Name: name,
|
||||||
Timestamp: newStats.Timestamp,
|
Timestamp: newStats.Timestamp,
|
||||||
@ -371,7 +371,7 @@ func newResourceCollector(c *client.Client, nodeName string, containerNames []st
|
|||||||
func (r *resourceCollector) Start() {
|
func (r *resourceCollector) Start() {
|
||||||
r.stopCh = make(chan struct{}, 1)
|
r.stopCh = make(chan struct{}, 1)
|
||||||
// Keep the last observed stats for comparison.
|
// Keep the last observed stats for comparison.
|
||||||
oldStats := make(map[string]*cadvisor.ContainerStats)
|
oldStats := make(map[string]*cadvisorapi.ContainerStats)
|
||||||
go util.Until(func() { r.collectStats(oldStats) }, r.pollingInterval, r.stopCh)
|
go util.Until(func() { r.collectStats(oldStats) }, r.pollingInterval, r.stopCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ func (r *resourceCollector) Stop() {
|
|||||||
|
|
||||||
// collectStats gets the latest stats from kubelet's /stats/container, computes
|
// collectStats gets the latest stats from kubelet's /stats/container, computes
|
||||||
// the resource usage, and pushes it to the buffer.
|
// the resource usage, and pushes it to the buffer.
|
||||||
func (r *resourceCollector) collectStats(oldStats map[string]*cadvisor.ContainerStats) {
|
func (r *resourceCollector) collectStats(oldStats map[string]*cadvisorapi.ContainerStats) {
|
||||||
infos, err := getContainerInfo(r.client, r.node, &kubelet.StatsRequest{
|
infos, err := getContainerInfo(r.client, r.node, &kubelet.StatsRequest{
|
||||||
ContainerName: "/",
|
ContainerName: "/",
|
||||||
NumStats: 1,
|
NumStats: 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user