Skip to content

Commit 5ccf1b3

Browse files
authored
Merge pull request kubernetes-retired#42 from wlan0/master
ensure that indexer has latest instance of an object
2 parents 0af83d5 + 32b6c31 commit 5ccf1b3

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

controller/controller.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ func NewObjectStorageControllerWithClientset(identity string, leaderLockName str
158158

159159
ResyncPeriod: 30 * time.Second,
160160
// leader election
161-
LeaseDuration: 60 * time.Second,
162-
RenewDeadline: 30 * time.Second,
163-
RetryPeriod: 15 * time.Second,
161+
LeaseDuration: 150 * time.Second,
162+
RenewDeadline: 120 * time.Second,
163+
RetryPeriod: 60 * time.Second,
164164

165165
opMap: &sync.Map{},
166166
}, nil
@@ -258,7 +258,7 @@ func (c *ObjectStorageController) processNextItem(ctx context.Context) bool {
258258

259259
op, ok := c.opMap.Load(uuid)
260260
if !ok {
261-
panic("unreachable code")
261+
return true
262262
}
263263

264264
// Ensure that multiple operations on different versions of the same object
@@ -270,22 +270,16 @@ func (c *ObjectStorageController) processNextItem(ctx context.Context) bool {
270270
case addOp:
271271
add := *o.AddFunc
272272
err = add(ctx, o.Object)
273-
if err == nil {
274-
o.Indexer.Add(o.Object)
275-
}
273+
o.Indexer.Add(o.Object)
276274
case updateOp:
277275
update := *o.UpdateFunc
278276
err = update(ctx, o.OldObject, o.NewObject)
279-
if err == nil {
280-
o.Indexer.Update(o.NewObject)
281-
}
277+
o.Indexer.Update(o.NewObject)
282278
case deleteOp:
283279
delete := *o.DeleteFunc
284280
err = delete(ctx, o.Object)
285-
if err == nil {
286-
o.Indexer.Delete(o.Object)
287-
c.opMap.Delete(uuid)
288-
}
281+
o.Indexer.Delete(o.Object)
282+
c.opMap.Delete(uuid)
289283
default:
290284
panic("unknown item in queue")
291285
}
@@ -321,6 +315,7 @@ func (c *ObjectStorageController) GetOpLock(op types.UID) *sync.Mutex {
321315
// handleErr checks if an error happened and makes sure we will retry later.
322316
func (c *ObjectStorageController) handleErr(err error, uuid types.UID) {
323317
if err == nil {
318+
c.opMap.Delete(uuid)
324319
return
325320
}
326321
c.queue.AddRateLimited(uuid)

0 commit comments

Comments
 (0)