mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Remove all code dealing with cadvisor Percentiles
This was removed upstream beween cadvisor 0.3.0 and 0.4.0
This commit is contained in:
parent
b24f202dd4
commit
a32400f47f
@ -109,10 +109,7 @@ func testHTTPContainerInfoGetter(
|
||||
|
||||
func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) {
|
||||
req := &info.ContainerInfoRequest{
|
||||
NumStats: 10,
|
||||
NumSamples: 10,
|
||||
CpuUsagePercentiles: []int{20, 30},
|
||||
MemoryUsagePercentiles: []int{40, 50},
|
||||
NumStats: 10,
|
||||
}
|
||||
cinfo := itest.GenerateRandomContainerInfo(
|
||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||
@ -125,10 +122,7 @@ func TestHTTPContainerInfoGetterGetContainerInfoSuccessfully(t *testing.T) {
|
||||
|
||||
func TestHTTPContainerInfoGetterGetRootInfoSuccessfully(t *testing.T) {
|
||||
req := &info.ContainerInfoRequest{
|
||||
NumStats: 10,
|
||||
NumSamples: 10,
|
||||
CpuUsagePercentiles: []int{20, 30},
|
||||
MemoryUsagePercentiles: []int{40, 50},
|
||||
NumStats: 10,
|
||||
}
|
||||
cinfo := itest.GenerateRandomContainerInfo(
|
||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||
@ -141,10 +135,7 @@ func TestHTTPContainerInfoGetterGetRootInfoSuccessfully(t *testing.T) {
|
||||
|
||||
func TestHTTPContainerInfoGetterGetContainerInfoWithError(t *testing.T) {
|
||||
req := &info.ContainerInfoRequest{
|
||||
NumStats: 10,
|
||||
NumSamples: 10,
|
||||
CpuUsagePercentiles: []int{20, 30},
|
||||
MemoryUsagePercentiles: []int{40, 50},
|
||||
NumStats: 10,
|
||||
}
|
||||
cinfo := itest.GenerateRandomContainerInfo(
|
||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||
@ -157,10 +148,7 @@ func TestHTTPContainerInfoGetterGetContainerInfoWithError(t *testing.T) {
|
||||
|
||||
func TestHTTPContainerInfoGetterGetRootInfoWithError(t *testing.T) {
|
||||
req := &info.ContainerInfoRequest{
|
||||
NumStats: 10,
|
||||
NumSamples: 10,
|
||||
CpuUsagePercentiles: []int{20, 30},
|
||||
MemoryUsagePercentiles: []int{40, 50},
|
||||
NumStats: 10,
|
||||
}
|
||||
cinfo := itest.GenerateRandomContainerInfo(
|
||||
"dockerIDWhichWillNotBeChecked", // docker ID
|
||||
|
@ -729,9 +729,7 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
|
||||
|
||||
func getCadvisorContainerInfoRequest(req *info.ContainerInfoRequest) *info.ContainerInfoRequest {
|
||||
ret := &info.ContainerInfoRequest{
|
||||
NumStats: req.NumStats,
|
||||
CpuUsagePercentiles: req.CpuUsagePercentiles,
|
||||
MemoryUsagePercentiles: req.MemoryUsagePercentiles,
|
||||
NumStats: req.NumStats,
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
@ -803,34 +803,6 @@ func (c *mockCadvisorClient) MachineInfo() (*info.MachineInfo, error) {
|
||||
return args.Get(0).(*info.MachineInfo), args.Error(1)
|
||||
}
|
||||
|
||||
func areSamePercentiles(
|
||||
cadvisorPercentiles []info.Percentile,
|
||||
kubePercentiles []info.Percentile,
|
||||
t *testing.T,
|
||||
) {
|
||||
if len(cadvisorPercentiles) != len(kubePercentiles) {
|
||||
t.Errorf("cadvisor gives %v percentiles; kubelet got %v", len(cadvisorPercentiles), len(kubePercentiles))
|
||||
return
|
||||
}
|
||||
for _, ap := range cadvisorPercentiles {
|
||||
found := false
|
||||
for _, kp := range kubePercentiles {
|
||||
if ap.Percentage == kp.Percentage {
|
||||
found = true
|
||||
if ap.Value != kp.Value {
|
||||
t.Errorf("%v percentile from cadvisor is %v; kubelet got %v",
|
||||
ap.Percentage,
|
||||
ap.Value,
|
||||
kp.Value)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("Unable to find %v percentile in kubelet's data", ap.Percentage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetContainerInfo(t *testing.T) {
|
||||
containerID := "ab2cdf"
|
||||
containerPath := fmt.Sprintf("/docker/%v", containerID)
|
||||
@ -838,19 +810,6 @@ func TestGetContainerInfo(t *testing.T) {
|
||||
ContainerReference: info.ContainerReference{
|
||||
Name: containerPath,
|
||||
},
|
||||
StatsPercentiles: &info.ContainerStatsPercentiles{
|
||||
MaxMemoryUsage: 1024000,
|
||||
MemoryUsagePercentiles: []info.Percentile{
|
||||
{50, 100},
|
||||
{80, 180},
|
||||
{90, 190},
|
||||
},
|
||||
CpuUsagePercentiles: []info.Percentile{
|
||||
{51, 101},
|
||||
{81, 181},
|
||||
{91, 191},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
mockCadvisor := &mockCadvisorClient{}
|
||||
@ -876,11 +835,6 @@ func TestGetContainerInfo(t *testing.T) {
|
||||
if stats == nil {
|
||||
t.Fatalf("stats should not be nil")
|
||||
}
|
||||
if stats.StatsPercentiles.MaxMemoryUsage != containerInfo.StatsPercentiles.MaxMemoryUsage {
|
||||
t.Errorf("wrong max memory usage")
|
||||
}
|
||||
areSamePercentiles(containerInfo.StatsPercentiles.CpuUsagePercentiles, stats.StatsPercentiles.CpuUsagePercentiles, t)
|
||||
areSamePercentiles(containerInfo.StatsPercentiles.MemoryUsagePercentiles, stats.StatsPercentiles.MemoryUsagePercentiles, t)
|
||||
mockCadvisor.AssertExpectations(t)
|
||||
}
|
||||
|
||||
@ -889,14 +843,6 @@ func TestGetRootInfo(t *testing.T) {
|
||||
containerInfo := &info.ContainerInfo{
|
||||
ContainerReference: info.ContainerReference{
|
||||
Name: containerPath,
|
||||
}, StatsPercentiles: &info.ContainerStatsPercentiles{MaxMemoryUsage: 1024000, MemoryUsagePercentiles: []info.Percentile{{50, 100}, {80, 180},
|
||||
{90, 190},
|
||||
},
|
||||
CpuUsagePercentiles: []info.Percentile{
|
||||
{51, 101},
|
||||
{81, 181},
|
||||
{91, 191},
|
||||
},
|
||||
},
|
||||
}
|
||||
fakeDocker := dockertools.FakeDockerClient{}
|
||||
@ -914,15 +860,10 @@ func TestGetRootInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
// If the container name is an empty string, then it means the root container.
|
||||
stats, err := kubelet.GetRootInfo(req)
|
||||
_, err := kubelet.GetRootInfo(req)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if stats.StatsPercentiles.MaxMemoryUsage != containerInfo.StatsPercentiles.MaxMemoryUsage {
|
||||
t.Errorf("wrong max memory usage")
|
||||
}
|
||||
areSamePercentiles(containerInfo.StatsPercentiles.CpuUsagePercentiles, stats.StatsPercentiles.CpuUsagePercentiles, t)
|
||||
areSamePercentiles(containerInfo.StatsPercentiles.MemoryUsagePercentiles, stats.StatsPercentiles.MemoryUsagePercentiles, t)
|
||||
mockCadvisor.AssertExpectations(t)
|
||||
}
|
||||
|
||||
@ -942,15 +883,6 @@ func TestGetContainerInfoWithoutCadvisor(t *testing.T) {
|
||||
if stats == nil {
|
||||
return
|
||||
}
|
||||
if stats.StatsPercentiles.MaxMemoryUsage != 0 {
|
||||
t.Errorf("MaxMemoryUsage is %v even if there's no cadvisor", stats.StatsPercentiles.MaxMemoryUsage)
|
||||
}
|
||||
if len(stats.StatsPercentiles.CpuUsagePercentiles) > 0 {
|
||||
t.Errorf("CPU usage percentiles is not empty (%+v) even if there's no cadvisor", stats.StatsPercentiles.CpuUsagePercentiles)
|
||||
}
|
||||
if len(stats.StatsPercentiles.MemoryUsagePercentiles) > 0 {
|
||||
t.Errorf("Memory usage percentiles is not empty (%+v) even if there's no cadvisor", stats.StatsPercentiles.MemoryUsagePercentiles)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetContainerInfoWhenCadvisorFailed(t *testing.T) {
|
||||
|
@ -166,21 +166,7 @@ func TestPodInfo(t *testing.T) {
|
||||
|
||||
func TestContainerInfo(t *testing.T) {
|
||||
fw := newServerTest()
|
||||
expectedInfo := &info.ContainerInfo{
|
||||
StatsPercentiles: &info.ContainerStatsPercentiles{
|
||||
MaxMemoryUsage: 1024001,
|
||||
CpuUsagePercentiles: []info.Percentile{
|
||||
{50, 150},
|
||||
{80, 180},
|
||||
{90, 190},
|
||||
},
|
||||
MemoryUsagePercentiles: []info.Percentile{
|
||||
{50, 150},
|
||||
{80, 180},
|
||||
{90, 190},
|
||||
},
|
||||
},
|
||||
}
|
||||
expectedInfo := &info.ContainerInfo{}
|
||||
expectedPodID := "somepod"
|
||||
expectedContainerName := "goodcontainer"
|
||||
fw.fakeKubelet.containerInfoFunc = func(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||
@ -207,21 +193,7 @@ func TestContainerInfo(t *testing.T) {
|
||||
|
||||
func TestRootInfo(t *testing.T) {
|
||||
fw := newServerTest()
|
||||
expectedInfo := &info.ContainerInfo{
|
||||
StatsPercentiles: &info.ContainerStatsPercentiles{
|
||||
MaxMemoryUsage: 1024001,
|
||||
CpuUsagePercentiles: []info.Percentile{
|
||||
{50, 150},
|
||||
{80, 180},
|
||||
{90, 190},
|
||||
},
|
||||
MemoryUsagePercentiles: []info.Percentile{
|
||||
{50, 150},
|
||||
{80, 180},
|
||||
{90, 190},
|
||||
},
|
||||
},
|
||||
}
|
||||
expectedInfo := &info.ContainerInfo{}
|
||||
fw.fakeKubelet.rootInfoFunc = func(req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||
return expectedInfo, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user