-
Notifications
You must be signed in to change notification settings - Fork 1.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
[Bookworm] Timezone setting is not propagated to containers #20925
Comments
@nmoray can the logic be updated instead to use /etc/localtime directly from host instead of using /etc/timezone |
@vivekrnv It is not recommended to mount the symlink. That is why, I mounted only the timezone and is creating the symlink at docker runtime. |
Hmm, so one way i could think is this. @nmoray Can you try if this solves the problem?
|
@nmoray, could you please take a look at Vivek's comments and rework your patch? |
@prabhataravind Okay, let me look into it. |
I haven't but looks like that command is used in older systems or systems without systemd. Besides "config clock" command, in our deployments we use DHCP for mgmt ip. When eth0 recieved mgmt-ip, it also invokes the timedatectl command and changes the timezone. Thus, we should consider timedatectl as the command that is used to change timezone and work upon it to solve this issue |
@vivekrnv Okay. IMO, following change will not work out. When the container is rebooted, "timedatectl show -p Timezone --value" will always return the timezone set inside the container only. So it will eventually create the symlink based on the default timezone only.
Presently, I can think of three options to solve this issue.
|
@vivekrnv There is one better way. The method timezone_update() from hostcfgd is responsible for updating the timezone. We can update the /etc/timezone file inside this method.
|
@vivekrnv Please try out this fix and let me know if it works. |
@nmoray, I'm in favour of option 3, did some preliminary testing and the change is working. I know its not ideal but this should work as long as the container has tzdata package installed. Problem with option 1 & 2, they can solve the "config cli" flow but not the timezone setting through DHCP flow. Eg for the dhcp flow:
For both flows to work, i could only think of option 3. I will raise a fix for this |
@vivekrnv one way to fix your DHCP flow is by overriding systemd-timedated.service. We can write the new timezone in /etc/timezone file as a part of ExecStartPost. This way, we can achieve our goal with minimal change. |
@vivekrnv for your reference,
Note: I tested it on the earlier debian version so I used nik_timezone as a temporary file in place of /etc/timezone. |
/etc/timezone is deprecated in Debian. In SONiC, we should try to stay close to Debian for generic config and thus I’m not in favor in patching systemd to update /etc/timezone. |
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md ** Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it Fix sonic-net#20925 Not cherry-pickable to 202405, will raise a separate PR #### How I did it Mount /etc/localtime on containers and remove /etc/timezone dependency #### How to verify it ``` root@sonic:/home/admin# zdump /etc/localtime /etc/localtime Fri Dec 6 23:24:03 2024 IST root@sonic:/home/admin# docker exec swss zdump /etc/localtime /etc/localtime Fri Dec 6 23:24:12 2024 IST ``` Verify swss.rec/sairedis.rec and syslog are following same time <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it Fix #20925 Not cherry-pickable to 202405, will raise a separate PR #### How I did it Mount /etc/localtime on containers and remove /etc/timezone dependency #### How to verify it ``` root@sonic:/home/admin# zdump /etc/localtime /etc/localtime Fri Dec 6 23:24:03 2024 IST root@sonic:/home/admin# docker exec swss zdump /etc/localtime /etc/localtime Fri Dec 6 23:24:12 2024 IST ``` Verify swss.rec/sairedis.rec and syslog are following same time <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [ ] <!-- image version 1 --> - [ ] <!-- image version 2 --> #### Description for the changelog <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
- Why I did it Fix sonic-net#20925 Not cherry-pickable to 202405, will raise a separate PR - How I did it Mount /etc/localtime on containers and remove /etc/timezone dependency - How to verify it root@sonic:/home/admin# zdump /etc/localtime /etc/localtime Fri Dec 6 23:24:03 2024 IST root@sonic:/home/admin# docker exec swss zdump /etc/localtime /etc/localtime Fri Dec 6 23:24:12 2024 IST Verify swss.rec/sairedis.rec and syslog are following same time Signed-off-by: Vivek <vkarri@nvidia.com>
Description
Timezone setting is expected to propagate to the containers. But after bookworm upgrade in SONiC, it is broken
202311
config clock timezone Asia/Pyongyang
202405 and above:
After config reload, containers are expected to have timezone change but it is not seen
Triage
Issue lies in timedatectl command not updating /etc/timezone in systemd version used on bookworm
Ref: https://unix.stackexchange.com/questions/451709/timedatectl-set-timezone-doesnt-update-etc-timezone
This PR #14000 (Which fixes the timesync issue between host and container) uses /etc/timezone as reference to update the timezone in container.
The text was updated successfully, but these errors were encountered: