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
db87da1c
Unverified
Commit
db87da1c
authored
Mar 06, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74959 from deads2k/hook-reg
track poststarthook registration stacks for debugging
parents
e15ebcd6
b75e93d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
hooks.go
staging/src/k8s.io/apiserver/pkg/server/hooks.go
+8
-3
No files found.
staging/src/k8s.io/apiserver/pkg/server/hooks.go
View file @
db87da1c
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"net/http"
"net/http"
"runtime/debug"
"k8s.io/klog"
"k8s.io/klog"
...
@@ -58,6 +59,9 @@ type PostStartHookProvider interface {
...
@@ -58,6 +59,9 @@ type PostStartHookProvider interface {
type
postStartHookEntry
struct
{
type
postStartHookEntry
struct
{
hook
PostStartHookFunc
hook
PostStartHookFunc
// originatingStack holds the stack that registered postStartHooks. This allows us to show a more helpful message
// for duplicate registration.
originatingStack
string
// done will be closed when the postHook is finished
// done will be closed when the postHook is finished
done
chan
struct
{}
done
chan
struct
{}
...
@@ -85,8 +89,9 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
...
@@ -85,8 +89,9 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
if
s
.
postStartHooksCalled
{
if
s
.
postStartHooksCalled
{
return
fmt
.
Errorf
(
"unable to add %q because PostStartHooks have already been called"
,
name
)
return
fmt
.
Errorf
(
"unable to add %q because PostStartHooks have already been called"
,
name
)
}
}
if
_
,
exists
:=
s
.
postStartHooks
[
name
];
exists
{
if
postStartHook
,
exists
:=
s
.
postStartHooks
[
name
];
exists
{
return
fmt
.
Errorf
(
"unable to add %q because it is already registered"
,
name
)
// this is programmer error, but it can be hard to debug
return
fmt
.
Errorf
(
"unable to add %q because it was already registered by: %s"
,
name
,
postStartHook
.
originatingStack
)
}
}
// done is closed when the poststarthook is finished. This is used by the health check to be able to indicate
// done is closed when the poststarthook is finished. This is used by the health check to be able to indicate
...
@@ -95,7 +100,7 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
...
@@ -95,7 +100,7 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
if
err
:=
s
.
AddHealthzChecks
(
postStartHookHealthz
{
name
:
"poststarthook/"
+
name
,
done
:
done
});
err
!=
nil
{
if
err
:=
s
.
AddHealthzChecks
(
postStartHookHealthz
{
name
:
"poststarthook/"
+
name
,
done
:
done
});
err
!=
nil
{
return
err
return
err
}
}
s
.
postStartHooks
[
name
]
=
postStartHookEntry
{
hook
:
hook
,
done
:
done
}
s
.
postStartHooks
[
name
]
=
postStartHookEntry
{
hook
:
hook
,
originatingStack
:
string
(
debug
.
Stack
()),
done
:
done
}
return
nil
return
nil
}
}
...
...
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