mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #109035 from deepakkinni/enable_def_v1
Default enable flag for beta feature HonorPVReclaimPolicy
This commit is contained in:
commit
78889cd1bb
@ -188,11 +188,10 @@ func TestDeleteSync(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// TODO: Change the expectedVolumes to novolumes after HonorPVReclaimPolicy is enabled by default.
|
|
||||||
// delete success - volume has deletion timestamp before doDelete() starts
|
// delete success - volume has deletion timestamp before doDelete() starts
|
||||||
"8-13 - volume has deletion timestamp and processed",
|
"8-13 - volume has deletion timestamp and processed",
|
||||||
volumesWithFinalizers(withVolumeDeletionTimestamp(newVolumeArray("volume8-13", "1Gi", "uid8-13", "claim8-13", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, volume.AnnBoundByController)), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
volumesWithFinalizers(withVolumeDeletionTimestamp(newVolumeArray("volume8-13", "1Gi", "uid8-13", "claim8-13", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty, volume.AnnBoundByController)), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
||||||
volumesWithFinalizers(withVolumeDeletionTimestamp(newVolumeArray("volume8-13", "1Gi", "uid8-13", "claim8-13", v1.VolumeReleased, v1.PersistentVolumeReclaimDelete, classEmpty, volume.AnnBoundByController)), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
novolumes,
|
||||||
noclaims,
|
noclaims,
|
||||||
noclaims,
|
noclaims,
|
||||||
noevents, noerrors,
|
noevents, noerrors,
|
||||||
@ -222,7 +221,7 @@ func TestDeleteMultiSync(t *testing.T) {
|
|||||||
// delete failure - delete returns error. The controller should
|
// delete failure - delete returns error. The controller should
|
||||||
// try again.
|
// try again.
|
||||||
"9-1 - delete returns error",
|
"9-1 - delete returns error",
|
||||||
newVolumeArray("volume9-1", "1Gi", "uid9-1", "claim9-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty),
|
volumesWithFinalizers(newVolumeArray("volume9-1", "1Gi", "uid9-1", "claim9-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classEmpty), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
||||||
novolumes,
|
novolumes,
|
||||||
noclaims,
|
noclaims,
|
||||||
noclaims,
|
noclaims,
|
||||||
|
@ -254,6 +254,7 @@ func newVolume(name, capacity, boundToClaimUID, boundToClaimName string, phase v
|
|||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
|
Finalizers: []string{storagehelpers.PVDeletionInTreeProtectionFinalizer},
|
||||||
},
|
},
|
||||||
Spec: v1.PersistentVolumeSpec{
|
Spec: v1.PersistentVolumeSpec{
|
||||||
Capacity: v1.ResourceList{
|
Capacity: v1.ResourceList{
|
||||||
|
@ -172,7 +172,7 @@ func TestProvisionSync(t *testing.T) {
|
|||||||
// Provision a volume (with a default class)
|
// Provision a volume (with a default class)
|
||||||
"11-1 - successful provision with storage class 1",
|
"11-1 - successful provision with storage class 1",
|
||||||
novolumes,
|
novolumes,
|
||||||
newVolumeArray("pvc-uid11-1", "1Gi", "uid11-1", "claim11-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classGold, volume.AnnBoundByController, volume.AnnDynamicallyProvisioned),
|
volumesWithFinalizers(newVolumeArray("pvc-uid11-1", "1Gi", "uid11-1", "claim11-1", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classGold, volume.AnnBoundByController, volume.AnnDynamicallyProvisioned), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
||||||
newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, &classGold),
|
newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, &classGold),
|
||||||
// Binding will be completed in the next syncClaim
|
// Binding will be completed in the next syncClaim
|
||||||
newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, &classGold, volume.AnnStorageProvisioner, volume.AnnBetaStorageProvisioner),
|
newClaimArray("claim11-1", "uid11-1", "1Gi", "", v1.ClaimPending, &classGold, volume.AnnStorageProvisioner, volume.AnnBetaStorageProvisioner),
|
||||||
@ -242,7 +242,7 @@ func TestProvisionSync(t *testing.T) {
|
|||||||
// second retry succeeds
|
// second retry succeeds
|
||||||
"11-8 - cannot save provisioned volume",
|
"11-8 - cannot save provisioned volume",
|
||||||
novolumes,
|
novolumes,
|
||||||
newVolumeArray("pvc-uid11-8", "1Gi", "uid11-8", "claim11-8", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classGold, volume.AnnBoundByController, volume.AnnDynamicallyProvisioned),
|
volumesWithFinalizers(newVolumeArray("pvc-uid11-8", "1Gi", "uid11-8", "claim11-8", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classGold, volume.AnnBoundByController, volume.AnnDynamicallyProvisioned), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
||||||
newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, &classGold),
|
newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, &classGold),
|
||||||
// Binding will be completed in the next syncClaim
|
// Binding will be completed in the next syncClaim
|
||||||
newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, &classGold, volume.AnnStorageProvisioner, volume.AnnBetaStorageProvisioner),
|
newClaimArray("claim11-8", "uid11-8", "1Gi", "", v1.ClaimPending, &classGold, volume.AnnStorageProvisioner, volume.AnnBetaStorageProvisioner),
|
||||||
@ -363,7 +363,7 @@ func TestProvisionSync(t *testing.T) {
|
|||||||
// Provision a volume (with non-default class)
|
// Provision a volume (with non-default class)
|
||||||
"11-13 - successful provision with storage class 2",
|
"11-13 - successful provision with storage class 2",
|
||||||
novolumes,
|
novolumes,
|
||||||
newVolumeArray("pvc-uid11-13", "1Gi", "uid11-13", "claim11-13", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classSilver, volume.AnnBoundByController, volume.AnnDynamicallyProvisioned),
|
volumesWithFinalizers(newVolumeArray("pvc-uid11-13", "1Gi", "uid11-13", "claim11-13", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, classSilver, volume.AnnBoundByController, volume.AnnDynamicallyProvisioned), []string{volume.PVDeletionInTreeProtectionFinalizer}),
|
||||||
newClaimArray("claim11-13", "uid11-13", "1Gi", "", v1.ClaimPending, &classSilver),
|
newClaimArray("claim11-13", "uid11-13", "1Gi", "", v1.ClaimPending, &classSilver),
|
||||||
// Binding will be completed in the next syncClaim
|
// Binding will be completed in the next syncClaim
|
||||||
newClaimArray("claim11-13", "uid11-13", "1Gi", "", v1.ClaimPending, &classSilver, volume.AnnStorageProvisioner, volume.AnnBetaStorageProvisioner),
|
newClaimArray("claim11-13", "uid11-13", "1Gi", "", v1.ClaimPending, &classSilver, volume.AnnStorageProvisioner, volume.AnnBetaStorageProvisioner),
|
||||||
|
@ -1458,6 +1458,12 @@ func (ctrl *PersistentVolumeController) doDeleteVolume(volume *v1.PersistentVolu
|
|||||||
func (ctrl *PersistentVolumeController) removeDeletionProtectionFinalizer(ctx context.Context, volume *v1.PersistentVolume) error {
|
func (ctrl *PersistentVolumeController) removeDeletionProtectionFinalizer(ctx context.Context, volume *v1.PersistentVolume) error {
|
||||||
var err error
|
var err error
|
||||||
pvUpdateNeeded := false
|
pvUpdateNeeded := false
|
||||||
|
// Retrieve latest version
|
||||||
|
volume, err = ctrl.kubeClient.CoreV1().PersistentVolumes().Get(context.TODO(), volume.Name, metav1.GetOptions{})
|
||||||
|
if err != nil {
|
||||||
|
klog.Errorf("error reading persistent volume %q: %v", volume.Name, err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
volumeClone := volume.DeepCopy()
|
volumeClone := volume.DeepCopy()
|
||||||
pvFinalizers := volumeClone.Finalizers
|
pvFinalizers := volumeClone.Finalizers
|
||||||
if pvFinalizers != nil && slice.ContainsString(pvFinalizers, storagehelpers.PVDeletionInTreeProtectionFinalizer, nil) {
|
if pvFinalizers != nil && slice.ContainsString(pvFinalizers, storagehelpers.PVDeletionInTreeProtectionFinalizer, nil) {
|
||||||
|
@ -434,7 +434,7 @@ func updateMigrationAnnotationsAndFinalizers(cmpm CSIMigratedPluginManager, tran
|
|||||||
if !claim && utilfeature.DefaultFeatureGate.Enabled(features.HonorPVReclaimPolicy) {
|
if !claim && utilfeature.DefaultFeatureGate.Enabled(features.HonorPVReclaimPolicy) {
|
||||||
modified := false
|
modified := false
|
||||||
if finalizers == nil {
|
if finalizers == nil {
|
||||||
*finalizers = []string{}
|
finalizers = &([]string{})
|
||||||
}
|
}
|
||||||
// Add back the in-tree PV deletion protection finalizer if does not already exists
|
// Add back the in-tree PV deletion protection finalizer if does not already exists
|
||||||
if !slice.ContainsString(*finalizers, storagehelpers.PVDeletionInTreeProtectionFinalizer, nil) {
|
if !slice.ContainsString(*finalizers, storagehelpers.PVDeletionInTreeProtectionFinalizer, nil) {
|
||||||
|
@ -52,7 +52,6 @@ import (
|
|||||||
// can't reliably simulate periodic sync of volumes/claims - it would be
|
// can't reliably simulate periodic sync of volumes/claims - it would be
|
||||||
// either very timing-sensitive or slow to wait for real periodic sync.
|
// either very timing-sensitive or slow to wait for real periodic sync.
|
||||||
func TestControllerSync(t *testing.T) {
|
func TestControllerSync(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.HonorPVReclaimPolicy, true)()
|
|
||||||
tests := []controllerTest{
|
tests := []controllerTest{
|
||||||
// [Unit test set 5] - controller tests.
|
// [Unit test set 5] - controller tests.
|
||||||
// We test the controller as if
|
// We test the controller as if
|
||||||
@ -612,7 +611,6 @@ func TestUpdateFinalizer(t *testing.T) {
|
|||||||
// This set of tests ensures that protection finalizer is removed when CSI migration is disabled
|
// This set of tests ensures that protection finalizer is removed when CSI migration is disabled
|
||||||
// and PV controller needs to remove finalizers added by the external-provisioner.
|
// and PV controller needs to remove finalizers added by the external-provisioner.
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationGCE, false)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigrationGCE, false)()
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.HonorPVReclaimPolicy, true)()
|
|
||||||
const gcePlugin = "kubernetes.io/gce-pd"
|
const gcePlugin = "kubernetes.io/gce-pd"
|
||||||
const gceDriver = "pd.csi.storage.gke.io"
|
const gceDriver = "pd.csi.storage.gke.io"
|
||||||
const customFinalizer = "test.volume.kubernetes.io/finalizer"
|
const customFinalizer = "test.volume.kubernetes.io/finalizer"
|
||||||
|
@ -967,7 +967,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
|||||||
JobMutableNodeSchedulingDirectives: {Default: true, PreRelease: featuregate.Beta},
|
JobMutableNodeSchedulingDirectives: {Default: true, PreRelease: featuregate.Beta},
|
||||||
IdentifyPodOS: {Default: true, PreRelease: featuregate.Beta},
|
IdentifyPodOS: {Default: true, PreRelease: featuregate.Beta},
|
||||||
PodAndContainerStatsFromCRI: {Default: false, PreRelease: featuregate.Alpha},
|
PodAndContainerStatsFromCRI: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
HonorPVReclaimPolicy: {Default: false, PreRelease: featuregate.Beta},
|
HonorPVReclaimPolicy: {Default: true, PreRelease: featuregate.Beta},
|
||||||
RecoverVolumeExpansionFailure: {Default: false, PreRelease: featuregate.Alpha},
|
RecoverVolumeExpansionFailure: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
GRPCContainerProbe: {Default: true, PreRelease: featuregate.Beta},
|
GRPCContainerProbe: {Default: true, PreRelease: featuregate.Beta},
|
||||||
LegacyServiceAccountTokenNoAutoGeneration: {Default: true, PreRelease: featuregate.Beta},
|
LegacyServiceAccountTokenNoAutoGeneration: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
Loading…
Reference in New Issue
Block a user