Make DBus aggregation optional
There are a number of scenarios where Entity manager might not be
running, or might have errored out. For resilience, this should ONLY
result in the aggregated sources disappearing, and should not effect the
main collections.
One use case for this is local development and testing the aggregation.
To accomplish this, modify the getSatteliteConfigs function to always
call the callback, in the case of an error, calling with an empty map of
satellites.
Tested: Launched bmcweb directly with insecure-disable-auth and
redfish-aggregation enabled. Created an aggregated source:
```
curl -vvvv -k https://localhost:18080/redfish/v1/AggregationService/AggregationSources -H "Content-Type: application/json" --request POST --data '{"HostName":"https://10.114.132.149", "UserName": "root", "Password": "0penBmc"}'
```
Change-Id: Ica667fe27a35b33a99d0b411a06407b73efe6731
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp
index 3ac4ed7..4839a30 100644
--- a/redfish-core/include/redfish_aggregator.hpp
+++ b/redfish-core/include/redfish_aggregator.hpp
@@ -428,15 +428,8 @@
// Dummy callback used by the Constructor so that it can report the number
// of satellite configs when the class is first created
static void constructorCallback(
- const boost::system::error_code& ec,
const std::unordered_map<std::string, boost::urls::url>& satelliteInfo)
{
- if (ec)
- {
- BMCWEB_LOG_ERROR("Something went wrong while querying dbus!");
- return;
- }
-
BMCWEB_LOG_DEBUG("There were {} satellite configs found at startup",
std::to_string(satelliteInfo.size()));
}
@@ -695,19 +688,12 @@
AggregationType aggType,
const std::shared_ptr<crow::Request>& sharedReq,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::system::error_code& ec,
const std::unordered_map<std::string, boost::urls::url>& satelliteInfo)
{
if (sharedReq == nullptr)
{
return;
}
- // Something went wrong while querying dbus
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
// No satellite configs means we don't need to keep attempting to
// aggregate
@@ -944,8 +930,7 @@
// Expects a handler which interacts with the returned configs
void getSatelliteConfigs(
std::function<
- void(const boost::system::error_code&,
- const std::unordered_map<std::string, boost::urls::url>&)>
+ void(const std::unordered_map<std::string, boost::urls::url>&)>
handler) const
{
BMCWEB_LOG_DEBUG("Gathering satellite configs");
@@ -966,29 +951,29 @@
const dbus::utility::ManagedObjectType& objects) mutable {
if (ec)
{
- BMCWEB_LOG_ERROR("DBUS response error {}, {}", ec.value(),
- ec.message());
- handler(ec, satelliteInfo);
- return;
- }
-
- // Maps a chosen alias representing a satellite BMC to a url
- // containing the information required to create a http
- // connection to the satellite
- findSatelliteConfigs(objects, satelliteInfo);
-
- if (!satelliteInfo.empty())
- {
- BMCWEB_LOG_DEBUG(
- "Redfish Aggregation enabled with {} satellite BMCs",
- std::to_string(satelliteInfo.size()));
+ BMCWEB_LOG_WARNING("DBUS response error {}, {}", ec.value(),
+ ec.message());
}
else
{
- BMCWEB_LOG_DEBUG(
- "No satellite BMCs detected. Redfish Aggregation not enabled");
+ // Maps a chosen alias representing a satellite BMC to a url
+ // containing the information required to create a http
+ // connection to the satellite
+ findSatelliteConfigs(objects, satelliteInfo);
+
+ if (!satelliteInfo.empty())
+ {
+ BMCWEB_LOG_DEBUG(
+ "Redfish Aggregation enabled with {} satellite BMCs",
+ std::to_string(satelliteInfo.size()));
+ }
+ else
+ {
+ BMCWEB_LOG_DEBUG(
+ "No satellite BMCs detected. Redfish Aggregation not enabled");
+ }
}
- handler(ec, satelliteInfo);
+ handler(satelliteInfo);
});
}
diff --git a/redfish-core/lib/aggregation_service.hpp b/redfish-core/lib/aggregation_service.hpp
index 65d3ac7..f503459 100644
--- a/redfish-core/lib/aggregation_service.hpp
+++ b/redfish-core/lib/aggregation_service.hpp
@@ -81,15 +81,8 @@
inline void populateAggregationSourceCollection(
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::system::error_code& ec,
const std::unordered_map<std::string, boost::urls::url>& satelliteInfo)
{
- // Something went wrong while querying dbus
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
nlohmann::json::array_t members;
for (const auto& sat : satelliteInfo)
{
@@ -153,20 +146,12 @@
inline void populateAggregationSource(
const std::string& aggregationSourceId,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const boost::system::error_code& ec,
const std::unordered_map<std::string, boost::urls::url>& satelliteInfo)
{
asyncResp->res.addHeader(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/AggregationSource/AggregationSource.json>; rel=describedby");
- // Something went wrong while querying dbus
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
const auto& sat = satelliteInfo.find(aggregationSourceId);
if (sat == satelliteInfo.end())
{
@@ -393,16 +378,8 @@
// Entity Manager sources
RedfishAggregator::getInstance().getSatelliteConfigs(
[asyncResp, aggregationSourceId](
- const boost::system::error_code& ec,
const std::unordered_map<std::string, boost::urls::url>&
satelliteInfo) {
- // Something went wrong while querying dbus
- if (ec)
- {
- messages::internalError(asyncResp->res);
- return;
- }
-
// Check if it exists in Entity Manager sources
if (satelliteInfo.contains(aggregationSourceId))
{