-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow searching $TZDIR for timezone data #21063
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
glibc supports the environment variable as additional search path, means we allow to override the `/usr/share/zoneinfo` path by setting the variable. Analogous change to containers/common#1772 Signed-off-by: Sascha Grunert <[email protected]>
@@ -1708,6 +1708,14 @@ func (c *Container) mountStorage() (_ string, deferredErr error) { | |||
tz := c.Timezone() | |||
if tz != "" { | |||
timezonePath := filepath.Join("/usr/share/zoneinfo", tz) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all of this come from the similar code in containers/common?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say yes, especially since we have a clone of that code in cri-o/cri-o#7589. I stated that in cri-o/cri-o#7550 (comment). For CRI-O we would like to still maintain our own config field but reuse the helper functions per cri-o/cri-o#7550 (comment).
// https://sourceware.org/git/?p=glibc.git;a=blob;f=time/tzfile.c;h=8a923d0cccc927a106dc3e3c641be310893bab4e;hb=HEAD#l149 | ||
tzdir := os.Getenv("TZDIR") | ||
if tzdir != "" { | ||
timezonePath = filepath.Join(tzdir, tz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait.... this seems wrong to me, it's completely different from the append-path approach in your c-c PR. And I don't see any other basic utils if TZDIR is missing. I'm still investigating, but for now, let's block this
/hold
(Oh, also, what Dan said. We don't want two inconsistent implementations. But that might be a bigger problem)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah so the question to me would be: Do we want to mimic the glibc behavior and use $TZDIR
as override or do we want to place it as a higher priority path? I'm leaning towards the override.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The glibc code you linked to implements it as an override; the wording in tzset(3)
seems to confirm:
TZDIR If this variable is set its value takes precedence over the system configured timezone database directory path.
Okay, so it's c-c that is wrong. It squicks me out to have podman actually error out, instead of just ignoring the error, but there's precedent (podman run --tz=Foo/Bar
also fails), so okay.
Please fix it so it actually works though (my Abc/Def
test above).
Thanks for your PR and for providing good reference sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, following-up in c/common: containers/common#1774
@@ -513,6 +513,11 @@ json-file | f | |||
assert "$output" == "../usr/share/zoneinfo/Europe/Berlin" "localtime is linked correctly" | |||
} | |||
|
|||
@test "podman run --tz with zoneinfo and custom TZDIR env" { | |||
# Setting the timezone should fail because it does not exist | |||
TZDIR="$PODMAN_TMPDIR/zoneinfo" run_podman 127 run --rm --tz Europe/Berlin "$SYSTEMD_IMAGE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please don't just do error-status checks. Error messages must be confirmed:
assert "$output" =~ "Error: setting timezone for container .*: stat $PODMAN_TMPDIR/zoneinfo/Europe/Berlin: no such file or directory"
Also,
skip_if_remote "TZDIR not propagated remotely"
Also, it doesn't seem to be working: $ mkdir -p /tmp/zoneinfo/Abc
$ cp /usr/share/zoneinfo/Pacific/Chatham /tmp/zoneinfo/Abc/Def
$ TZDIR=/tmp/zoneinfo TZ=Abc/Def date
Thu Dec 21 03:15:13 AM +1345 2023 <--- OK, it works on f39
$ TZDIR=/tmp/zoneinfo bin/podman run --rm --tz=Abc/Def quay.io/libpod/testimage:20221018 date
Error: running container create option: finding timezone: unknown time zone Abc/Def
^^^^^ but not with podman |
@sohankunkerkar @rhatdan @vrothberg @edsantiago @Luap99 considering cri-o/cri-o#7589, do we want to move the timezone related bits into c/common helper functions and reuse them in CRI-O and Podman? |
Yeah, that's a good idea. We can reuse the |
Awesome, let me close this one then and vendor c/common code once it is there. |
The TZDIR environment variable override the lookup paths and does not append them. This patch fixes that behavior and is a follow-up on: containers#1772 Ref: containers/podman#21063 (comment) Signed-off-by: Sascha Grunert <[email protected]>
The TZDIR environment variable override the lookup paths and does not append them. This patch fixes that behavior and is a follow-up on: containers#1772 Ref: containers/podman#21063 (comment) Signed-off-by: Sascha Grunert <[email protected]>
The TZDIR environment variable override the lookup paths and does not append them. This patch fixes that behavior and is a follow-up on: containers#1772 Ref: containers/podman#21063 (comment) Signed-off-by: Sascha Grunert <[email protected]>
glibc supports the environment variable as additional search path, means we allow to override the
/usr/share/zoneinfo
path by setting the variable.Analogous change to containers/common#1772
Does this PR introduce a user-facing change?