/openbmc/phosphor-time-manager/ |
H A D | settings.hpp | diff e101030b37eb8f64616a33eb0ef71d67a19bf7d7 Mon Apr 01 23:20:43 CDT 2024 Jason Zhu <zhujiesen@bytedance.com> Synchronize NTP settings with systemd-timedated
Bmcweb get/set the "NTP settings" on phosphor-settings. phosphor-time-manager and phosphor-settings are responsible to sync the settings with systemd-timedated. So the services like bmcweb and ipmid will only have to get/set the property on phosphor-settings.
However, in order to avoid a race condition issue with NTP set, bmcweb now directly uses systemd instead of routing through phosphor-settings. As a result, there may be differences in the "NTP settings" between phosphor-setttings and systemd-timedated. To address this, this commit adds a match to monitor time sync method changes on systemd-timedated and updates it to phosphor-settings.
Tested: ``` 1. Get current NTP setting: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" }
2. Call method in systemd timedate, to change NTP setting: busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb false false
journal log: phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.Manual phosphor-time-manager[28150]: NTP property changed in systemd time service, update to phosphor-settings. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to systemd time service again.
3. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b false
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.Manual" }
4. Set property in phosphor-settings, to change NTP setting: busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP"
journal log: phosphor-time-manager[28150]: Updated NTP setting: True phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.NTP phosphor-time-manager[28150]: NTP property changed in phosphor-settings, update to systemd time service. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to phosphor-settings again.
5. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" } ```
Signed-off-by: Jason Zhu <zhujiesen@bytedance.com> Change-Id: I192d2257569f46aa0f5473331595c5242d816964
|
H A D | utils.hpp | diff e101030b37eb8f64616a33eb0ef71d67a19bf7d7 Mon Apr 01 23:20:43 CDT 2024 Jason Zhu <zhujiesen@bytedance.com> Synchronize NTP settings with systemd-timedated
Bmcweb get/set the "NTP settings" on phosphor-settings. phosphor-time-manager and phosphor-settings are responsible to sync the settings with systemd-timedated. So the services like bmcweb and ipmid will only have to get/set the property on phosphor-settings.
However, in order to avoid a race condition issue with NTP set, bmcweb now directly uses systemd instead of routing through phosphor-settings. As a result, there may be differences in the "NTP settings" between phosphor-setttings and systemd-timedated. To address this, this commit adds a match to monitor time sync method changes on systemd-timedated and updates it to phosphor-settings.
Tested: ``` 1. Get current NTP setting: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" }
2. Call method in systemd timedate, to change NTP setting: busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb false false
journal log: phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.Manual phosphor-time-manager[28150]: NTP property changed in systemd time service, update to phosphor-settings. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to systemd time service again.
3. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b false
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.Manual" }
4. Set property in phosphor-settings, to change NTP setting: busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP"
journal log: phosphor-time-manager[28150]: Updated NTP setting: True phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.NTP phosphor-time-manager[28150]: NTP property changed in phosphor-settings, update to systemd time service. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to phosphor-settings again.
5. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" } ```
Signed-off-by: Jason Zhu <zhujiesen@bytedance.com> Change-Id: I192d2257569f46aa0f5473331595c5242d816964
|
H A D | manager.hpp | diff e101030b37eb8f64616a33eb0ef71d67a19bf7d7 Mon Apr 01 23:20:43 CDT 2024 Jason Zhu <zhujiesen@bytedance.com> Synchronize NTP settings with systemd-timedated
Bmcweb get/set the "NTP settings" on phosphor-settings. phosphor-time-manager and phosphor-settings are responsible to sync the settings with systemd-timedated. So the services like bmcweb and ipmid will only have to get/set the property on phosphor-settings.
However, in order to avoid a race condition issue with NTP set, bmcweb now directly uses systemd instead of routing through phosphor-settings. As a result, there may be differences in the "NTP settings" between phosphor-setttings and systemd-timedated. To address this, this commit adds a match to monitor time sync method changes on systemd-timedated and updates it to phosphor-settings.
Tested: ``` 1. Get current NTP setting: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" }
2. Call method in systemd timedate, to change NTP setting: busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb false false
journal log: phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.Manual phosphor-time-manager[28150]: NTP property changed in systemd time service, update to phosphor-settings. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to systemd time service again.
3. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b false
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.Manual" }
4. Set property in phosphor-settings, to change NTP setting: busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP"
journal log: phosphor-time-manager[28150]: Updated NTP setting: True phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.NTP phosphor-time-manager[28150]: NTP property changed in phosphor-settings, update to systemd time service. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to phosphor-settings again.
5. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" } ```
Signed-off-by: Jason Zhu <zhujiesen@bytedance.com> Change-Id: I192d2257569f46aa0f5473331595c5242d816964
|
H A D | manager.cpp | diff e101030b37eb8f64616a33eb0ef71d67a19bf7d7 Mon Apr 01 23:20:43 CDT 2024 Jason Zhu <zhujiesen@bytedance.com> Synchronize NTP settings with systemd-timedated
Bmcweb get/set the "NTP settings" on phosphor-settings. phosphor-time-manager and phosphor-settings are responsible to sync the settings with systemd-timedated. So the services like bmcweb and ipmid will only have to get/set the property on phosphor-settings.
However, in order to avoid a race condition issue with NTP set, bmcweb now directly uses systemd instead of routing through phosphor-settings. As a result, there may be differences in the "NTP settings" between phosphor-setttings and systemd-timedated. To address this, this commit adds a match to monitor time sync method changes on systemd-timedated and updates it to phosphor-settings.
Tested: ``` 1. Get current NTP setting: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" }
2. Call method in systemd timedate, to change NTP setting: busctl call org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 SetNTP bb false false
journal log: phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.Manual phosphor-time-manager[28150]: NTP property changed in systemd time service, update to phosphor-settings. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to systemd time service again.
3. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b false
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.Manual" }
4. Set property in phosphor-settings, to change NTP setting: busctl set-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP"
journal log: phosphor-time-manager[28150]: Updated NTP setting: True phosphor-time-manager[28150]: Time mode has been changed to xyz.openbmc_project.Time.Synchronization.Method.NTP phosphor-time-manager[28150]: NTP property changed in phosphor-settings, update to systemd time service. phosphor-time-manager[28150]: NTP mode is already the same, skip setting to phosphor-settings again.
5. Get NTP setting again, NTP in phosphor-settings is synced with systemd-timedated: busctl get-property org.freedesktop.timedate1 /org/freedesktop/timedate1 org.freedesktop.timedate1 NTP b true
busctl get-property xyz.openbmc_project.Settings /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization TimeSyncMethod -j { "type" : "s", "data" : "xyz.openbmc_project.Time.Synchronization.Method.NTP" } ```
Signed-off-by: Jason Zhu <zhujiesen@bytedance.com> Change-Id: I192d2257569f46aa0f5473331595c5242d816964
|