in pkg/common/utils/resource/persistent_volume_claim.go [97:175]
func GenerateEveryoneMountPathDorisPersistentVolume(spec *dorisv1.BaseSpec, excludePaths []string, config map[string]interface{}, componentType dorisv1.ComponentType) ([]dorisv1.PersistentVolume, error) {
// Only the last data pvc template configuration takes effect
var template *dorisv1.PersistentVolume
// dorisPersistentVolumes is the pvc that needs to be actually created, specified by the user
var dorisPersistentVolumes []dorisv1.PersistentVolume
for i := range spec.PersistentVolumes {
if spec.PersistentVolumes[i].MountPath != "" {
path := spec.PersistentVolumes[i].MountPath
if strings.HasSuffix(path, "/") {
path = path[:len(path)-1]
}
if !set.ArrayContains(excludePaths, path) {
dorisPersistentVolumes = append(dorisPersistentVolumes, spec.PersistentVolumes[i])
} else {
klog.Errorf("GenerateEveryoneMountPathDorisPersistentVolume SharedPersistentVolumeClaim.MountPath (%s) conflicts with the MountPath configured in BaseSpec.PersistentVolumes, "+
"and the SharedPersistentVolumeClaims configuration takes precedence, skipping the processing of the BaseSpec.PersistentVolumes for the PVC. "+
"If it does not meet expectations, please handle the conflict and rebuild the cluster.", path)
}
} else {
template = (&spec.PersistentVolumes[i]).DeepCopy()
}
}
if template == nil {
return dorisPersistentVolumes, nil
}
// Processing pvc template
var dataPathKey, dataDefaultPath string
var dataPaths []string
dorisHome := getDefaultDorisHome(componentType)
switch componentType {
case dorisv1.Component_FE:
dataPathKey = "meta_dir"
dataDefaultPath = dorisHome + "/doris-meta"
case dorisv1.Component_BE, dorisv1.Component_CN:
dataPathKey = "storage_root_path"
dataDefaultPath = dorisHome + "/storage"
default:
klog.Infof("GenerateEveryoneMountPathDorisPersistentVolume the componentType: %s is not supported, PersistentVolume template will not work ", componentType)
return dorisPersistentVolumes, nil
}
dataPathValue, dataExist := config[dataPathKey]
if !dataExist {
klog.Infof("GenerateEveryoneMountPathDorisPersistentVolume: dataPathKey '%s' not found in config, default value will effect", dataPathKey)
dataPaths = append(dataPaths, dataDefaultPath)
} else {
dataPaths = doris.ResolveStorageRootPath(dataPathValue.(string))
}
if len(dataPaths) == 1 {
tmp := *template.DeepCopy()
tmp.MountPath = dataPaths[0]
if !set.ArrayContains(excludePaths, dataPaths[0]) {
dorisPersistentVolumes = append(dorisPersistentVolumes, tmp)
} else {
klog.Errorf("GenerateEveryoneMountPathDorisPersistentVolume SharedPersistentVolumeClaims.MountPath (%s) conflicts with the MountPath configured in BaseSpec.PersistentVolumes, "+
"and the SharedPersistentVolumeClaims configuration takes precedence, skipping the processing of the BaseSpec.PersistentVolumes for the PVC. "+
"If it does not meet expectations, please handle the conflict and rebuild the cluster.", dataPaths[0])
}
} else {
pathNames := doris.GetNameOfEachPath(dataPaths)
for i := range dataPaths {
tmp := *template.DeepCopy()
tmp.Name = tmp.Name + "-" + pathNames[i]
tmp.MountPath = dataPaths[i]
if !set.ArrayContains(excludePaths, dataPaths[i]) {
dorisPersistentVolumes = append(dorisPersistentVolumes, tmp)
} else {
klog.Errorf("GenerateEveryoneMountPathDorisPersistentVolume SharedPersistentVolumeClaims.MountPath (%s) conflicts with the MountPath configured in BaseSpec.PersistentVolumes, "+
"and the SharedPersistentVolumeClaims configuration takes precedence, skipping the processing of the BaseSpec.PersistentVolumes for the PVC. "+
"If it does not meet expectations, please handle the conflict and rebuild the cluster.", dataPaths[i])
}
}
}
return dorisPersistentVolumes, nil
}