fix issue with using feature HonorPVReclaimPolicy in csi-provisioner
This commit is contained in:
parent
d61cbac69a
commit
5ff42b2368
@ -148,9 +148,9 @@ func TestDeleteSync(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// PV requires external deleter
|
// PV requires external deleter
|
||||||
name: "8-10 - external deleter",
|
name: "8-10-1 - external deleter when volume is dynamic provisioning",
|
||||||
initialVolumes: []*v1.PersistentVolume{newExternalProvisionedVolume("volume8-10", "1Gi", "uid10-1", "claim10-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, gceDriver, nil, volume.AnnBoundByController)},
|
initialVolumes: []*v1.PersistentVolume{newExternalProvisionedVolume("volume8-10-1", "1Gi", "uid10-1-1", "claim10-1-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, gceDriver, nil, volume.AnnBoundByController)},
|
||||||
expectedVolumes: []*v1.PersistentVolume{newExternalProvisionedVolume("volume8-10", "1Gi", "uid10-1", "claim10-1", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, gceDriver, nil, volume.AnnBoundByController)},
|
expectedVolumes: []*v1.PersistentVolume{newExternalProvisionedVolume("volume8-10-1", "1Gi", "uid10-1-1", "claim10-1-1", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, gceDriver, nil, volume.AnnBoundByController)},
|
||||||
initialClaims: noclaims,
|
initialClaims: noclaims,
|
||||||
expectedClaims: noclaims,
|
expectedClaims: noclaims,
|
||||||
expectedEvents: noevents,
|
expectedEvents: noevents,
|
||||||
@ -162,6 +162,28 @@ func TestDeleteSync(t *testing.T) {
|
|||||||
return testSyncVolume(ctrl, reactor, test)
|
return testSyncVolume(ctrl, reactor, test)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// PV requires external deleter
|
||||||
|
name: "8-10-2 - external deleter when volume is static provisioning",
|
||||||
|
initialVolumes: []*v1.PersistentVolume{newExternalProvisionedVolume("volume8-10-2", "1Gi", "uid10-1-2", "claim10-1-2", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, gceDriver, nil, volume.AnnBoundByController)},
|
||||||
|
expectedVolumes: []*v1.PersistentVolume{newExternalProvisionedVolume("volume8-10-2", "1Gi", "uid10-1-2", "claim10-1-2", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, gceDriver, nil, volume.AnnBoundByController)},
|
||||||
|
initialClaims: noclaims,
|
||||||
|
expectedClaims: noclaims,
|
||||||
|
expectedEvents: noevents,
|
||||||
|
errors: noerrors,
|
||||||
|
test: testSyncVolume,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// PV requires external deleter
|
||||||
|
name: "8-10-3 - external deleter when volume is migrated",
|
||||||
|
initialVolumes: []*v1.PersistentVolume{volumeWithAnnotation(volume.AnnMigratedTo, "pd.csi.storage.gke.io", volumeWithAnnotation(volume.AnnDynamicallyProvisioned, "kubernetes.io/gce-pd", newVolume("volume8-10-3", "1Gi", "uid10-1-3", "claim10-1-3", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, volume.AnnDynamicallyProvisioned)))},
|
||||||
|
expectedVolumes: []*v1.PersistentVolume{volumeWithAnnotation(volume.AnnMigratedTo, "pd.csi.storage.gke.io", volumeWithAnnotation(volume.AnnDynamicallyProvisioned, "kubernetes.io/gce-pd", newVolume("volume8-10-3", "1Gi", "uid10-1-3", "claim10-1-3", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, volume.AnnDynamicallyProvisioned)))},
|
||||||
|
initialClaims: noclaims,
|
||||||
|
expectedClaims: noclaims,
|
||||||
|
expectedEvents: noevents,
|
||||||
|
errors: noerrors,
|
||||||
|
test: testSyncVolume,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// delete success - two PVs are provisioned for a single claim.
|
// delete success - two PVs are provisioned for a single claim.
|
||||||
// One of the PVs is deleted.
|
// One of the PVs is deleted.
|
||||||
|
@ -1952,6 +1952,18 @@ func (ctrl *PersistentVolumeController) findDeletablePlugin(volume *v1.Persisten
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if utilfeature.DefaultFeatureGate.Enabled(features.HonorPVReclaimPolicy) {
|
||||||
|
if metav1.HasAnnotation(volume.ObjectMeta, storagehelpers.AnnMigratedTo) {
|
||||||
|
// CSI migration scenario - do not depend on in-tree plugin
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if volume.Spec.CSI != nil {
|
||||||
|
// CSI volume source scenario - external provisioner is requested
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The plugin that provisioned the volume was not found or the volume
|
// The plugin that provisioned the volume was not found or the volume
|
||||||
// was not dynamically provisioned. Try to find a plugin by spec.
|
// was not dynamically provisioned. Try to find a plugin by spec.
|
||||||
spec := vol.NewSpecFromPersistentVolume(volume, false)
|
spec := vol.NewSpecFromPersistentVolume(volume, false)
|
||||||
|
Loading…
Reference in New Issue
Block a user