After NTP synchronization if I try to enquire the host OS over Dbus immediately, I observed it returning false. I am using that timestamp with NTP synchronization as my status, but it’s returning that the correct synchronized time is false.
Should I consider any delay before enquiring NTP synchronization over Dbus after NTP is synchronized to receive the correct status?
I’m not entirely sure I understand the part where you mention that you check NTP is synchronised and then check via DBUS separately.
The documentation to check NTP time is via DBUS. There is a dict entry that has the string NTPSynchronized. Once that is returned true, time is synchronized. And the same dbus return has an entry for timeUsec which is since epoch. Does the next DBUS query immediately afterwards return false in NTPSynchronized? I checked on a Beaglebone + v2.16.7 I had running and ran dbus-send in a loop and that only returned NTPSynchronized as true.
The only thing I can guess is that you ran timedatectl and that returned NTP synchronised: yes And then immediately afterwards, ran the DBUS command which didn’t yet respond with NTPSynchronized?
Status here is “NTP synchronised:” response of DBUS query. It returned False like above for about 32 secs after NTP synchronized and then it’s returning True.
for example Jul 03 16:04:18.330 DEBUG: Time: 2018-07-03T16:04:18.219710, Status: 0 here time is NTP synchronized but it returned False. I can see the correct status again after 32 secs. Do I need to consider some delay in checking for NTP synchronization over Dbus?
so, it’s returning True after NTP synchronized and then the subsequent queries returning False for 32 secs and True from then onwards.
Didn’t see NTP respond false at any point.
Not really sure what else we can do if we cannot replicate it.
Time/NTP should not loose sync unless something is messing with clocks/network times etc.
Whenever I loose internet for an extended period of time and a power cycle(Where fake hw clock fails) when there is no internet, I loose NTP. After power cycle, when I get internet back if I keep checking for NTP synchronization, I observed that there is a NTP sync happened, the status was true for less than 1 sec and then the status returned false(I can read correct NTP time in this period) for 32 secs and then it was true thereafter.
Looks like NTP is taking a bit of time to stabilise. And there is a one-off NTP Sync status reported but then NTP thinks it has synchronised before settling down.
I’d recommend re-checking NTP Synchronisation once every second for 10 times. If it is true for 10 times, consider the time to be correct. This will disregard the one-off NTP Sync status you see.
In resinOS v2.13 we have moved to a better NTP daemon called chrony. The previous one was systemd-timesyncd. It might be better but I cannot guarantee that you won’t see similar behaviour. I’d still recommend that you check NTPSync 10 times via dbus over 10 seconds before considering time to be accurate.
I will try to copy the /etc/timezone to target. If you build your image, you need to copy it to your Dockerfile. Before copy this file, you are able to check the timezone as your wanted timezone.