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{}) | ||||
| 	defer close(stopCh) | ||||
| 	wrappingServer.PrepareRun() | ||||
| 	wrappingServer.RunPostStartHooks() | ||||
| 	wrappingServer.RunPostStartHooks(stopCh) | ||||
| 
 | ||||
| 	server := httptest.NewServer(wrappingServer.Handler) | ||||
| 	defer server.Close() | ||||
|  |  | |||
|  | @ -272,7 +272,7 @@ func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error { | |||
| 		close(internalStopCh) | ||||
| 	}() | ||||
| 
 | ||||
| 	s.RunPostStartHooks() | ||||
| 	s.RunPostStartHooks(stopCh) | ||||
| 
 | ||||
| 	if _, err := systemd.SdNotify(true, "READY=1\n"); err != nil { | ||||
| 		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 { | ||||
| 	// LoopbackClientConfig is a config for a privileged loopback connection to the API server
 | ||||
| 	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
 | ||||
|  | @ -89,12 +91,15 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc) | |||
| } | ||||
| 
 | ||||
| // RunPostStartHooks runs the PostStartHooks for the server
 | ||||
| func (s *GenericAPIServer) RunPostStartHooks() { | ||||
| func (s *GenericAPIServer) RunPostStartHooks(stopCh <-chan struct{}) { | ||||
| 	s.postStartHookLock.Lock() | ||||
| 	defer s.postStartHookLock.Unlock() | ||||
| 	s.postStartHooksCalled = true | ||||
| 
 | ||||
| 	context := PostStartHookContext{LoopbackClientConfig: s.LoopbackClientConfig} | ||||
| 	context := PostStartHookContext{ | ||||
| 		LoopbackClientConfig: s.LoopbackClientConfig, | ||||
| 		StopCh:               stopCh, | ||||
| 	} | ||||
| 
 | ||||
| 	for hookName, hookEntry := range s.postStartHooks { | ||||
| 		go runPostStartHook(hookName, hookEntry, context) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue