Skip to content

Introducing finalizers to PersistentVolumeClaim #1389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ func createFakeNamedPVC(requestBytes int64, name string, userAnnotations map[str
Name: name,
Namespace: "fake-ns",
Annotations: annotations,
Finalizers: []string{"volume.kubernetes.io/clone-protection"},
Copy link
Contributor

@jsafrane jsafrane Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of "clone protection finalizer" check is to ensure that the external-provisioner adds the finalizer when needed. Adding finalizer to the initial PVC will only make the tests pass, without actually testing anything.

A real fix will be far more complicated. You need to study when the controller adds the finalizer, when it removes the finalizer and how the unit test reads the finalizer. My guess would be that the unit test reads the PVC to check from an informer and the informer is stale. Try to read the PVC directly from the API server instead.

},
Spec: v1.PersistentVolumeClaimSpec{
Selector: nil, // Provisioner doesn't support selector
Expand Down Expand Up @@ -970,7 +971,7 @@ func TestFSTypeProvision(t *testing.T) {
volOpts: controller.ProvisionOptions{
StorageClass: &storagev1.StorageClass{
ReclaimPolicy: &deletePolicy,
Parameters: map[string]string{
Parameters: map[string]string{
// We deliberately skip fsType in sc param
// "fstype": "",
},
Expand Down Expand Up @@ -1028,7 +1029,7 @@ func TestFSTypeProvision(t *testing.T) {
volOpts: controller.ProvisionOptions{
StorageClass: &storagev1.StorageClass{
ReclaimPolicy: &deletePolicy,
Parameters: map[string]string{
Parameters: map[string]string{
// We deliberately skip fsType in sc param
// "fstype": "xfs",
},
Expand Down