Skip to content

Fix conditionalDelete returning no success for undecodable objects in 1.37.0 rebase #4521

Open

Description

@mjudeikis-bot

What exists today

In the kcp-dev/kubernetes 1.37.0 rebase (PR kcp-dev/kubernetes#198, head 5ec79958933dfa6999e77eab9e90b691e26fbcd5), conditionalDelete in staging/src/k8s.io/apiserver/pkg/storage/etcd3/store.go (around lines 470-485) has the final return nil inside the if !expectTransformOrDecodeError { ... } block:

if !expectTransformOrDecodeError {
    err = s.decode(s.codec, s.versioner, origState.data, out, txnResp.Revision, clusterName, shardName)
    if err != nil {
        recordDecodeError(s.groupResource, key)
        return err
    }
    return nil
}

Upstream returns nil after that block, unconditionally. When ExpectTransformOrDecodeError is set (deleting a corrupt or undecodable object), the loop continues after OptimisticDelete has already succeeded. It then retries against a key that no longer exists, so the delete never returns success.

Review comment that raised it: kcp-dev/kubernetes#198 (comment)
Request to track it: kcp-dev/kubernetes#198 (comment)

What should replace it

Move return nil out of the if, matching upstream, so a successful delete always returns.

Steps

  • Move return nil after the if !expectTransformOrDecodeError block in conditionalDelete in the kcp-dev/kubernetes 1.37.0 branch (or the patch in kcp-dev/kubernetes-patches).
  • Add or run a test that deletes a corrupt object with ExpectTransformOrDecodeError set and expects success.
  • Confirm the diff against upstream conditionalDelete is empty for this block.
  • Make sure the fix lands before kcp bumps to 1.37.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions