external-provisioner icon indicating copy to clipboard operation
external-provisioner copied to clipboard

fix: add finalizer to prevent volume leakage

Open 1978629634 opened this issue 11 months ago • 5 comments

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind bug

What this PR does / why we need it:

Add a annotation volume.kubernetes.io/provisioning-consistency to pvc. When the annotation is set to enable, use a finalizer to ensure that the lifecycle of the PVC is consistent with the associated volume, preventing volume leakage.

The finalizer is removed under two conditions:

1.When the annotation volume.kubernetes.io/provisioning-consistency is set to disable on the PVC, or

2.When the associated PV has been provisioned successfully.

Removing the finalizer allows the PVC to be deleted safely without causing the volume to leak.

Which issue(s) this PR fixes:

Fixes #486

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


When the annotation volume.kubernetes.io/provisioning-consistency is added to a PVC with the value enable, a provisioning protection finalizer will be added before creating the volume and removed after setting pvc.spec.volumeName.

If the PVC is being deleted and volume.kubernetes.io/provisioning-consistency is set to disable, the finalizer will be removed, abandoning the provisioning process. A CSI driver may be provisioning the volume and this volume may leak.

1978629634 avatar Mar 19 '24 17:03 1978629634