Skip to content

Commit 88f0be6

Browse files
committed
in GuaranteedUpdate, retry on precondition check failure if we are working with cached data
1 parent 2670651 commit 88f0be6

File tree

1 file changed

+14
-1
lines changed
  • staging/src/k8s.io/apiserver/pkg/storage/etcd3

1 file changed

+14
-1
lines changed

staging/src/k8s.io/apiserver/pkg/storage/etcd3/store.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,20 @@ func (s *store) GuaranteedUpdate(
274274
transformContext := authenticatedDataString(key)
275275
for {
276276
if err := preconditions.Check(key, origState.obj); err != nil {
277-
return err
277+
// If our data is already up to date, return the error
278+
if !mustCheckData {
279+
return err
280+
}
281+
282+
// It's possible we were working with stale data
283+
// Actually fetch
284+
origState, err = getCurrentState()
285+
if err != nil {
286+
return err
287+
}
288+
mustCheckData = false
289+
// Retry
290+
continue
278291
}
279292

280293
ret, ttl, err := s.updateState(origState, tryUpdate)

0 commit comments

Comments
 (0)