From b6329b5c2364c1d43a3e71102ae43dcd3531cbcd Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Wed, 24 Sep 2025 18:52:48 +0800 Subject: [PATCH] fix(host-deployer): loop dev resize diskfs umounted and f2fs support (#23358) --- pkg/hostman/diskutils/fsutils/fsutils.go | 14 ++++++++++---- pkg/hostman/guestman/pod_helper.go | 2 +- .../hostdeployer/deployserver/deployserver.go | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/hostman/diskutils/fsutils/fsutils.go b/pkg/hostman/diskutils/fsutils/fsutils.go index 205656670d..38bfec3115 100644 --- a/pkg/hostman/diskutils/fsutils/fsutils.go +++ b/pkg/hostman/diskutils/fsutils/fsutils.go @@ -174,13 +174,19 @@ func (d *SFsutilDriver) ResizeDiskPartition(diskPath string, sizeMb int) (string if len(parts) > 0 && (label == "gpt" || (label == "msdos" && parts[len(parts)-1][5] == "primary")) { var part = parts[len(parts)-1] - if part[5] == "lvm" || IsSupportResizeFs(part[6]) { + fsType := part[6] + if len(fsType) == 0 { + partDev := fmt.Sprintf("%s%s", diskPath, part[0]) + fsType = d.GetFsFormat(partDev) + log.Infof("blkid get fstype %s", fsType) + } + if part[5] == "lvm" || IsSupportResizeFs(fsType) { // growpart script replace parted resizepart output, err := d.Exec("growpart", diskPath, part[0]) if err != nil { return "", "", errors.Wrapf(err, "growpart failed %s", output) } - return part[7], part[6], nil + return part[7], fsType, nil } } return "", "", nil @@ -263,7 +269,7 @@ func IsSupportResizeFs(fs string) bool { return true } else if strings.HasPrefix(fs, "ext") { return true - } else if fs == "xfs" { + } else if fs == "xfs" || fs == "f2fs" { return true } return false @@ -330,7 +336,7 @@ func (d *SFsutilDriver) ResizePartitionFs(fpath, fs string, raiseError, onlineRe // cmds = [][]string{{"ntfsresize", "-c", fpath}, {"ntfsresize", "-P", "-f", fpath}} } else if fs == "f2fs" { if !onlineResize { - cmds = [][]string{{"resize.f2fs"}} + cmds = [][]string{{"resize.f2fs", fpath}} } } diff --git a/pkg/hostman/guestman/pod_helper.go b/pkg/hostman/guestman/pod_helper.go index 98b51dccf7..514a43f5a7 100644 --- a/pkg/hostman/guestman/pod_helper.go +++ b/pkg/hostman/guestman/pod_helper.go @@ -308,7 +308,7 @@ func (m *SCpuFreqRealTimeSimulateManager) startSetCpuFreqSimulate() { } cpuDir := pod.getContainerSystemCpusDir(ctr.Id) if !fileutils2.Exists(cpuDir) { - log.Errorf("%s %s has no cpuDir", pod.GetName(), criIds[i]) + log.Debugf("%s %s has no cpuDir", pod.GetName(), criIds[i]) continue } diff --git a/pkg/hostman/hostdeployer/deployserver/deployserver.go b/pkg/hostman/hostdeployer/deployserver/deployserver.go index 6a8737cbc7..2a0a170bc8 100644 --- a/pkg/hostman/hostdeployer/deployserver/deployserver.go +++ b/pkg/hostman/hostdeployer/deployserver/deployserver.go @@ -135,7 +135,7 @@ func (*DeployerServer) ResizeFs(ctx context.Context, req *deployapi.ResizeFsPara log.Infof("********* Resize fs on %#v", req.DiskInfo) if strings.HasPrefix(req.DiskInfo.Path, "/dev/loop") { // HACK: container loop device, do resize locally - if err := fsutils.ResizeDiskFs(req.DiskInfo.Path, 0, true); err != nil { + if err := fsutils.ResizeDiskFs(req.DiskInfo.Path, 0, false); err != nil { return new(deployapi.Empty), errors.Wrap(err, "fsutils.ResizeDiskFs") } return new(deployapi.Empty), nil