Skip to content

Commit 0b2ac9f

Browse files
smanpathakAMecea
authored andcommitted
Fix a bug in reconciliation
1 parent a832d8b commit 0b2ac9f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ bin/
4343
hack/docker/mysql-helper/mysql-helper
4444
hack/docker/mysql-operator/mysql-operator
4545
**/charts/*.tgz
46+
47+
# ignore vscode
48+
.vscode

pkg/controller/clustercontroller/controller.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (c *Controller) Start(workers int, stopCh <-chan struct{}) error {
161161

162162
for i := 0; i < reconcileWorkers; i++ {
163163
c.workerWg.Add(1)
164-
go wait.Until(func() { c.workerRecouncile(stopCh) }, workerPeriodTime, stopCh)
164+
go wait.Until(func() { c.workerReconcile(stopCh) }, workerPeriodTime, stopCh)
165165
}
166166

167167
<-stopCh
@@ -231,13 +231,13 @@ func (c *Controller) workerController(stopCh <-chan struct{}) {
231231
}
232232
}
233233

234-
func (c *Controller) workerRecouncile(stopCh <-chan struct{}) {
234+
func (c *Controller) workerReconcile(stopCh <-chan struct{}) {
235235
defer c.workerWg.Done()
236236
ctx, cancel := context.WithCancel(context.Background())
237237
ctx = util.ContextWithStopCh(ctx, stopCh)
238238
defer cancel()
239239

240-
glog.V(2).Info("Starting recouncile worker.")
240+
glog.V(2).Info("Starting reconcile worker.")
241241

242242
for {
243243
obj, shutdown := c.reconcileQueue.Get()
@@ -254,7 +254,7 @@ func (c *Controller) workerRecouncile(stopCh <-chan struct{}) {
254254
return nil
255255
}
256256

257-
if ok1, ok2 := c.clustersSync.Load(key); !ok1.(bool) && ok2 {
257+
if value, exists := c.clustersSync.Load(key); exists && !value.(bool) {
258258
// key is removed from map, don't execute reconciliation
259259
return nil
260260
}
@@ -264,7 +264,8 @@ func (c *Controller) workerRecouncile(stopCh <-chan struct{}) {
264264
if err != nil {
265265
if k8errors.IsNotFound(err) {
266266
// key was removed from map, don't reconcile.
267-
glog.Infof("Cluster %q is not found!", key)
267+
glog.Infof("Removing issuer %q from reconcile queue", key)
268+
c.removeClusterFromReconciliation(key)
268269
return nil
269270
}
270271
return fmt.Errorf("failed to get cluster: %s", err)

0 commit comments

Comments
 (0)