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
15c54ffa
Commit
15c54ffa
authored
Aug 23, 2017
by
Simo Sorce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an OrDie version for AddPostStartHook
Simplifies usage and consolidate the error message so it is always the same everywhere. Signed-off-by:
Simo Sorce
<
simo@redhat.com
>
parent
2f00e6d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
master.go
pkg/master/master.go
+3
-9
hooks.go
staging/src/k8s.io/apiserver/pkg/server/hooks.go
+7
-0
No files found.
pkg/master/master.go
View file @
15c54ffa
...
...
@@ -278,9 +278,7 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
m
.
installTunneler
(
c
.
Tunneler
,
corev1client
.
NewForConfigOrDie
(
c
.
GenericConfig
.
LoopbackClientConfig
)
.
Nodes
())
}
if
err
:=
m
.
GenericAPIServer
.
AddPostStartHook
(
"ca-registration"
,
c
.
ClientCARegistrationHook
.
PostStartHook
);
err
!=
nil
{
glog
.
Fatalf
(
"Error registering PostStartHook %q: %v"
,
"ca-registration"
,
err
)
}
m
.
GenericAPIServer
.
AddPostStartHookOrDie
(
"ca-registration"
,
c
.
ClientCARegistrationHook
.
PostStartHook
)
return
m
,
nil
}
...
...
@@ -294,9 +292,7 @@ func (m *Master) InstallLegacyAPI(c *Config, restOptionsGetter generic.RESTOptio
if
c
.
EnableCoreControllers
{
coreClient
:=
coreclient
.
NewForConfigOrDie
(
c
.
GenericConfig
.
LoopbackClientConfig
)
bootstrapController
:=
c
.
NewBootstrapController
(
legacyRESTStorage
,
coreClient
,
coreClient
)
if
err
:=
m
.
GenericAPIServer
.
AddPostStartHook
(
"bootstrap-controller"
,
bootstrapController
.
PostStartHook
);
err
!=
nil
{
glog
.
Fatalf
(
"Error registering PostStartHook %q: %v"
,
"bootstrap-controller"
,
err
)
}
m
.
GenericAPIServer
.
AddPostStartHookOrDie
(
"bootstrap-controller"
,
bootstrapController
.
PostStartHook
)
}
if
err
:=
m
.
GenericAPIServer
.
InstallLegacyAPIGroup
(
genericapiserver
.
DefaultLegacyAPIPrefix
,
&
apiGroupInfo
);
err
!=
nil
{
...
...
@@ -341,9 +337,7 @@ func (m *Master) InstallAPIs(apiResourceConfigSource serverstorage.APIResourceCo
if
err
!=
nil
{
glog
.
Fatalf
(
"Error building PostStartHook: %v"
,
err
)
}
if
err
:=
m
.
GenericAPIServer
.
AddPostStartHook
(
name
,
hook
);
err
!=
nil
{
glog
.
Fatalf
(
"Error registering PostStartHook %q: %v"
,
name
,
err
)
}
m
.
GenericAPIServer
.
AddPostStartHookOrDie
(
name
,
hook
)
}
apiGroupsInfo
=
append
(
apiGroupsInfo
,
apiGroupInfo
)
...
...
staging/src/k8s.io/apiserver/pkg/server/hooks.go
View file @
15c54ffa
...
...
@@ -90,6 +90,13 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
return
nil
}
// AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure
func
(
s
*
GenericAPIServer
)
AddPostStartHookOrDie
(
name
string
,
hook
PostStartHookFunc
)
{
if
err
:=
s
.
AddPostStartHook
(
name
,
hook
);
err
!=
nil
{
glog
.
Fatalf
(
"Error registering PostStartHook %q: %v"
,
name
,
err
)
}
}
// RunPostStartHooks runs the PostStartHooks for the server
func
(
s
*
GenericAPIServer
)
RunPostStartHooks
(
stopCh
<-
chan
struct
{})
{
s
.
postStartHookLock
.
Lock
()
...
...
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