Merge pull request #74089 from deads2k/aggregator-error-handling

prevent unhandled errors on colliding poststarthook registration

Kubernetes-commit: c32ea74031e51296669eed3f94f408327f1b4fbb
This commit is contained in:
Kubernetes Publisher 2019-02-18 13:29:21 -08:00
commit e869466783
4 changed files with 1092 additions and 1026 deletions

2108
Godeps/Godeps.json generated

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,7 @@ func TestNewWithDelegate(t *testing.T) {
})
delegatePostStartHookChan := make(chan struct{})
delegateServer.AddPostStartHook("delegate-post-start-hook", func(context PostStartHookContext) error {
delegateServer.AddPostStartHookOrDie("delegate-post-start-hook", func(context PostStartHookContext) error {
defer close(delegatePostStartHookChan)
return nil
})
@ -85,7 +85,7 @@ func TestNewWithDelegate(t *testing.T) {
})
wrappingPostStartHookChan := make(chan struct{})
wrappingServer.AddPostStartHook("wrapping-post-start-hook", func(context PostStartHookContext) error {
wrappingServer.AddPostStartHookOrDie("wrapping-post-start-hook", func(context PostStartHookContext) error {
defer close(wrappingPostStartHookChan)
return nil
})

View File

@ -92,7 +92,9 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
// done is closed when the poststarthook is finished. This is used by the health check to be able to indicate
// that the poststarthook is finished
done := make(chan struct{})
s.AddHealthzChecks(postStartHookHealthz{name: "poststarthook/" + name, done: done})
if err := s.AddHealthzChecks(postStartHookHealthz{name: "poststarthook/" + name, done: done}); err != nil {
return err
}
s.postStartHooks[name] = postStartHookEntry{hook: hook, done: done}
return nil

View File

@ -496,7 +496,7 @@ func TestServerRunWithSNI(t *testing.T) {
// add poststart hook to know when the server is up.
startedCh := make(chan struct{})
s.AddPostStartHook("test-notifier", func(context PostStartHookContext) error {
s.AddPostStartHookOrDie("test-notifier", func(context PostStartHookContext) error {
close(startedCh)
return nil
})