Skip to content

Commit d936eef

Browse files
authored
Merge pull request kubernetes-sigs#178 from droot/ctrl-add-watches-after-start
do not hold the lock after controller has started
2 parents da89fe5 + 80661ac commit d936eef

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/internal/controller/controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ func (c *Controller) Watch(src source.Source, evthdler handler.EventHandler, prc
125125
// Start implements controller.Controller
126126
func (c *Controller) Start(stop <-chan struct{}) error {
127127
c.mu.Lock()
128-
defer c.mu.Unlock()
129128

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

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

163163
c.Started = true
164+
c.mu.Unlock()
164165

165166
<-stop
166167
log.Info("Stopping workers", "Controller", c.Name)

0 commit comments

Comments
 (0)