Skip to content

Commit 80661ac

Browse files
committed
do not hold the lock after controller has started
This enables controller to be able to create new watches after it has started. This is required for cases where you are writing some meta-controller which discovers new types to watch during the reconcilation.
1 parent 1fe24e5 commit 80661ac

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
@@ -124,7 +124,6 @@ func (c *Controller) Watch(src source.Source, evthdler handler.EventHandler, prc
124124
// Start implements controller.Controller
125125
func (c *Controller) Start(stop <-chan struct{}) error {
126126
c.mu.Lock()
127-
defer c.mu.Unlock()
128127

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

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

162162
c.Started = true
163+
c.mu.Unlock()
163164

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

0 commit comments

Comments
 (0)