Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#178 from droot/ctrl-add-watches-af…
Browse files Browse the repository at this point in the history
…ter-start

do not hold the lock after controller has started
  • Loading branch information
k8s-ci-robot committed Nov 2, 2018
2 parents da89fe5 + 80661ac commit d936eef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (c *Controller) Watch(src source.Source, evthdler handler.EventHandler, prc
// Start implements controller.Controller
func (c *Controller) Start(stop <-chan struct{}) error {
c.mu.Lock()
defer c.mu.Unlock()

// TODO(pwittrock): Reconsider HandleCrash
defer utilruntime.HandleCrash()
Expand All @@ -143,6 +142,7 @@ func (c *Controller) Start(stop <-chan struct{}) error {
// Leaving it here because that could happen in the future
err := fmt.Errorf("failed to wait for %s caches to sync", c.Name)
log.Error(err, "Could not wait for Cache to sync", "Controller", c.Name)
c.mu.Unlock()
return err
}

Expand All @@ -161,6 +161,7 @@ func (c *Controller) Start(stop <-chan struct{}) error {
}

c.Started = true
c.mu.Unlock()

<-stop
log.Info("Stopping workers", "Controller", c.Name)
Expand Down

0 comments on commit d936eef

Please sign in to comment.