Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
30bc2af9
Commit
30bc2af9
authored
Jul 14, 2014
by
Nan Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt -r "GetContainerStats->GetContainerInfo"
parent
8c573ee7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
kubelet.go
pkg/kubelet/kubelet.go
+1
-1
kubelet_server.go
pkg/kubelet/kubelet_server.go
+2
-2
kubelet_server_test.go
pkg/kubelet/kubelet_server_test.go
+1
-1
kubelet_test.go
pkg/kubelet/kubelet_test.go
+4
-4
No files found.
pkg/kubelet/kubelet.go
View file @
30bc2af9
...
@@ -850,7 +850,7 @@ func (kl *Kubelet) statsFromContainerPath(containerPath string, req *info.Contai
...
@@ -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
)
GetContainer
Stats
(
podID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
{
func
(
kl
*
Kubelet
)
GetContainer
Info
(
podID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
{
if
kl
.
CadvisorClient
==
nil
{
if
kl
.
CadvisorClient
==
nil
{
return
nil
,
nil
return
nil
,
nil
}
}
...
...
pkg/kubelet/kubelet_server.go
View file @
30bc2af9
...
@@ -43,7 +43,7 @@ type KubeletServer struct {
...
@@ -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
{
GetContainer
Stats
(
podID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
GetContainer
Info
(
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) {
...
@@ -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
.
GetContainer
Stats
(
components
[
1
],
components
[
2
],
&
query
)
stats
,
err
=
s
.
Kubelet
.
GetContainer
Info
(
components
[
1
],
components
[
2
],
&
query
)
default
:
default
:
http
.
Error
(
w
,
"unknown resource."
,
http
.
StatusNotFound
)
http
.
Error
(
w
,
"unknown resource."
,
http
.
StatusNotFound
)
return
return
...
...
pkg/kubelet/kubelet_server_test.go
View file @
30bc2af9
...
@@ -42,7 +42,7 @@ func (fk *fakeKubelet) GetPodInfo(name string) (api.PodInfo, error) {
...
@@ -42,7 +42,7 @@ func (fk *fakeKubelet) GetPodInfo(name string) (api.PodInfo, error) {
return
fk
.
infoFunc
(
name
)
return
fk
.
infoFunc
(
name
)
}
}
func
(
fk
*
fakeKubelet
)
GetContainer
Stats
(
podID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
{
func
(
fk
*
fakeKubelet
)
GetContainer
Info
(
podID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
{
return
fk
.
containerStatsFunc
(
podID
,
containerName
,
req
)
return
fk
.
containerStatsFunc
(
podID
,
containerName
,
req
)
}
}
...
...
pkg/kubelet/kubelet_test.go
View file @
30bc2af9
...
@@ -988,7 +988,7 @@ func TestGetContainerStats(t *testing.T) {
...
@@ -988,7 +988,7 @@ func TestGetContainerStats(t *testing.T) {
},
},
}
}
stats
,
err
:=
kubelet
.
GetContainer
Stats
(
"qux"
,
"foo"
,
req
)
stats
,
err
:=
kubelet
.
GetContainer
Info
(
"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) {
...
@@ -1054,7 +1054,7 @@ func TestGetContainerStatsWithoutCadvisor(t *testing.T) {
},
},
}
}
stats
,
_
:=
kubelet
.
GetContainer
Stats
(
"qux"
,
"foo"
,
nil
)
stats
,
_
:=
kubelet
.
GetContainer
Info
(
"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) {
...
@@ -1092,7 +1092,7 @@ func TestGetContainerStatsWhenCadvisorFailed(t *testing.T) {
},
},
}
}
stats
,
err
:=
kubelet
.
GetContainer
Stats
(
"qux"
,
"foo"
,
req
)
stats
,
err
:=
kubelet
.
GetContainer
Info
(
"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) {
...
@@ -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
.
GetContainer
Stats
(
"qux"
,
"foo"
,
nil
)
stats
,
_
:=
kubelet
.
GetContainer
Info
(
"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"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment