Skip to content

Commit 87dfcf7

Browse files
swordqiuQiu Jian
andauthored
fix: always update hostname for rhel-like os (#23016)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
1 parent c0562f2 commit 87dfcf7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/hostman/guestfs/fsdriver/linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,10 +1316,10 @@ func (r *sRedhatLikeRootFs) DeployHostname(rootFs IDiskPartition, hn, domain str
13161316
centosHn += "NETWORKING=yes\n"
13171317
centosHn += fmt.Sprintf("HOSTNAME=%s\n", getHostname(hn, domain))
13181318
if err := rootFs.FilePutContents(sPath, centosHn, false, false); err != nil {
1319-
return err
1319+
return errors.Wrapf(err, "DeployHostname %s", sPath)
13201320
}
1321-
if rootFs.Exists("/etc/hostname", false) {
1322-
return rootFs.FilePutContents("/etc/hostname", hn, false, false)
1321+
if err := rootFs.FilePutContents("/etc/hostname", hn, false, false); err != nil {
1322+
return errors.Wrapf(err, "DeployHostname %s", "/etc/hostname")
13231323
}
13241324
return nil
13251325
}

0 commit comments

Comments
 (0)