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
08f10226
Commit
08f10226
authored
Apr 08, 2024
by
Brad Davidson
Committed by
Brad Davidson
Apr 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't log 'apiserver disabled' error sent by etcd-only nodes
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
7d9abc9f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
router.go
pkg/server/router.go
+2
-2
apierrors.go
pkg/util/apierrors.go
+4
-3
No files found.
pkg/server/router.go
View file @
08f10226
...
@@ -104,14 +104,14 @@ func apiserver(runtime *config.ControlRuntime) http.Handler {
...
@@ -104,14 +104,14 @@ func apiserver(runtime *config.ControlRuntime) http.Handler {
if
runtime
!=
nil
&&
runtime
.
APIServer
!=
nil
{
if
runtime
!=
nil
&&
runtime
.
APIServer
!=
nil
{
runtime
.
APIServer
.
ServeHTTP
(
resp
,
req
)
runtime
.
APIServer
.
ServeHTTP
(
resp
,
req
)
}
else
{
}
else
{
util
.
SendError
(
util
.
ErrNotReady
,
resp
,
req
,
http
.
StatusServiceUnavailable
)
util
.
SendError
(
util
.
Err
API
NotReady
,
resp
,
req
,
http
.
StatusServiceUnavailable
)
}
}
})
})
}
}
func
apiserverDisabled
()
http
.
Handler
{
func
apiserverDisabled
()
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
resp
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
return
http
.
HandlerFunc
(
func
(
resp
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
util
.
SendError
(
errors
.
New
(
"apiserver disabled"
)
,
resp
,
req
,
http
.
StatusServiceUnavailable
)
util
.
SendError
(
util
.
ErrAPIDisabled
,
resp
,
req
,
http
.
StatusServiceUnavailable
)
})
})
}
}
...
...
pkg/util/apierrors.go
View file @
08f10226
...
@@ -15,7 +15,8 @@ import (
...
@@ -15,7 +15,8 @@ import (
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters"
)
)
var
ErrNotReady
=
errors
.
New
(
"apiserver not ready"
)
var
ErrAPINotReady
=
errors
.
New
(
"apiserver not ready"
)
var
ErrAPIDisabled
=
errors
.
New
(
"apiserver disabled"
)
// SendErrorWithID sends and logs a random error ID so that logs can be correlated
// SendErrorWithID sends and logs a random error ID so that logs can be correlated
// between the REST API (which does not provide any detailed error output, to avoid
// between the REST API (which does not provide any detailed error output, to avoid
...
@@ -36,8 +37,8 @@ func SendError(err error, resp http.ResponseWriter, req *http.Request, status ..
...
@@ -36,8 +37,8 @@ func SendError(err error, resp http.ResponseWriter, req *http.Request, status ..
code
=
http
.
StatusInternalServerError
code
=
http
.
StatusInternalServerError
}
}
// Don't log "apiserver not ready" errors, they are frequent during startup
// Don't log "apiserver not ready"
or "apiserver disabled"
errors, they are frequent during startup
if
!
errors
.
Is
(
err
,
Err
NotReady
)
{
if
!
errors
.
Is
(
err
,
Err
APINotReady
)
&&
!
errors
.
Is
(
err
,
ErrAPIDisabled
)
{
logrus
.
Errorf
(
"Sending HTTP %d response to %s: %v"
,
code
,
req
.
RemoteAddr
,
err
)
logrus
.
Errorf
(
"Sending HTTP %d response to %s: %v"
,
code
,
req
.
RemoteAddr
,
err
)
}
}
...
...
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