mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 17:38:50 +00:00
Enable PVC as DataSource for PVC creation
This enables the ability to specify and existing PVC as a DataSource in a new PVC Spec (eg "clone" and existing volume).
This commit is contained in:
@@ -28,7 +28,7 @@ func DropDisabledFields(pvcSpec, oldPVCSpec *core.PersistentVolumeClaimSpec) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && !volumeModeInUse(oldPVCSpec) {
|
||||
pvcSpec.VolumeMode = nil
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.VolumeSnapshotDataSource) && !volumeSnapshotDataSourceInUse(oldPVCSpec) {
|
||||
if !dataSourceIsEnabled(pvcSpec) && !dataSourceInUse(oldPVCSpec) {
|
||||
pvcSpec.DataSource = nil
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ func volumeModeInUse(oldPVCSpec *core.PersistentVolumeClaimSpec) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func volumeSnapshotDataSourceInUse(oldPVCSpec *core.PersistentVolumeClaimSpec) bool {
|
||||
func dataSourceInUse(oldPVCSpec *core.PersistentVolumeClaimSpec) bool {
|
||||
if oldPVCSpec == nil {
|
||||
return false
|
||||
}
|
||||
@@ -52,3 +52,17 @@ func volumeSnapshotDataSourceInUse(oldPVCSpec *core.PersistentVolumeClaimSpec) b
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func dataSourceIsEnabled(pvcSpec *core.PersistentVolumeClaimSpec) bool {
|
||||
if pvcSpec.DataSource != nil {
|
||||
if pvcSpec.DataSource.Kind == "PersistentVolumeClaim" && utilfeature.DefaultFeatureGate.Enabled(features.VolumeDataSource) {
|
||||
return true
|
||||
|
||||
}
|
||||
if pvcSpec.DataSource.Kind == "VolumeSnapshot" && utilfeature.DefaultFeatureGate.Enabled(features.VolumeSnapshotDataSource) {
|
||||
return true
|
||||
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user