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 abe029a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ spec:
{{- if .Values.starrocksFESpec.storageSpec.name }}
- name: {{ .Values.starrocksFESpec.storageSpec.name }}{{ template "starrockscluster.fe.meta.suffix" . }}
storageClassName: {{ .Values.starrocksFESpec.storageSpec.storageClassName }}
storageSize: {{ .Values.starrocksFESpec.storageSpec.storageSize }}
storageSize: "{{ .Values.starrocksFESpec.storageSpec.storageSize }}"
mountPath: {{ template "starrockscluster.fe.meta.path" . }}
- name: {{ .Values.starrocksFESpec.storageSpec.name }}{{ template "starrockscluster.fe.log.suffix" . }}
storageClassName: {{ .Values.starrocksFESpec.storageSpec.storageClassName }}
storageSize: {{ .Values.starrocksFESpec.storageSpec.logStorageSize }}
storageSize: "{{ .Values.starrocksFESpec.storageSpec.logStorageSize }}"
mountPath: {{ template "starrockscluster.fe.log.path" . }}
{{- end }}
{{- if .Values.starrocksFESpec.emptyDirs }}
Expand Down Expand Up @@ -308,11 +308,11 @@ spec:
storageVolumes:
- name: {{ .Values.starrocksBeSpec.storageSpec.name }}{{template "starrockscluster.be.data.suffix" . }}
storageClassName: {{ .Values.starrocksBeSpec.storageSpec.storageClassName }}
storageSize: {{ .Values.starrocksBeSpec.storageSpec.storageSize }}
storageSize: "{{ .Values.starrocksBeSpec.storageSpec.storageSize }}"
mountPath: {{template "starrockscluster.be.data.path" . }}
- name: {{ .Values.starrocksBeSpec.storageSpec.name }}{{template "starrockscluster.be.log.suffix" . }}
storageClassName: {{ .Values.starrocksBeSpec.storageSpec.storageClassName }}
storageSize: {{ .Values.starrocksBeSpec.storageSpec.logStorageSize }}
storageSize: "{{ .Values.starrocksBeSpec.storageSpec.logStorageSize }}"
mountPath: {{template "starrockscluster.be.log.path" . }}
{{- end }}
{{- if .Values.starrocksBeSpec.emptyDirs }}
Expand Down Expand Up @@ -472,11 +472,11 @@ spec:
{{- if .Values.starrocksCnSpec.storageSpec.name }}
- name: {{ .Values.starrocksCnSpec.storageSpec.name }}{{template "starrockscluster.cn.data.suffix" . }}
storageClassName: {{ .Values.starrocksCnSpec.storageSpec.storageClassName }}
storageSize: {{ .Values.starrocksCnSpec.storageSpec.storageSize }}
storageSize: "{{ .Values.starrocksCnSpec.storageSpec.storageSize }}"
mountPath: {{template "starrockscluster.cn.data.path" . }}
- name: {{ .Values.starrocksCnSpec.storageSpec.name }}{{template "starrockscluster.cn.log.suffix" . }}
storageClassName: {{ .Values.starrocksCnSpec.storageSpec.storageClassName }}
storageSize: {{ .Values.starrocksCnSpec.storageSpec.logStorageSize }}
storageSize: "{{ .Values.starrocksCnSpec.storageSpec.logStorageSize }}"
mountPath: {{template "starrockscluster.cn.log.path" . }}
{{- end }}
{{- if .Values.starrocksCnSpec.emptyDirs }}
Expand Down
5 changes: 5 additions & 0 deletions pkg/k8sutils/templates/pod/mount.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package pod

import (
"strings"

corev1 "k8s.io/api/core/v1"

v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1"
Expand All @@ -23,6 +25,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 strings.HasPrefix(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
5 changes: 5 additions & 0 deletions pkg/k8sutils/templates/statefulset/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package statefulset

import (
"strings"

appv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
Expand All @@ -36,6 +38,9 @@ func PVCList(volumes []v1.StorageVolume) []corev1.PersistentVolumeClaim {
if pod.IsSpecialStorageClass(vm.StorageClassName) {
continue
}
if strings.HasPrefix(vm.StorageSize, "0") {
continue
}
pvc := corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{Name: vm.Name},
Spec: corev1.PersistentVolumeClaimSpec{
Expand Down

0 comments on commit abe029a

Please sign in to comment.