diff --git a/build/docker/Dockerfile.host-deployer b/build/docker/Dockerfile.host-deployer index 3561416845..a23d73055c 100644 --- a/build/docker/Dockerfile.host-deployer +++ b/build/docker/Dockerfile.host-deployer @@ -1,16 +1,9 @@ -FROM registry.cn-beijing.aliyuncs.com/yunionio/yunionos:v3.10.8-20231215.0-vm as yunionos -FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:1.4.3 +FROM registry.cn-beijing.aliyuncs.com/yunionio/host-deployer-base:1.4.4 MAINTAINER "Yaoqi Wan wanyaoqi@yunionyun.com" ENV TZ UTC RUN mkdir -p /opt/yunion/bin -RUN mkdir -p /yunionos/x86_64 -RUN mkdir -p /yunionos/aarch64 -COPY --from=yunionos /yunionos/x86_64/initramfs /yunionos/x86_64/initramfs -COPY --from=yunionos /yunionos/x86_64/kernel /yunionos/x86_64/kernel -COPY --from=yunionos /yunionos/aarch64/kernel /yunionos/aarch64/kernel -COPY --from=yunionos /yunionos/aarch64/initramfs /yunionos/aarch64/initramfs ADD ./_output/centos-build/bin/host-deployer /opt/yunion/bin/host-deployer diff --git a/pkg/hostman/diskutils/fsutils/fsutils.go b/pkg/hostman/diskutils/fsutils/fsutils.go index a787d463d9..eb52a4060b 100644 --- a/pkg/hostman/diskutils/fsutils/fsutils.go +++ b/pkg/hostman/diskutils/fsutils/fsutils.go @@ -18,7 +18,6 @@ import ( "fmt" "io" "io/ioutil" - "path" "regexp" "strconv" "strings" @@ -140,7 +139,6 @@ func ResizeDiskFs(diskPath string, sizeMb int) error { } parts, label := ParseDiskPartition(diskPath, strings.Split(string(lines), "\n")) log.Infof("Parts: %v label: %s", parts, label) - maxSector := GetDevSector512Count(path.Base(diskPath)) if label == "gpt" { proc := procutils.NewCommand("gdisk", diskPath) stdin, err := proc.StdinPipe() @@ -188,26 +186,12 @@ func ResizeDiskFs(diskPath string, sizeMb int) error { } if len(parts) > 0 && (label == "gpt" || (label == "msdos" && parts[len(parts)-1][5] == "primary")) { - var ( - part = parts[len(parts)-1] - end int - ) - if sizeMb > 0 { - end = sizeMb * 1024 * 2 - } else if label == "gpt" { - end = maxSector - 35 - } else { - end = maxSector - 1 - } - if label == "msdos" && end >= 4294967296 { - end = 4294967295 - } + var part = parts[len(parts)-1] if IsSupportResizeFs(part[6]) { - cmds := []string{"parted", "-a", "none", "-s", diskPath, "--", "resizepart", part[0], fmt.Sprintf("%ds", end)} - log.Infof("resize disk partition: %s", cmds) - output, err := procutils.NewCommand(cmds[0], cmds[1:]...).Output() + // growpart script replace parted resizepart + output, err := procutils.NewCommand("growpart", diskPath, part[0]).Output() if err != nil { - return errors.Wrapf(err, "parted failed %s", output) + return errors.Wrapf(err, "growpart failed %s", output) } err, _ = ResizePartitionFs(part[7], part[6], false) if err != nil { diff --git a/pkg/hostman/hostdeployer/deployserver/deployserver.go b/pkg/hostman/hostdeployer/deployserver/deployserver.go index 0e921001c0..fe002a8e88 100644 --- a/pkg/hostman/hostdeployer/deployserver/deployserver.go +++ b/pkg/hostman/hostdeployer/deployserver/deployserver.go @@ -344,25 +344,21 @@ func (s *SDeployService) PrepareEnv() error { } } else { // prepare for yunionos don't have but necessary files - out, err := procutils.NewCommand("cp", "-rf", "/usr/bin/chntpw.static", "/opt/yunion/bin/chntpw.static").Output() + out, err := procutils.NewCommand("mkdir", "-p", "/opt/yunion/bin/bundles").Output() if err != nil { return errors.Wrapf(err, "cp files failed %s", out) } - out, err = procutils.NewCommand("cp", "-rf", "/usr/bin/.chntpw.static.bin", "/opt/yunion/bin/.chntpw.static.bin").Output() - if err != nil { - return errors.Wrapf(err, "cp files failed %s", out) - } - out, err = procutils.NewCommand("mkdir", "-p", "/opt/yunion/bin/bundles").Output() - if err != nil { - return errors.Wrapf(err, "cp files failed %s", out) - } - out, err = procutils.NewCommand("cp", "-rf", "/usr/bin/bundles/chntpw.static", "/opt/yunion/bin/bundles/chntpw.static").Output() - if err != nil { - return errors.Wrapf(err, "cp files failed %s", out) - } - out, err = procutils.NewCommand("cp", "-rf", "/usr/sbin/zerofree", "/opt/yunion/bin/zerofree").Output() - if err != nil { - return errors.Wrapf(err, "cp files failed %s", out) + for k, v := range map[string]string{ + "/usr/bin/chntpw.static": "/opt/yunion/bin/chntpw.static", + "/usr/bin/.chntpw.static.bin": "/opt/yunion/bin/.chntpw.static.bin", + "/usr/bin/bundles/chntpw.static": "/opt/yunion/bin/bundles/chntpw.static", + "/usr/bin/growpart": "/opt/yunion/bin/growpart", + "/usr/sbin/zerofree": "/opt/yunion/bin/zerofree", + } { + out, err = procutils.NewCommand("cp", "-rf", k, v).Output() + if err != nil { + return errors.Wrapf(err, "cp files failed %s", out) + } } { diff --git a/pkg/hostman/hostdeployer/deployserver/localdeploy.go b/pkg/hostman/hostdeployer/deployserver/localdeploy.go index 146ed422a8..f20736899f 100644 --- a/pkg/hostman/hostdeployer/deployserver/localdeploy.go +++ b/pkg/hostman/hostdeployer/deployserver/localdeploy.go @@ -106,7 +106,7 @@ func LocalInitEnv() error { "/sbin", "/usr/bin", "/usr/sbin", - "/opt/yunion/bin", // for zerofree command + "/opt/yunion/bin", // for zerofree and growpart command } err := os.Setenv("PATH", strings.Join(paths, ":")) if err != nil { diff --git a/pkg/hostman/storageman/disk_rbd.go b/pkg/hostman/storageman/disk_rbd.go index b89defeaf3..57a49e73f1 100644 --- a/pkg/hostman/storageman/disk_rbd.go +++ b/pkg/hostman/storageman/disk_rbd.go @@ -133,7 +133,8 @@ func (d *SRBDDisk) Resize(ctx context.Context, params interface{}) (jsonutils.JS Path: d.GetPath(), } if err := d.ResizeFs(resizeFsInfo); err != nil { - return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) + log.Errorf("Resize fs %s fail %s", d.GetPath(), err) + // return nil, errors.Wrapf(err, "resize fs %s", d.GetPath()) } return d.GetDiskDesc(), nil