mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix(region,host,hostdeployer): 支持添加 case_insensitive_paths (#21558)
This commit is contained in:
@@ -233,7 +233,7 @@ type ContainerVolumeMountDisk struct {
|
||||
StorageSizeFile string `json:"storage_size_file"`
|
||||
Overlay *ContainerVolumeMountDiskOverlay `json:"overlay"`
|
||||
// case insensitive feature is incompatible with overlayfs
|
||||
CaseInsensitive bool `json:"case_insensitive"`
|
||||
CaseInsensitivePaths []string `json:"case_insensitive_paths"`
|
||||
}
|
||||
|
||||
type ContainerVolumeMountHostPathType string
|
||||
|
||||
@@ -21,13 +21,13 @@ import (
|
||||
)
|
||||
|
||||
type ContainerVolumeMountDisk struct {
|
||||
Index *int `json:"index,omitempty"`
|
||||
Id string `json:"id"`
|
||||
TemplateId string `json:"template_id"`
|
||||
SubDirectory string `json:"sub_directory"`
|
||||
StorageSizeFile string `json:"storage_size_file"`
|
||||
Overlay *apis.ContainerVolumeMountDiskOverlay `json:"overlay"`
|
||||
CaseInsensitive bool `json:"case_insensitive"`
|
||||
Index *int `json:"index,omitempty"`
|
||||
Id string `json:"id"`
|
||||
TemplateId string `json:"template_id"`
|
||||
SubDirectory string `json:"sub_directory"`
|
||||
StorageSizeFile string `json:"storage_size_file"`
|
||||
Overlay *apis.ContainerVolumeMountDiskOverlay `json:"overlay"`
|
||||
CaseInsensitivePaths []string `json:"case_insensitive_paths"`
|
||||
}
|
||||
|
||||
type ContainerVolumeMountCephFS struct {
|
||||
|
||||
@@ -69,7 +69,7 @@ func (d disk) validateCreateData(ctx context.Context, userCred mcclient.TokenCre
|
||||
}
|
||||
|
||||
func (d disk) validateCaseInsensitive(disk *models.SDisk, vm *apis.ContainerVolumeMountDisk) error {
|
||||
if !vm.CaseInsensitive {
|
||||
if len(vm.CaseInsensitivePaths) == 0 {
|
||||
return nil
|
||||
}
|
||||
if disk.FsFeatures == nil {
|
||||
|
||||
@@ -407,13 +407,13 @@ func (vm *ContainerVolumeMountRelation) toHostDiskMount(disk *apis.ContainerVolu
|
||||
return nil, errors.Errorf("fetch disk by id %s", disk.Id)
|
||||
}
|
||||
ret := &hostapi.ContainerVolumeMountDisk{
|
||||
Index: disk.Index,
|
||||
Id: disk.Id,
|
||||
TemplateId: diskObj.TemplateId,
|
||||
SubDirectory: disk.SubDirectory,
|
||||
StorageSizeFile: disk.StorageSizeFile,
|
||||
Overlay: disk.Overlay,
|
||||
CaseInsensitive: disk.CaseInsensitive,
|
||||
Index: disk.Index,
|
||||
Id: disk.Id,
|
||||
TemplateId: diskObj.TemplateId,
|
||||
SubDirectory: disk.SubDirectory,
|
||||
StorageSizeFile: disk.StorageSizeFile,
|
||||
Overlay: disk.Overlay,
|
||||
CaseInsensitivePaths: disk.CaseInsensitivePaths,
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
@@ -173,13 +173,18 @@ func (d disk) Mount(pod IPodInfo, ctrId string, vm *hostapi.ContainerVolumeMount
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "make sub_directory %s inside %s: %s", vmDisk.SubDirectory, mntPoint, out)
|
||||
}
|
||||
if vmDisk.CaseInsensitive {
|
||||
if err := d.setDirCaseInsensitive(subDir); err != nil {
|
||||
return errors.Wrapf(err, "enable case_insensitive %s", subDir)
|
||||
for _, cd := range vmDisk.CaseInsensitivePaths {
|
||||
cdp := filepath.Join(subDir, cd)
|
||||
out, err := procutils.NewRemoteCommandAsFarAsPossible("mkdir", "-p", cdp).Output()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "make %s inside %s: %s", cdp, vmDisk.SubDirectory, out)
|
||||
}
|
||||
if err := d.setDirCaseInsensitive(cdp); err != nil {
|
||||
return errors.Wrapf(err, "enable case_insensitive %s", cdp)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if vmDisk.CaseInsensitive {
|
||||
if len(vmDisk.CaseInsensitivePaths) != 0 {
|
||||
return errors.Errorf("only sub_directory can use case_insensitive")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,12 +396,16 @@ func FormatPartition(path, fs, uuid string, fsFeatures *apis.FsFeatures) error {
|
||||
cmdUuid = []string{"tune2fs", "-U", uuid}
|
||||
case fs == "ext4":
|
||||
feature := "^64bit"
|
||||
extendOpts := "lazy_itable_init=1"
|
||||
if fsFeatures != nil && fsFeatures.Ext4 != nil {
|
||||
if fsFeatures.Ext4.CaseInsensitive {
|
||||
feature = fmt.Sprintf("%s,casefold", feature)
|
||||
feature = fmt.Sprintf("%s,casefold,project,quota", feature)
|
||||
//feature = fmt.Sprintf("casefold,project,quota")
|
||||
extendOpts = fmt.Sprintf("%s,nodiscard,lazy_journal_init=1,encoding_flags=strict,encoding=utf8-12.1", extendOpts)
|
||||
}
|
||||
}
|
||||
cmd = []string{"mkfs.ext4", "-O", feature, "-E", "lazy_itable_init=1"}
|
||||
cmd = []string{"mkfs.ext4", "-O", feature, "-E", extendOpts}
|
||||
log.Infof("===========format partion cmd: %#v", cmd)
|
||||
/*
|
||||
// see /etc/mke2fs.conf, default inode_ratio is 16384
|
||||
If this option is is not specified, mke2fs will pick a single default usage type based on the size
|
||||
|
||||
@@ -237,10 +237,10 @@ func parseContainerVolumeMount(vmStr string) (*apis.ContainerVolumeMount, error)
|
||||
vm.Disk = &apis.ContainerVolumeMountDisk{}
|
||||
}
|
||||
vm.Disk.StorageSizeFile = val
|
||||
case "case_insensitive", "casefold":
|
||||
if strings.ToLower(val) == "true" {
|
||||
vm.Disk.CaseInsensitive = true
|
||||
}
|
||||
//case "case_insensitive", "casefold":
|
||||
// if strings.ToLower(val) == "true" {
|
||||
// vm.Disk.CaseInsensitive = true
|
||||
// }
|
||||
case "overlay":
|
||||
if vm.Disk == nil {
|
||||
vm.Disk = &apis.ContainerVolumeMountDisk{}
|
||||
|
||||
Reference in New Issue
Block a user