Skip to content

Commit

Permalink
prevent nil pointer when starting controllers before running the shar…
Browse files Browse the repository at this point in the history
…ed informer
  • Loading branch information
deads2k committed May 16, 2016
1 parent 8d90427 commit 4af1c54
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controller/framework/shared_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}()

Expand All @@ -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()
}

Expand Down

0 comments on commit 4af1c54

Please sign in to comment.