Skip to content

Commit

Permalink
[Enhancement] Remove PVC when storageSize is zero
Browse files Browse the repository at this point in the history
Signed-off-by: yandongxiao <[email protected]>
  • Loading branch information
yandongxiao committed Jan 16, 2024
1 parent 0695544 commit 4ae3f90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/k8sutils/templates/pod/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func MountStorageVolumes(spec v1.SpecInterface) ([]corev1.Volume, []corev1.Volum
var volumeMounts []corev1.VolumeMount
vexist := make(map[string]bool)
for _, sv := range spec.GetStorageVolumes() {
if sv.StorageSize == "0" {
continue
}
vexist[sv.MountPath] = true
if IsSpecialStorageClass(sv.StorageClassName) {
volumes, volumeMounts = MountEmptyDirVolume(volumes, volumeMounts, sv.Name, sv.MountPath, sv.SubPath)
Expand Down
3 changes: 3 additions & 0 deletions pkg/k8sutils/templates/statefulset/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func PVCList(volumes []v1.StorageVolume) []corev1.PersistentVolumeClaim {
if pod.IsSpecialStorageClass(vm.StorageClassName) {
continue
}
if vm.StorageSize == "0" {
continue
}
pvc := corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{Name: vm.Name},
Spec: corev1.PersistentVolumeClaimSpec{
Expand Down

0 comments on commit 4ae3f90

Please sign in to comment.