in pkg/controller/sub_controller/disaggregated_subcontroller.go [311:388]
func (d *DisaggregatedSubDefaultController) PersistentVolumeBuildVolumesVolumeMountsAndPVCs(commonSpec *v1.CommonSpec, confMap map[string]interface{}, componentType v1.DisaggregatedComponentType) ([]corev1.Volume, []corev1.VolumeMount, []corev1.PersistentVolumeClaim) {
v1pv := commonSpec.PersistentVolume
if v1pv == nil {
return nil, nil, nil
}
pathName := map[string]string{} /*key=path, value=name*/
var requiredPaths []string
switch componentType {
case v1.DisaggregatedMS:
//if logNotStore anywhere is true, not build pvc.
if !commonSpec.PersistentVolume.LogNotStore && !commonSpec.LogNotStore {
logPath := d.getLogPath(confMap, componentType)
pathName[logPath] = MSLogStoreName
requiredPaths = append(requiredPaths, logPath)
}
case v1.DisaggregatedFE:
if !commonSpec.PersistentVolume.LogNotStore && !commonSpec.LogNotStore {
logPath := d.getLogPath(confMap, componentType)
pathName[logPath] = FELogStoreName
requiredPaths = append(requiredPaths, logPath)
}
metaPath := d.getFEMetaPath(confMap)
pathName[metaPath] = FEMetaStoreName
requiredPaths = append(requiredPaths, metaPath)
case v1.DisaggregatedBE:
if !commonSpec.PersistentVolume.LogNotStore && !commonSpec.LogNotStore {
logPath := d.getLogPath(confMap, componentType)
pathName[logPath] = BELogStoreName
requiredPaths = append(requiredPaths, logPath)
}
cachePaths, _ := d.getCacheMaxSizeAndPaths(confMap)
for i, _ := range cachePaths {
path_i := BECacheStorePreName + strconv.Itoa(i)
pathName[cachePaths[i]] = path_i
requiredPaths = append(requiredPaths, cachePaths[i])
}
//generate the last path's name, the ordinal is length of cache paths.
baseIndex := len(cachePaths)
for _, path := range v1pv.MountPaths {
if _, ok := pathName[path]; ok {
//compatible before name= storage+i
continue
}
requiredPaths = append(requiredPaths, path)
pathName[path] = BECacheStorePreName + strconv.Itoa(baseIndex)
baseIndex = baseIndex + 1
}
default:
}
var vs []corev1.Volume
var vms []corev1.VolumeMount
var pvcs []corev1.PersistentVolumeClaim
for _, path := range requiredPaths {
name := pathName[path]
vs = append(vs, corev1.Volume{Name: name, VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: name,
}}})
vms = append(vms, corev1.VolumeMount{Name: name, MountPath: path})
pvcs = append(pvcs, corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Annotations: v1pv.Annotations,
},
Spec: *v1pv.PersistentVolumeClaimSpec.DeepCopy(),
})
}
return vs, vms, pvcs
}