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
78f66a6c
Commit
78f66a6c
authored
Feb 04, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check Docker version in Kubelet /healthz handler
parent
0b801a91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
kubelet.go
pkg/kubelet/kubelet.go
+17
-0
server.go
pkg/kubelet/server.go
+21
-2
server_test.go
pkg/kubelet/server_test.go
+5
-0
No files found.
pkg/kubelet/kubelet.go
View file @
78f66a6c
...
@@ -1361,6 +1361,23 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
...
@@ -1361,6 +1361,23 @@ func (kl *Kubelet) syncLoop(updates <-chan PodUpdate, handler SyncHandler) {
}
}
}
}
// Returns Docker version for this Kubelet.
func
(
kl
*
Kubelet
)
GetDockerVersion
()
(
string
,
error
)
{
if
kl
.
dockerClient
==
nil
{
return
""
,
fmt
.
Errorf
(
"No Docker client"
)
}
env
,
err
:=
kl
.
dockerClient
.
Version
()
if
err
!=
nil
{
return
""
,
err
}
for
_
,
entry
:=
range
*
env
{
if
strings
.
HasPrefix
(
entry
,
"Version="
)
{
return
strings
.
Split
(
entry
,
"="
)[
1
],
nil
}
}
return
""
,
fmt
.
Errorf
(
"Docker version unknown"
)
}
// GetKubeletContainerLogs returns logs from the container
// GetKubeletContainerLogs returns logs from the container
// The second parameter of GetPodStatus and FindPodContainer methods represents pod UUID, which is allowed to be blank
// The second parameter of GetPodStatus and FindPodContainer methods represents pod UUID, which is allowed to be blank
// TODO: this method is returning logs of random container attempts, when it should be returning the most recent attempt
// TODO: this method is returning logs of random container attempts, when it should be returning the most recent attempt
...
...
pkg/kubelet/server.go
View file @
78f66a6c
...
@@ -31,7 +31,6 @@ import (
...
@@ -31,7 +31,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
...
@@ -64,6 +63,7 @@ func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint,
...
@@ -64,6 +63,7 @@ func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint,
type
HostInterface
interface
{
type
HostInterface
interface
{
GetContainerInfo
(
podFullName
string
,
uid
types
.
UID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
GetContainerInfo
(
podFullName
string
,
uid
types
.
UID
,
containerName
string
,
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
GetRootInfo
(
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
GetRootInfo
(
req
*
info
.
ContainerInfoRequest
)
(
*
info
.
ContainerInfo
,
error
)
GetDockerVersion
()
(
string
,
error
)
GetMachineInfo
()
(
*
info
.
MachineInfo
,
error
)
GetMachineInfo
()
(
*
info
.
MachineInfo
,
error
)
GetBoundPods
()
([]
api
.
BoundPod
,
error
)
GetBoundPods
()
([]
api
.
BoundPod
,
error
)
GetPodByName
(
namespace
,
name
string
)
(
*
api
.
BoundPod
,
bool
)
GetPodByName
(
namespace
,
name
string
)
(
*
api
.
BoundPod
,
bool
)
...
@@ -88,7 +88,7 @@ func NewServer(host HostInterface, enableDebuggingHandlers bool) Server {
...
@@ -88,7 +88,7 @@ func NewServer(host HostInterface, enableDebuggingHandlers bool) Server {
// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
healthz
.
InstallHandler
(
s
.
mux
)
s
.
mux
.
HandleFunc
(
"/healthz"
,
s
.
handleHealthz
)
s
.
mux
.
HandleFunc
(
"/podInfo"
,
s
.
handlePodInfoOld
)
s
.
mux
.
HandleFunc
(
"/podInfo"
,
s
.
handlePodInfoOld
)
s
.
mux
.
HandleFunc
(
"/api/v1beta1/podInfo"
,
s
.
handlePodInfoVersioned
)
s
.
mux
.
HandleFunc
(
"/api/v1beta1/podInfo"
,
s
.
handlePodInfoVersioned
)
s
.
mux
.
HandleFunc
(
"/boundPods"
,
s
.
handleBoundPods
)
s
.
mux
.
HandleFunc
(
"/boundPods"
,
s
.
handleBoundPods
)
...
@@ -109,6 +109,25 @@ func (s *Server) error(w http.ResponseWriter, err error) {
...
@@ -109,6 +109,25 @@ func (s *Server) error(w http.ResponseWriter, err error) {
http
.
Error
(
w
,
fmt
.
Sprintf
(
"Internal Error: %v"
,
err
),
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
fmt
.
Sprintf
(
"Internal Error: %v"
,
err
),
http
.
StatusInternalServerError
)
}
}
// handleHealthz handles /healthz request and checks Docker version
func
(
s
*
Server
)
handleHealthz
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
version
,
err
:=
s
.
host
.
GetDockerVersion
()
if
err
!=
nil
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
w
.
Write
([]
byte
(
"unknown Docker version"
))
return
}
const
minDockerVersion
=
"1.3.0"
if
version
<
minDockerVersion
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
msg
:=
"Docker version is too old ("
+
version
+
")"
w
.
Write
([]
byte
(
msg
))
return
;
}
w
.
WriteHeader
(
http
.
StatusOK
)
w
.
Write
([]
byte
(
"ok"
))
}
// handleContainerLogs handles containerLogs request against the Kubelet
// handleContainerLogs handles containerLogs request against the Kubelet
func
(
s
*
Server
)
handleContainerLogs
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
s
*
Server
)
handleContainerLogs
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
defer
req
.
Body
.
Close
()
defer
req
.
Body
.
Close
()
...
...
pkg/kubelet/server_test.go
View file @
78f66a6c
...
@@ -42,6 +42,7 @@ type fakeKubelet struct {
...
@@ -42,6 +42,7 @@ type fakeKubelet struct {
boundPodsFunc
func
()
([]
api
.
BoundPod
,
error
)
boundPodsFunc
func
()
([]
api
.
BoundPod
,
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
)
dockerVersionFunc
func
()
(
string
,
error
)
containerLogsFunc
func
(
podFullName
,
containerName
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
error
containerLogsFunc
func
(
podFullName
,
containerName
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
error
}
}
...
@@ -61,6 +62,10 @@ func (fk *fakeKubelet) GetRootInfo(req *info.ContainerInfoRequest) (*info.Contai
...
@@ -61,6 +62,10 @@ func (fk *fakeKubelet) GetRootInfo(req *info.ContainerInfoRequest) (*info.Contai
return
fk
.
rootInfoFunc
(
req
)
return
fk
.
rootInfoFunc
(
req
)
}
}
func
(
fk
*
fakeKubelet
)
GetDockerVersion
()
(
string
,
error
)
{
return
fk
.
dockerVersionFunc
()
}
func
(
fk
*
fakeKubelet
)
GetMachineInfo
()
(
*
info
.
MachineInfo
,
error
)
{
func
(
fk
*
fakeKubelet
)
GetMachineInfo
()
(
*
info
.
MachineInfo
,
error
)
{
return
fk
.
machineInfoFunc
()
return
fk
.
machineInfoFunc
()
}
}
...
...
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