kubernetes: CSINode object is not recreated after Node object is recreated

What happened?

A preemptible Node got deleted and recreated with the same name, however during csi driver registration the CSINode object was updated while it still had an ownerReference to the old Node uid. Then the CSINode object got garbage collected and we’re left with no CSINode object, causing attach/mount operations to fail.

Some audit logs with a timeline of events:

Old node uuid is ef26e636-556b-4af7-ba9e-fecece154997

The replacement Node object was created after preemption:

DEFAULT 2023-07-28T07:59:59.649269Z [protoPayload.methodName: io.k8s.core.v1.nodes.create] 
        "metadata": {
          "uid": "bec5b072-7eb8-4ab9-a5c7-e4242414e3e0"
        },

There was an update to CSINode to register the driver, however the CSINode object updated has an owner reference to the old Node uid.

DEFAULT 2023-07-28T08:00:33.437252Z [protoPayload.methodName: io.k8s.storage.v1.csinodes.update] 
          "ownerReferences": [
            {
              "apiVersion": "v1",
              "kind": "Node",
              "uid": "ef26e636-556b-4af7-ba9e-fecece154997"
            }
        },
        "spec": {
          "drivers":  ....
       }

The CSINode was then garbage collected because the old Node object was deleted.

DEFAULT 2023-07-28T08:01:09.931137Z [protoPayload.methodName: io.k8s.storage.v1.csinodes.delete] [protoPayload.authenticationInfo.principalEmail: system:serviceaccount:kube-system:generic-garbage-collector] 
          "ownerReferences": [
            {
              "apiVersion": "v1",
              "kind": "Node",
              "uid": "ef26e636-556b-4af7-ba9e-fecece154997"
            }

Then CSINode was not recreated until some time later, after the driver was manually restarted.

What did you expect to happen?

CSI driver registration should update/recreate the correct CSINode object.

How can we reproduce it (as minimally and precisely as possible)?

It’s a race condition between the garbage collector and csi driver registration.

The csi driver needs to start up and register before the old CSINode object gets garbage collected.

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
1.25

Cloud provider

GKE

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, …) and versions (if applicable)

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 24 (17 by maintainers)

Most upvoted comments

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

I don’t think it should block the Node initiatialization, however it should block csi initialization.