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
b7b4b84a
Unverified
Commit
b7b4b84a
authored
Jun 09, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add healthz check to ensure logging is not blocked
parent
f29c1301
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
2 deletions
+40
-2
server.go
pkg/kubelet/server/server.go
+1
-0
config.go
staging/src/k8s.io/apiserver/pkg/server/config.go
+1
-1
config_test.go
staging/src/k8s.io/apiserver/pkg/server/config_test.go
+2
-0
BUILD
staging/src/k8s.io/apiserver/pkg/server/healthz/BUILD
+4
-1
healthz.go
staging/src/k8s.io/apiserver/pkg/server/healthz/healthz.go
+32
-0
No files found.
pkg/kubelet/server/server.go
View file @
b7b4b84a
...
@@ -256,6 +256,7 @@ func (s *Server) InstallAuthFilter() {
...
@@ -256,6 +256,7 @@ 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
.
LogHealthz
,
healthz
.
NamedCheck
(
"syncloop"
,
s
.
syncLoopHealthCheck
),
healthz
.
NamedCheck
(
"syncloop"
,
s
.
syncLoopHealthCheck
),
)
)
ws
:=
new
(
restful
.
WebService
)
ws
:=
new
(
restful
.
WebService
)
...
...
staging/src/k8s.io/apiserver/pkg/server/config.go
View file @
b7b4b84a
...
@@ -255,7 +255,7 @@ func NewConfig(codecs serializer.CodecFactory) *Config {
...
@@ -255,7 +255,7 @@ func NewConfig(codecs serializer.CodecFactory) *Config {
HandlerChainWaitGroup
:
new
(
utilwaitgroup
.
SafeWaitGroup
),
HandlerChainWaitGroup
:
new
(
utilwaitgroup
.
SafeWaitGroup
),
LegacyAPIGroupPrefixes
:
sets
.
NewString
(
DefaultLegacyAPIPrefix
),
LegacyAPIGroupPrefixes
:
sets
.
NewString
(
DefaultLegacyAPIPrefix
),
DisabledPostStartHooks
:
sets
.
NewString
(),
DisabledPostStartHooks
:
sets
.
NewString
(),
HealthzChecks
:
[]
healthz
.
HealthzChecker
{
healthz
.
PingHealthz
},
HealthzChecks
:
[]
healthz
.
HealthzChecker
{
healthz
.
PingHealthz
,
healthz
.
LogHealthz
},
EnableIndex
:
true
,
EnableIndex
:
true
,
EnableDiscovery
:
true
,
EnableDiscovery
:
true
,
EnableProfiling
:
true
,
EnableProfiling
:
true
,
...
...
staging/src/k8s.io/apiserver/pkg/server/config_test.go
View file @
b7b4b84a
...
@@ -101,6 +101,7 @@ func TestNewWithDelegate(t *testing.T) {
...
@@ -101,6 +101,7 @@ func TestNewWithDelegate(t *testing.T) {
"/foo",
"/foo",
"/healthz",
"/healthz",
"/healthz/delegate-health",
"/healthz/delegate-health",
"/healthz/log",
"/healthz/ping",
"/healthz/ping",
"/healthz/poststarthook/delegate-post-start-hook",
"/healthz/poststarthook/delegate-post-start-hook",
"/healthz/poststarthook/generic-apiserver-start-informers",
"/healthz/poststarthook/generic-apiserver-start-informers",
...
@@ -111,6 +112,7 @@ func TestNewWithDelegate(t *testing.T) {
...
@@ -111,6 +112,7 @@ func TestNewWithDelegate(t *testing.T) {
]
]
}`
,
t
)
}`
,
t
)
checkPath
(
server
.
URL
+
"/healthz"
,
http
.
StatusInternalServerError
,
`[+]ping ok
checkPath
(
server
.
URL
+
"/healthz"
,
http
.
StatusInternalServerError
,
`[+]ping ok
[+]log ok
[-]wrapping-health failed: reason withheld
[-]wrapping-health failed: reason withheld
[-]delegate-health failed: reason withheld
[-]delegate-health failed: reason withheld
[+]poststarthook/generic-apiserver-start-informers ok
[+]poststarthook/generic-apiserver-start-informers ok
...
...
staging/src/k8s.io/apiserver/pkg/server/healthz/BUILD
View file @
b7b4b84a
...
@@ -20,7 +20,10 @@ go_library(
...
@@ -20,7 +20,10 @@ go_library(
],
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/healthz",
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/server/healthz",
importpath = "k8s.io/apiserver/pkg/server/healthz",
importpath = "k8s.io/apiserver/pkg/server/healthz",
deps = ["//vendor/github.com/golang/glog:go_default_library"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
],
)
)
filegroup(
filegroup(
...
...
staging/src/k8s.io/apiserver/pkg/server/healthz/healthz.go
View file @
b7b4b84a
...
@@ -22,8 +22,12 @@ import (
...
@@ -22,8 +22,12 @@ import (
"net/http"
"net/http"
"strings"
"strings"
"sync"
"sync"
"sync/atomic"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/apimachinery/pkg/util/wait"
)
)
// HealthzChecker is a named healthz checker.
// HealthzChecker is a named healthz checker.
...
@@ -56,6 +60,34 @@ func (ping) Check(_ *http.Request) error {
...
@@ -56,6 +60,34 @@ func (ping) Check(_ *http.Request) error {
return
nil
return
nil
}
}
// LogHealthz returns true if logging is not blocked
var
LogHealthz
HealthzChecker
=
&
log
{}
type
log
struct
{
startOnce
sync
.
Once
lastVerified
atomic
.
Value
}
func
(
l
*
log
)
Name
()
string
{
return
"log"
}
func
(
l
*
log
)
Check
(
_
*
http
.
Request
)
error
{
l
.
startOnce
.
Do
(
func
()
{
l
.
lastVerified
.
Store
(
time
.
Now
())
go
wait
.
Forever
(
func
()
{
glog
.
Flush
()
l
.
lastVerified
.
Store
(
time
.
Now
())
},
time
.
Minute
)
})
lastVerified
:=
l
.
lastVerified
.
Load
()
.
(
time
.
Time
)
if
time
.
Since
(
lastVerified
)
<
(
2
*
time
.
Minute
)
{
return
nil
}
return
fmt
.
Errorf
(
"logging blocked"
)
}
// NamedCheck returns a healthz checker for the given name and function.
// NamedCheck returns a healthz checker for the given name and function.
func
NamedCheck
(
name
string
,
check
func
(
r
*
http
.
Request
)
error
)
HealthzChecker
{
func
NamedCheck
(
name
string
,
check
func
(
r
*
http
.
Request
)
error
)
HealthzChecker
{
return
&
healthzCheck
{
name
,
check
}
return
&
healthzCheck
{
name
,
check
}
...
...
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