diff options
author | Carson Labrado <clabrado@google.com> | 2022-06-01 19:01:52 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-06-15 03:22:52 +0300 |
commit | a7a80296f731ef1069d3ecfbd3069668fb71cd68 (patch) | |
tree | d2d7ec05983bdeb6e37daea2c10b0fe6a284d9b5 /redfish-core | |
parent | cec58fe39551f162a9aec9ebbb359876f8f2e762 (diff) | |
download | bmcweb-a7a80296f731ef1069d3ecfbd3069668fb71cd68.tar.xz |
bmcweb: Set Retry Policy Valid Response Codes
Allows individual retry policies to specify what HTTP response codes
are considered valid. Sets functions for the EventService and
Redfish Aggregation retry policies. Those functions expect a
response code and return an error code based on what the response
code is.
This change is needed because EventService only considers 2XX codes
to be valid. Any code outside of that range would trigger a retry
attempt. Redfish Aggregation by design will need to return
errors outside of that range such as 404. It should not retry to
send a message when it receives a 404 from a satellite BMC.
Right now 404 is the only error code that is handled differently
between the services. Going forward, Redfish Aggregation will
likely want to allow other error codes as its functionality is
expanded.
Tested:
Used Redfish-Event-Listener with ssh port forwarding to create 3
subscriptions. I then closed the ssh connection and sent a test
event. Bmcweb made 3 retry attempts for each subscription. At
that point the max retry amount (as defined by EventService) was
reached and bmcweb stop attempting to resend the messages.
There were no errors when the Redfish-Event-Listener was correctly
connected. Test events resulted in messages being sent for each
subscription.
Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: Ifdfaf638d28982ed18998f3ca05280a288e0020a
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 20 | ||||
-rw-r--r-- | redfish-core/include/redfish_aggregator.hpp | 25 |
2 files changed, 44 insertions, 1 deletions
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index 6747575c33..8c21fac5ab 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -537,7 +537,8 @@ class Subscription : public persistent_data::UserSubscription const uint32_t retryTimeoutInterval) { crow::HttpClient::getInstance().setRetryConfig( - retryAttempts, retryTimeoutInterval, retryPolicyName); + retryAttempts, retryTimeoutInterval, retryRespHandler, + retryPolicyName); } void updateRetryPolicy() @@ -559,6 +560,23 @@ class Subscription : public persistent_data::UserSubscription std::string uriProto; std::shared_ptr<crow::ServerSentEvents> sseConn = nullptr; std::string retryPolicyName = "SubscriptionEvent"; + + // Check used to indicate what response codes are valid as part of our retry + // policy. 2XX is considered acceptable + static boost::system::error_code retryRespHandler(unsigned int respCode) + { + BMCWEB_LOG_DEBUG + << "Checking response code validity for SubscriptionEvent"; + if ((respCode < 200) || (respCode >= 300)) + { + return boost::system::errc::make_error_code( + boost::system::errc::result_out_of_range); + } + + // Return 0 if the response code is valid + return boost::system::errc::make_error_code( + boost::system::errc::success); + }; }; class EventServiceManager diff --git a/redfish-core/include/redfish_aggregator.hpp b/redfish-core/include/redfish_aggregator.hpp index 67ed929cb5..01e5aba45e 100644 --- a/redfish-core/include/redfish_aggregator.hpp +++ b/redfish-core/include/redfish_aggregator.hpp @@ -8,11 +8,36 @@ namespace redfish class RedfishAggregator { private: + const std::string retryPolicyName = "RedfishAggregation"; + const uint32_t retryAttempts = 5; + const uint32_t retryTimeoutInterval = 0; + RedfishAggregator() { getSatelliteConfigs(constructorCallback); + + // Setup the retry policy to be used by Redfish Aggregation + crow::HttpClient::getInstance().setRetryConfig( + retryAttempts, retryTimeoutInterval, aggregationRetryHandler, + retryPolicyName); } + static inline boost::system::error_code + aggregationRetryHandler(unsigned int respCode) + { + // As a default, assume 200X is alright. + // We don't need to retry on a 404 + if ((respCode < 200) || ((respCode >= 300) && (respCode != 404))) + { + return boost::system::errc::make_error_code( + boost::system::errc::result_out_of_range); + } + + // Return 0 if the response code is valid + return boost::system::errc::make_error_code( + boost::system::errc::success); + }; + // 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( |