From 4af1c546b4f9ce7c474a7a8ab9d659a8b8a084e6 Mon Sep 17 00:00:00 2001 From: deads2k Date: Mon, 16 May 2016 09:53:45 -0400 Subject: [PATCH] prevent nil pointer when starting controllers before running the shared informer --- pkg/controller/framework/shared_informer.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/controller/framework/shared_informer.go b/pkg/controller/framework/shared_informer.go index 9d9d99bcf4d..59f641b9814 100644 --- a/pkg/controller/framework/shared_informer.go +++ b/pkg/controller/framework/shared_informer.go @@ -139,11 +139,12 @@ func (s *sharedIndexInformer) Run(stopCh <-chan struct{}) { Process: s.HandleDeltas, } - s.controller = New(cfg) func() { s.startedLock.Lock() defer s.startedLock.Unlock() + + s.controller = New(cfg) s.started = true }() @@ -158,6 +159,12 @@ func (s *sharedIndexInformer) isStarted() bool { } func (s *sharedIndexInformer) HasSynced() bool { + s.startedLock.Lock() + defer s.startedLock.Unlock() + + if s.controller == nil { + return false + } return s.controller.HasSynced() }