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
51094926
Commit
51094926
authored
Dec 05, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17752 from yujuhong/docker_health
Auto commit by PR queue bot
parents
ab35fff6
26b6b18f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
42 deletions
+0
-42
server.go
pkg/kubelet/server.go
+0
-19
server_test.go
pkg/kubelet/server_test.go
+0
-23
No files found.
pkg/kubelet/server.go
View file @
51094926
...
@@ -48,7 +48,6 @@ import (
...
@@ -48,7 +48,6 @@ import (
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/healthz"
"k8s.io/kubernetes/pkg/httplog"
"k8s.io/kubernetes/pkg/httplog"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
"k8s.io/kubernetes/pkg/kubelet/portforward"
"k8s.io/kubernetes/pkg/kubelet/portforward"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util"
...
@@ -141,7 +140,6 @@ type AuthInterface interface {
...
@@ -141,7 +140,6 @@ type AuthInterface interface {
// 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
)
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
...
@@ -212,7 +210,6 @@ func (s *Server) InstallAuthFilter() {
...
@@ -212,7 +210,6 @@ func (s *Server) InstallAuthFilter() {
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
healthz
.
InstallHandler
(
s
.
restfulCont
,
healthz
.
InstallHandler
(
s
.
restfulCont
,
healthz
.
PingHealthz
,
healthz
.
PingHealthz
,
healthz
.
NamedCheck
(
"docker"
,
s
.
dockerHealthCheck
),
healthz
.
NamedCheck
(
"syncloop"
,
s
.
syncLoopHealthCheck
),
healthz
.
NamedCheck
(
"syncloop"
,
s
.
syncLoopHealthCheck
),
)
)
var
ws
*
restful
.
WebService
var
ws
*
restful
.
WebService
...
@@ -367,22 +364,6 @@ func (s *Server) error(w http.ResponseWriter, err error) {
...
@@ -367,22 +364,6 @@ func (s *Server) error(w http.ResponseWriter, err error) {
http
.
Error
(
w
,
msg
,
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
msg
,
http
.
StatusInternalServerError
)
}
}
func
(
s
*
Server
)
dockerHealthCheck
(
req
*
http
.
Request
)
error
{
version
,
err
:=
s
.
host
.
GetContainerRuntimeVersion
()
if
err
!=
nil
{
return
errors
.
New
(
"unknown Docker version"
)
}
// Verify the docker version.
result
,
err
:=
version
.
Compare
(
dockertools
.
MinimumDockerAPIVersion
)
if
err
!=
nil
{
return
err
}
if
result
<
0
{
return
fmt
.
Errorf
(
"Docker version is too old: %q"
,
version
.
String
())
}
return
nil
}
// Checks if kubelet's sync loop that updates containers is working.
// Checks if kubelet's sync loop that updates containers is working.
func
(
s
*
Server
)
syncLoopHealthCheck
(
req
*
http
.
Request
)
error
{
func
(
s
*
Server
)
syncLoopHealthCheck
(
req
*
http
.
Request
)
error
{
duration
:=
s
.
host
.
ResyncInterval
()
*
2
duration
:=
s
.
host
.
ResyncInterval
()
*
2
...
...
pkg/kubelet/server_test.go
View file @
51094926
...
@@ -38,8 +38,6 @@ import (
...
@@ -38,8 +38,6 @@ import (
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"
"k8s.io/kubernetes/pkg/auth/user"
"k8s.io/kubernetes/pkg/auth/user"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/httpstream"
"k8s.io/kubernetes/pkg/util/httpstream"
...
@@ -56,7 +54,6 @@ type fakeKubelet struct {
...
@@ -56,7 +54,6 @@ type fakeKubelet struct {
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
)
runFunc
func
(
podFullName
string
,
uid
types
.
UID
,
containerName
string
,
cmd
[]
string
)
([]
byte
,
error
)
runFunc
func
(
podFullName
string
,
uid
types
.
UID
,
containerName
string
,
cmd
[]
string
)
([]
byte
,
error
)
containerVersionFunc
func
()
(
kubecontainer
.
Version
,
error
)
execFunc
func
(
pod
string
,
uid
types
.
UID
,
container
string
,
cmd
[]
string
,
in
io
.
Reader
,
out
,
err
io
.
WriteCloser
,
tty
bool
)
error
execFunc
func
(
pod
string
,
uid
types
.
UID
,
container
string
,
cmd
[]
string
,
in
io
.
Reader
,
out
,
err
io
.
WriteCloser
,
tty
bool
)
error
attachFunc
func
(
pod
string
,
uid
types
.
UID
,
container
string
,
in
io
.
Reader
,
out
,
err
io
.
WriteCloser
,
tty
bool
)
error
attachFunc
func
(
pod
string
,
uid
types
.
UID
,
container
string
,
in
io
.
Reader
,
out
,
err
io
.
WriteCloser
,
tty
bool
)
error
portForwardFunc
func
(
name
string
,
uid
types
.
UID
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
portForwardFunc
func
(
name
string
,
uid
types
.
UID
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
...
@@ -87,10 +84,6 @@ func (fk *fakeKubelet) GetRawContainerInfo(containerName string, req *cadvisorap
...
@@ -87,10 +84,6 @@ func (fk *fakeKubelet) GetRawContainerInfo(containerName string, req *cadvisorap
return
fk
.
rawInfoFunc
(
req
)
return
fk
.
rawInfoFunc
(
req
)
}
}
func
(
fk
*
fakeKubelet
)
GetContainerRuntimeVersion
()
(
kubecontainer
.
Version
,
error
)
{
return
fk
.
containerVersionFunc
()
}
func
(
fk
*
fakeKubelet
)
GetCachedMachineInfo
()
(
*
cadvisorapi
.
MachineInfo
,
error
)
{
func
(
fk
*
fakeKubelet
)
GetCachedMachineInfo
()
(
*
cadvisorapi
.
MachineInfo
,
error
)
{
return
fk
.
machineInfoFunc
()
return
fk
.
machineInfoFunc
()
}
}
...
@@ -161,9 +154,6 @@ type serverTestFramework struct {
...
@@ -161,9 +154,6 @@ type serverTestFramework struct {
func
newServerTest
()
*
serverTestFramework
{
func
newServerTest
()
*
serverTestFramework
{
fw
:=
&
serverTestFramework
{}
fw
:=
&
serverTestFramework
{}
fw
.
fakeKubelet
=
&
fakeKubelet
{
fw
.
fakeKubelet
=
&
fakeKubelet
{
containerVersionFunc
:
func
()
(
kubecontainer
.
Version
,
error
)
{
return
dockertools
.
NewVersion
(
"1.18"
)
},
hostnameFunc
:
func
()
string
{
hostnameFunc
:
func
()
string
{
return
"127.0.0.1"
return
"127.0.0.1"
},
},
...
@@ -505,9 +495,6 @@ func TestServeRunInContainerWithUID(t *testing.T) {
...
@@ -505,9 +495,6 @@ func TestServeRunInContainerWithUID(t *testing.T) {
func
TestHealthCheck
(
t
*
testing
.
T
)
{
func
TestHealthCheck
(
t
*
testing
.
T
)
{
fw
:=
newServerTest
()
fw
:=
newServerTest
()
fw
.
fakeKubelet
.
containerVersionFunc
=
func
()
(
kubecontainer
.
Version
,
error
)
{
return
dockertools
.
NewVersion
(
"1.18"
)
}
fw
.
fakeKubelet
.
hostnameFunc
=
func
()
string
{
fw
.
fakeKubelet
.
hostnameFunc
=
func
()
string
{
return
"127.0.0.1"
return
"127.0.0.1"
}
}
...
@@ -520,13 +507,6 @@ func TestHealthCheck(t *testing.T) {
...
@@ -520,13 +507,6 @@ func TestHealthCheck(t *testing.T) {
return
"fake"
return
"fake"
}
}
assertHealthIsOk
(
t
,
fw
.
testHTTPServer
.
URL
+
"/healthz"
)
assertHealthIsOk
(
t
,
fw
.
testHTTPServer
.
URL
+
"/healthz"
)
//Test with old container runtime version
fw
.
fakeKubelet
.
containerVersionFunc
=
func
()
(
kubecontainer
.
Version
,
error
)
{
return
dockertools
.
NewVersion
(
"1.16"
)
}
assertHealthFails
(
t
,
fw
.
testHTTPServer
.
URL
+
"/healthz"
,
http
.
StatusInternalServerError
)
}
}
func
assertHealthFails
(
t
*
testing
.
T
,
httpURL
string
,
expectedErrorCode
int
)
{
func
assertHealthFails
(
t
*
testing
.
T
,
httpURL
string
,
expectedErrorCode
int
)
{
...
@@ -714,9 +694,6 @@ func TestAuthorizationSuccess(t *testing.T) {
...
@@ -714,9 +694,6 @@ func TestAuthorizationSuccess(t *testing.T) {
func
TestSyncLoopCheck
(
t
*
testing
.
T
)
{
func
TestSyncLoopCheck
(
t
*
testing
.
T
)
{
fw
:=
newServerTest
()
fw
:=
newServerTest
()
fw
.
fakeKubelet
.
containerVersionFunc
=
func
()
(
kubecontainer
.
Version
,
error
)
{
return
dockertools
.
NewVersion
(
"1.18"
)
}
fw
.
fakeKubelet
.
hostnameFunc
=
func
()
string
{
fw
.
fakeKubelet
.
hostnameFunc
=
func
()
string
{
return
"127.0.0.1"
return
"127.0.0.1"
}
}
...
...
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