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

Check if system is synchronized on NTP #16

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

Conversation

pulkomandy
Copy link
Contributor

Hello,

You may not want to merge this since we ended up rewriting a lot of things and it may be growing out of scope of what alarm-fake-hwclock is meant to do. Anyways, here it is for reference, at least.

The issue we have encountered:

If, for some reason, the date of the reference file ends up being set some time in the future, alarm-fake-hwclock will keep restoring that date every time it is run, even if we have a better date set from NTP. This leads to the date being set in the future every 15 minutes as alarm-fake-hwclock runs, and then set back to the right time by NTP, but the correct date is never stored in the reference file.

To fix this, we decided to have alarm-fake-hwclock query the NTP client and check if the clock is currently synchronized. In that case, it will assume that clock is correct, and never use the time from the reference file. Otherwise (including if there is no NTP client running), things work as usual.

SENTENAC Jean and others added 3 commits July 2, 2024 14:40
[LCB-1272] CHeck synchro NTP before setting time

See merge request liebherr-mining/alarm-fake-hwclock!1
@@ -8,7 +8,6 @@ Wants=fake-hwclock.timer
[Service]
Type=simple
ExecStart=/usr/bin/fake-hwclock
ExecStop=/usr/bin/fake-hwclock
Copy link
Contributor Author

@pulkomandy pulkomandy Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is removed because it doesn't work as intended: the idea was (if I understand correctly) to start fake-hwclock at shutdown when the unit is stopped. But with the unit being of "simple" type, this instead results in fake-hwclock being run by ExecStart, and then immediately again by ExecStop, and not run at shutdown.

We don't have time to investigate and fix this at the moment, and it is not too critical in our use case, but we may have a look later and do a separate merge request about it. Until then, running the tool twice isn't useful, and can be removed.

Maybe it would work with a service of type oneshot, but I'm not entirely sure if that would work with the systemd timer to restart it periodically.

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.

1 participant