Merge pull request #143418 from serathius/etcd-ignore-not-found

Pass ignoreNotFound to getCurrentState
This commit is contained in:
kubernetes-prow[bot] authored and GitHub committed 2026-10-26 14:54:05 +00:00
commit f401533d30
1 file changed
+11 -11
@@ -125,7 +125,7 @@ type objState struct {
// when a precondition, validation, or update error occurs. If the state is already
// current, or if the revision in etcd matches the cached revision, it returns the
// original error.
func refreshOnError(st *objState, err error, getCurrentState func() (*objState, error)) (*objState, error) {
func refreshOnError(st *objState, err error, ignoreNotFound bool, getCurrentState func(ignoteNotFounc bool) (*objState, error)) (*objState, error) {
// If our data is already up to date, return the error
if st.current {
return st, err
@@ -136,7 +136,7 @@ func refreshOnError(st *objState, err error, getCurrentState func() (*objState,
cachedRev := st.rev
cachedErr := err
currentState, err := getCurrentState()
currentState, err := getCurrentState(ignoreNotFound)
if err != nil {
return nil, err
}
@@ -425,8 +425,8 @@ func (s *store) Delete(
func (s *store) conditionalDelete(
ctx context.Context, key string, out runtime.Object, v reflect.Value, preconditions *storage.Preconditions,
validateDeletion storage.ValidateObjectFunc, cachedExistingObject runtime.Object, expectTransformOrDecodeError bool) error {
getCurrentState := func() (*objState, error) {
return s.getCurrentState(ctx, "deleteGet", key, v, false, expectTransformOrDecodeError)
getCurrentState := func(ignoreNotFound bool) (*objState, error) {
return s.getCurrentState(ctx, "deleteGet", key, v, ignoreNotFound, expectTransformOrDecodeError)
}
var origState *objState
@@ -434,7 +434,7 @@ func (s *store) conditionalDelete(
if cachedExistingObject != nil {
origState, err = s.getStateFromObject(cachedExistingObject, false)
} else {
origState, err = getCurrentState()
origState, err = getCurrentState(false)
}
if err != nil {
return err
@@ -443,7 +443,7 @@ func (s *store) conditionalDelete(
for {
if preconditions != nil {
if err := preconditions.Check(key, origState.obj); err != nil {
origState, err = refreshOnError(origState, err, getCurrentState)
origState, err = refreshOnError(origState, err, false, getCurrentState)
if err != nil {
return err
}
@@ -451,7 +451,7 @@ func (s *store) conditionalDelete(
}
}
if err := validateDeletion(ctx, origState.obj); err != nil {
origState, err = refreshOnError(origState, err, getCurrentState)
origState, err = refreshOnError(origState, err, false, getCurrentState)
if err != nil {
return err
}
@@ -516,7 +516,7 @@ func (s *store) GuaranteedUpdate(
return fmt.Errorf("unable to convert output object to pointer: %v", err)
}
getCurrentState := func() (*objState, error) {
getCurrentState := func(ignoreNotFound bool) (*objState, error) {
return s.getCurrentState(ctx, "updateGet", preparedKey, v, ignoreNotFound, false)
}
@@ -524,7 +524,7 @@ func (s *store) GuaranteedUpdate(
if cachedExistingObject != nil {
origState, err = s.getStateFromObject(cachedExistingObject, false)
} else {
origState, err = getCurrentState()
origState, err = getCurrentState(ignoreNotFound)
}
if err != nil {
return err
@@ -533,7 +533,7 @@ func (s *store) GuaranteedUpdate(
for {
if err := preconditions.Check(preparedKey, origState.obj); err != nil {
origState, err = refreshOnError(origState, err, getCurrentState)
origState, err = refreshOnError(origState, err, ignoreNotFound, getCurrentState)
if err != nil {
return err
}
@@ -542,7 +542,7 @@ func (s *store) GuaranteedUpdate(
ret, ttl, err := updateState(origState, tryUpdate)
if err != nil {
origState, err = refreshOnError(origState, err, getCurrentState)
origState, err = refreshOnError(origState, err, ignoreNotFound, getCurrentState)
if err != nil {
return err
}