Skip to content

Commit 193d7b8

Browse files
committed
pkg/machine: properly setup zoneinfo symlink
If you run timedatectl inside it will not show the correct timezone, it seems systemd really wants a relative link which is also documented by coreos[1]. Also we can just use path.Join() directly and don't have to convert the path again on windows. [1] https://docs.fedoraproject.org/en-US/fedora-coreos/time-zone/#_setting_the_time_zone_via_ignition Signed-off-by: Paul Holzinger <[email protected]>
1 parent b431f06 commit 193d7b8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/machine/e2e/init_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ var _ = Describe("podman machine init", func() {
280280
Expect(err).ToNot(HaveOccurred())
281281
Expect(timezoneSession).To(Exit(0))
282282
Expect(timezoneSession.outputToString()).To(ContainSubstring("HST"))
283+
284+
sshTimezone = sshMachine{}
285+
timezoneSession, err = mb.setName(name).setCmd(sshTimezone.withSSHCommand([]string{"timedatectl show --property Timezone"})).run()
286+
Expect(err).ToNot(HaveOccurred())
287+
Expect(timezoneSession).To(Exit(0))
288+
Expect(timezoneSession.outputToString()).To(ContainSubstring("Pacific/Honolulu"))
283289
})
284290

285291
It("machine init with volume", func() {

pkg/machine/ignition/ignition.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,11 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
166166
},
167167
LinkEmbedded1: LinkEmbedded1{
168168
Hard: BoolToPtr(false),
169-
// We always want this value in unix form (/path/to/something) because this is being
170-
// set in the machine OS (always Linux). However, filepath.join on windows will use a "\\"
171-
// separator; therefore we use ToSlash to convert the path to unix style
172-
Target: filepath.ToSlash(filepath.Join("/usr/share/zoneinfo", tz)),
169+
// We always want this value in unix form (../usr/share/zoneinfo) because this is being
170+
// set in the machine OS (always Linux) and systemd needs the relative symlink. However,
171+
// filepath.join on windows will use a "\\" separator so use path.Join() which always
172+
// uses the slash.
173+
Target: path.Join("../usr/share/zoneinfo", tz),
173174
},
174175
}
175176
ignStorage.Links = append(ignStorage.Links, tzLink)

0 commit comments

Comments
 (0)