summaryrefslogtreecommitdiff
path: root/redfish-core/include
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-03-07 21:13:14 +0300
committerEd Tanous <ed@tanous.net>2024-03-19 01:31:07 +0300
commitc51afd54a55d5c8d6cb6e9583e209788f7996fe3 (patch)
tree6dc363cb66c1a1205904220b8a486acb86b48e1c /redfish-core/include
parent53b00f5d985d055bddd175f7192128ae7c3286a2 (diff)
downloadbmcweb-c51afd54a55d5c8d6cb6e9583e209788f7996fe3.tar.xz
Call systemd SetTime directly
Internally inside phosphor-time-manager, the elapsed(uint64) dbus call just forwards the request directly to systemd after static casting to int64_t (signed). bmcweb should just call systemd directly, for several reasons. phosphor-timesyncd might block on other calls, given it's a single threaded blocking design, due to bugs like #264. Calling systemd directly means that calls that don't require phosphor networkd won't be blocked. Calling systemd directly allows bmcweb to drop some code that parses a date as int64_t, then converts it to uint64_t to fulfill the phosphor datetime interface. We can now keep int64_t all the way through. Calling systemd directly allows bmcweb to give a more specific error code in the case there NTP is enabled, registering a PropertyValueConflict error, instead of a 500 InternalError. Tested: Patching DateTime property with NTP enabled returns 400, PropertyValueConflict ``` curl -vvvv -k --user "root:0penBmc" -H "Content-Type: application/json" -X PATCH -d '{"DateTime":"2020-12-15T15:40:52+00:00"}' https://192.168.7.2/redfish/v1/Managers/bmc ``` Disabling NTP using the following command: ``` curl -vvvv -k --user "root:0penBmc" -H "Content-Type: application/json" -X PATCH -d '{"NTP":{"ProtocolEnabled":false}}' https://192.168.7.2/redfish/v1/Managers/bmc/NetworkProtocol ``` Allows the prior command to succeed. [1] https://github.com/openbmc/phosphor-time-manager/blob/5ce9ac0e56440312997b25771507585905e8b360/bmc_epoch.cpp#L126 Change-Id: I6fbb6f63e17de8ab847ca5ed4eadc2bd313586d2 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core/include')
-rw-r--r--redfish-core/include/utils/time_utils.hpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/redfish-core/include/utils/time_utils.hpp b/redfish-core/include/utils/time_utils.hpp
index ee7dd4a013..30011e3d9b 100644
--- a/redfish-core/include/utils/time_utils.hpp
+++ b/redfish-core/include/utils/time_utils.hpp
@@ -417,7 +417,7 @@ inline std::pair<std::string, std::string> getDateTimeOffsetNow()
return std::make_pair(dateTime, timeOffset);
}
-using usSinceEpoch = std::chrono::duration<uint64_t, std::micro>;
+using usSinceEpoch = std::chrono::duration<int64_t, std::micro>;
std::optional<usSinceEpoch> dateStringToEpoch(std::string_view datetime);
} // namespace time_utils
} // namespace redfish