mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
gofmt -r "GetContainerStats->GetContainerInfo"
This commit is contained in:
parent
8c573ee727
commit
30bc2af9f1
@ -850,7 +850,7 @@ func (kl *Kubelet) statsFromContainerPath(containerPath string, req *info.Contai
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerStats returns stats (from Cadvisor) for a container.
|
// GetContainerStats returns stats (from Cadvisor) for a container.
|
||||||
func (kl *Kubelet) GetContainerStats(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
func (kl *Kubelet) GetContainerInfo(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||||
if kl.CadvisorClient == nil {
|
if kl.CadvisorClient == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ type KubeletServer struct {
|
|||||||
// kubeletInterface contains all the kubelet methods required by the server.
|
// kubeletInterface contains all the kubelet methods required by the server.
|
||||||
// For testablitiy.
|
// For testablitiy.
|
||||||
type kubeletInterface interface {
|
type kubeletInterface interface {
|
||||||
GetContainerStats(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
GetContainerInfo(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||||
GetMachineStats(req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
GetMachineStats(req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||||
GetPodInfo(name string) (api.PodInfo, error)
|
GetPodInfo(name string) (api.PodInfo, error)
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ func (s *KubeletServer) serveStats(w http.ResponseWriter, req *http.Request) {
|
|||||||
// TODO(monnand) Implement this
|
// TODO(monnand) Implement this
|
||||||
errors.New("pod level status currently unimplemented")
|
errors.New("pod level status currently unimplemented")
|
||||||
case 3:
|
case 3:
|
||||||
stats, err = s.Kubelet.GetContainerStats(components[1], components[2], &query)
|
stats, err = s.Kubelet.GetContainerInfo(components[1], components[2], &query)
|
||||||
default:
|
default:
|
||||||
http.Error(w, "unknown resource.", http.StatusNotFound)
|
http.Error(w, "unknown resource.", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
@ -42,7 +42,7 @@ func (fk *fakeKubelet) GetPodInfo(name string) (api.PodInfo, error) {
|
|||||||
return fk.infoFunc(name)
|
return fk.infoFunc(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) GetContainerStats(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
func (fk *fakeKubelet) GetContainerInfo(podID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||||
return fk.containerStatsFunc(podID, containerName, req)
|
return fk.containerStatsFunc(podID, containerName, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,7 +988,7 @@ func TestGetContainerStats(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
stats, err := kubelet.GetContainerStats("qux", "foo", req)
|
stats, err := kubelet.GetContainerInfo("qux", "foo", req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -1054,7 +1054,7 @@ func TestGetContainerStatsWithoutCadvisor(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
stats, _ := kubelet.GetContainerStats("qux", "foo", nil)
|
stats, _ := kubelet.GetContainerInfo("qux", "foo", nil)
|
||||||
// When there's no cAdvisor, the stats should be either nil or empty
|
// When there's no cAdvisor, the stats should be either nil or empty
|
||||||
if stats == nil {
|
if stats == nil {
|
||||||
return
|
return
|
||||||
@ -1092,7 +1092,7 @@ func TestGetContainerStatsWhenCadvisorFailed(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
stats, err := kubelet.GetContainerStats("qux", "foo", req)
|
stats, err := kubelet.GetContainerInfo("qux", "foo", req)
|
||||||
if stats != nil {
|
if stats != nil {
|
||||||
t.Errorf("non-nil stats on error")
|
t.Errorf("non-nil stats on error")
|
||||||
}
|
}
|
||||||
@ -1113,7 +1113,7 @@ func TestGetContainerStatsOnNonExistContainer(t *testing.T) {
|
|||||||
kubelet.CadvisorClient = mockCadvisor
|
kubelet.CadvisorClient = mockCadvisor
|
||||||
fakeDocker.containerList = []docker.APIContainers{}
|
fakeDocker.containerList = []docker.APIContainers{}
|
||||||
|
|
||||||
stats, _ := kubelet.GetContainerStats("qux", "foo", nil)
|
stats, _ := kubelet.GetContainerInfo("qux", "foo", nil)
|
||||||
if stats != nil {
|
if stats != nil {
|
||||||
t.Errorf("non-nil stats on non exist container")
|
t.Errorf("non-nil stats on non exist container")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user