Skip to content
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

Sync SONiC host's timezone to all containers #9493

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gord1306
Copy link

Sync the content of /etc/timezone and /etc/localtime from the SONiC host to all containers
during their own systemd services be started.

Why I did it

The containers are not awared the timezone change in the SONiC host, it may cause some info
are inconsistent e.g. time gap between syslog and swss.rec/sairedis.rec

How I did it

In the systemd scripts of services, then timezone of containers will be sync in the postStartAction()
and therefore the containers will have same timezone after their own services are restarted

How to verify it

Change the timezone in the SONiC host and then exec the sudo config reload -y
To check the containers timezone are changed

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106

Description for the changelog

A picture of a cute animal (not mandatory but encouraged)

@gord1306 gord1306 requested a review from lguohan as a code owner December 10, 2021 06:52
@gord1306
Copy link
Author

gord1306 commented Dec 13, 2021

/azpw run

@mssonicbld
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list.

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 9493 in repo Azure/sonic-buildimage

Sync the content of /etc/timezone and /etc/localtime from the SONiC host
to all containers during their own systemd services be started.
@bsun-sudo
Copy link
Contributor

If there is a runtime change of timezone in the host, would all running containers pick up the new timezone automatically?

@gord1306
Copy link
Author

If there is a runtime change of timezone in the host, would all running containers pick up the new timezone automatically?

No, the timezone would not be applied automatically. It is only applied during service starting.
Users can use the command - e.g. systemctl restart systemctl restart sonic.target to make the timezone be sync to the containers

@bsun-sudo
Copy link
Contributor

bsun-sudo commented Sep 1, 2022

systemctl restart systemctl restart sonic.target

Do you mean each docker need to be restarted to sync its timezone with the host's timezone? Or only restart the services in each docker use the timezone?

@gord1306
Copy link
Author

gord1306 commented Sep 2, 2022

systemctl restart systemctl restart sonic.target

Do you mean each docker need to be restarted to sync its timezone with the host's timezone? Or only restart the services in each docker use the timezone?

Yes, the script would be executed while the service is restarted and the restarted operation includes restarting the container. It is triggered by using the systemctl restart command. If you are asking for the docker restart command only, the answer would be no. The script is not triggered to execute by the docker restart command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants