plumb stopch to post start hook index since many of them are starting go funcs
Kubernetes-commit: be39283923650ad96539640ca988fbf194db2be4
This commit is contained in:
parent
f72563011c
commit
00b83db9b8
|
@ -88,7 +88,7 @@ func TestNewWithDelegate(t *testing.T) {
|
||||||
stopCh := make(chan struct{})
|
stopCh := make(chan struct{})
|
||||||
defer close(stopCh)
|
defer close(stopCh)
|
||||||
wrappingServer.PrepareRun()
|
wrappingServer.PrepareRun()
|
||||||
wrappingServer.RunPostStartHooks()
|
wrappingServer.RunPostStartHooks(stopCh)
|
||||||
|
|
||||||
server := httptest.NewServer(wrappingServer.Handler)
|
server := httptest.NewServer(wrappingServer.Handler)
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
|
@ -272,7 +272,7 @@ func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error {
|
||||||
close(internalStopCh)
|
close(internalStopCh)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
s.RunPostStartHooks()
|
s.RunPostStartHooks(stopCh)
|
||||||
|
|
||||||
if _, err := systemd.SdNotify(true, "READY=1\n"); err != nil {
|
if _, err := systemd.SdNotify(true, "READY=1\n"); err != nil {
|
||||||
glog.Errorf("Unable to send systemd daemon successful start message: %v\n", err)
|
glog.Errorf("Unable to send systemd daemon successful start message: %v\n", err)
|
||||||
|
|
|
@ -43,6 +43,8 @@ type PostStartHookFunc func(context PostStartHookContext) error
|
||||||
type PostStartHookContext struct {
|
type PostStartHookContext struct {
|
||||||
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
|
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
|
||||||
LoopbackClientConfig *restclient.Config
|
LoopbackClientConfig *restclient.Config
|
||||||
|
// StopCh is the channel that will be closed when the server stops
|
||||||
|
StopCh <-chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PostStartHookProvider is an interface in addition to provide a post start hook for the api server
|
// PostStartHookProvider is an interface in addition to provide a post start hook for the api server
|
||||||
|
@ -89,12 +91,15 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPostStartHooks runs the PostStartHooks for the server
|
// RunPostStartHooks runs the PostStartHooks for the server
|
||||||
func (s *GenericAPIServer) RunPostStartHooks() {
|
func (s *GenericAPIServer) RunPostStartHooks(stopCh <-chan struct{}) {
|
||||||
s.postStartHookLock.Lock()
|
s.postStartHookLock.Lock()
|
||||||
defer s.postStartHookLock.Unlock()
|
defer s.postStartHookLock.Unlock()
|
||||||
s.postStartHooksCalled = true
|
s.postStartHooksCalled = true
|
||||||
|
|
||||||
context := PostStartHookContext{LoopbackClientConfig: s.LoopbackClientConfig}
|
context := PostStartHookContext{
|
||||||
|
LoopbackClientConfig: s.LoopbackClientConfig,
|
||||||
|
StopCh: stopCh,
|
||||||
|
}
|
||||||
|
|
||||||
for hookName, hookEntry := range s.postStartHooks {
|
for hookName, hookEntry := range s.postStartHooks {
|
||||||
go runPostStartHook(hookName, hookEntry, context)
|
go runPostStartHook(hookName, hookEntry, context)
|
||||||
|
|
Loading…
Reference in New Issue