diff options
author | Jason M. Bills <jason.m.bills@linux.intel.com> | 2021-06-24 02:18:49 +0300 |
---|---|---|
committer | Jason M. Bills <jason.m.bills@linux.intel.com> | 2021-06-24 03:07:59 +0300 |
commit | defdca82c107f46e980c84bffb1b2c1263522fa0 (patch) | |
tree | c31fba338a65c86741b16e061d66e0e060e3b768 /meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice | |
parent | 5565c9abcc817b88098b849b2de5c017a8fb559f (diff) | |
download | openbmc-defdca82c107f46e980c84bffb1b2c1263522fa0.tar.xz |
Update to internal 0.57
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice')
7 files changed, 267 insertions, 89 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch index b46d30149..bda893a81 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch @@ -1,7 +1,7 @@ -From ae55e89c14ea5abef0895409c956f5f4c38f330f Mon Sep 17 00:00:00 2001 +From 3d6c3b3e91c04ff8f10bff49bcf2a7d7206c53df Mon Sep 17 00:00:00 2001 From: Sunitha Harish <sunithaharish04@gmail.com> Date: Fri, 19 Feb 2021 13:38:31 +0530 -Subject: [PATCH 1/2] EventService : Fix retry handling for http-client +Subject: [PATCH] EventService : Fix retry handling for http-client When the event send/receive is failed, the bmcweb does not handle the failure to tear-down the complete connection and start a fresh @@ -23,17 +23,22 @@ Tested by: - Generate an event and see the same is received at the listener's console - Update the listner to change the keep-alive to true/false and observe the http-client connection states at bmcweb + - Changed listener client to return non success HTTP status code + and observed retry logic gets trigrred in http-client. + - Gave wrong fqdn and observed async resolve failure and retry logc. + - Stopped listener after connect and verified timeouts on http-client + side. Change-Id: Ibb45691f139916ba2954da37beda9d4f91c7cef3 Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com> --- - http/http_client.hpp | 289 ++++++++++-------- + http/http_client.hpp | 288 ++++++++++-------- .../include/event_service_manager.hpp | 2 +- - 2 files changed, 163 insertions(+), 128 deletions(-) + 2 files changed, 162 insertions(+), 128 deletions(-) diff --git a/http/http_client.hpp b/http/http_client.hpp -index 992ac2b..d116f6d 100644 +index 992ac2b..feabbba 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -34,22 +34,28 @@ namespace crow @@ -67,7 +72,7 @@ index 992ac2b..d116f6d 100644 }; class HttpClient : public std::enable_shared_from_this<HttpClient> -@@ -58,11 +64,14 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -58,11 +64,13 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> crow::async_resolve::Resolver resolver; boost::beast::tcp_stream conn; boost::asio::steady_timer timer; @@ -80,13 +85,12 @@ index 992ac2b..d116f6d 100644 + std::optional< + boost::beast::http::response_parser<boost::beast::http::string_body>> + parser; -+ boost::asio::ip::tcp::endpoint endpoint; + boost::circular_buffer_space_optimized<std::string> requestDataQueue{}; + std::vector<boost::asio::ip::tcp::endpoint> endPoints; ConnState state; std::string subId; std::string host; -@@ -76,12 +85,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -76,12 +84,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> void doResolve() { @@ -99,7 +103,7 @@ index 992ac2b..d116f6d 100644 BMCWEB_LOG_DEBUG << "Trying to resolve: " << host << ":" << port; auto respHandler = -@@ -89,78 +93,56 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -89,78 +92,56 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> const boost::beast::error_code ec, const std::vector<boost::asio::ip::tcp::endpoint>& endpointList) { @@ -191,7 +195,7 @@ index 992ac2b..d116f6d 100644 // Send the HTTP request to the remote host boost::beast::http::async_write( conn, req, -@@ -171,7 +153,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -171,7 +152,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> BMCWEB_LOG_ERROR << "sendMessage() failed: " << ec.message(); self->state = ConnState::sendFailed; @@ -200,7 +204,7 @@ index 992ac2b..d116f6d 100644 return; } BMCWEB_LOG_DEBUG << "sendMessage() bytes transferred: " -@@ -184,9 +166,18 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -184,9 +165,17 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> void recvMessage() { @@ -208,8 +212,7 @@ index 992ac2b..d116f6d 100644 + + parser.emplace(std::piecewise_construct, std::make_tuple()); + parser->body_limit(httpReadBodyLimit); -+ // Since these are all push style eventing, we are not -+ // bothered about response body parsing. ++ + // Check only for the response header + parser->skip(true); + @@ -220,7 +223,7 @@ index 992ac2b..d116f6d 100644 [self(shared_from_this())](const boost::beast::error_code& ec, const std::size_t& bytesTransferred) { if (ec) -@@ -194,30 +185,46 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -194,30 +183,47 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> BMCWEB_LOG_ERROR << "recvMessage() failed: " << ec.message(); self->state = ConnState::recvFailed; @@ -257,7 +260,8 @@ index 992ac2b..d116f6d 100644 + // enabled + self->state = ConnState::abortConnection; + } -+ // Transfer ownership of the response ++ ++ // Returns ownership of the parsed message + self->parser->release(); + + self->handleConnState(); @@ -275,7 +279,7 @@ index 992ac2b..d116f6d 100644 // not_connected happens sometimes so don't bother reporting it. if (ec && ec != boost::beast::errc::not_connected) { -@@ -225,112 +232,139 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -225,112 +231,139 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> return; } BMCWEB_LOG_DEBUG << "Connection closed gracefully"; @@ -369,7 +373,7 @@ index 992ac2b..d116f6d 100644 - retryCount = 0; - connStateCheck(); + runningTimer = true; - ++ + retryCount++; + + BMCWEB_LOG_DEBUG << "Attempt retry after " << retryIntervalSecs @@ -384,7 +388,7 @@ index 992ac2b..d116f6d 100644 + // sending the event as per the retry policy + } + self->runningTimer = false; -+ + + // Lets close connection and start from resolve. + self->doClose(); + }); @@ -469,7 +473,7 @@ index 992ac2b..d116f6d 100644 } } -@@ -339,37 +373,38 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -339,37 +372,38 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> const std::string& destIP, const std::string& destPort, const std::string& destUri) : conn(ioc), @@ -526,10 +530,10 @@ index 992ac2b..d116f6d 100644 void setRetryConfig(const uint32_t retryAttempts, diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index 148c703..bffa68f 100644 +index fa4e41a..c999121 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp -@@ -412,7 +412,7 @@ class Subscription +@@ -423,7 +423,7 @@ class Subscription reqHeaders.emplace_back(std::pair(key, val)); } } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch index b1f61c6fd..7cbb406a5 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch @@ -1,7 +1,7 @@ -From 579fda953ec991b4e7f9d7194b08f6aa103fa0ec Mon Sep 17 00:00:00 2001 +From 5f19e5c8ebc5cb0ce331e4ef841526995b6bdb2e Mon Sep 17 00:00:00 2001 From: AppaRao Puli <apparao.puli@linux.intel.com> Date: Mon, 22 Feb 2021 17:07:47 +0000 -Subject: [PATCH 2/2] EventService: https client support +Subject: [PATCH] EventService: https client support Add https client support for push style eventing. Using this BMC can push the event @@ -17,12 +17,12 @@ Tested: Change-Id: I44c3918b39baa2eb5fddda9d635f99aa280a422a Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com> --- - http/http_client.hpp | 255 ++++++++++++------ + http/http_client.hpp | 257 ++++++++++++------ .../include/event_service_manager.hpp | 2 +- - 2 files changed, 175 insertions(+), 82 deletions(-) + 2 files changed, 176 insertions(+), 83 deletions(-) diff --git a/http/http_client.hpp b/http/http_client.hpp -index d116f6d..cebc857 100644 +index feabbba..aaf1b2d 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -20,6 +20,7 @@ @@ -52,7 +52,7 @@ index d116f6d..cebc857 100644 boost::asio::steady_timer timer; boost::beast::flat_static_buffer<httpReadBodyLimit> buffer; boost::beast::http::request<boost::beast::http::string_body> req; -@@ -112,23 +117,52 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -111,23 +116,52 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> void doConnect() { state = ConnState::connectInProgress; @@ -113,7 +113,7 @@ index d116f6d..cebc857 100644 self->state = ConnState::connected; self->handleConnState(); }); -@@ -136,106 +170,159 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -135,106 +169,159 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> void sendMessage(const std::string& data) { @@ -207,15 +207,15 @@ index d116f6d..cebc857 100644 + // Abort the connection since server is not keep-alive enabled + self->state = ConnState::abortConnection; + } -+ // Transfer ownership of the response ++ ++ // Returns ownership of the parsed message + self->parser->release(); + + self->handleConnState(); + }; parser.emplace(std::piecewise_construct, std::make_tuple()); parser->body_limit(httpReadBodyLimit); - // Since these are all push style eventing, we are not - // bothered about response body parsing. + // Check only for the response header parser->skip(true); + conn.expires_after(std::chrono::seconds(30)); @@ -296,7 +296,8 @@ index d116f6d..cebc857 100644 + self->state = ConnState::closed; + self->handleConnState(); } -- // Transfer ownership of the response +- +- // Returns ownership of the parsed message - self->parser->release(); - - self->handleConnState(); @@ -344,7 +345,7 @@ index d116f6d..cebc857 100644 } } -@@ -302,6 +389,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -301,6 +388,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> { case ConnState::resolveInProgress: case ConnState::connectInProgress: @@ -352,7 +353,7 @@ index d116f6d..cebc857 100644 case ConnState::sendInProgress: case ConnState::recvInProgress: case ConnState::closeInProgress: -@@ -333,6 +421,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -332,6 +420,7 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> } case ConnState::resolveFailed: case ConnState::connectFailed: @@ -360,7 +361,7 @@ index d116f6d..cebc857 100644 case ConnState::sendFailed: case ConnState::recvFailed: case ConnState::retry: -@@ -371,7 +460,8 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -370,7 +459,8 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> public: explicit HttpClient(boost::asio::io_context& ioc, const std::string& id, const std::string& destIP, const std::string& destPort, @@ -370,7 +371,7 @@ index d116f6d..cebc857 100644 conn(ioc), timer(ioc), req(boost::beast::http::verb::post, destUri, 11), state(ConnState::initialized), subId(id), host(destIP), port(destPort), -@@ -384,8 +474,11 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> +@@ -383,8 +473,11 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> req.keep_alive(true); requestDataQueue.set_capacity(maxRequestQueueSize); @@ -384,10 +385,10 @@ index d116f6d..cebc857 100644 { if ((state == ConnState::suspended) || (state == ConnState::terminated)) diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index bffa68f..1e6f496 100644 +index c999121..267c857 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp -@@ -387,7 +387,7 @@ class Subscription +@@ -398,7 +398,7 @@ class Subscription { conn = std::make_shared<crow::HttpClient>( crow::connections::systemBus->get_io_context(), id, host, port, diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch index 0d31fbc72..cd59ed94d 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch @@ -1,7 +1,7 @@ -From e93a6a02b0fba3371144d474422fadacc3f25fde Mon Sep 17 00:00:00 2001 +From 0c531d959364192697290c1489d5f7b1bdd7a665 Mon Sep 17 00:00:00 2001 From: AppaRao Puli <apparao.puli@linux.intel.com> Date: Fri, 12 Mar 2021 18:53:25 +0000 -Subject: [PATCH 4/6] Add Server-Sent-Events support +Subject: [PATCH] Add Server-Sent-Events support Server-Sent Events is a standard describing how servers can initiate data transmission towards clients once an initial @@ -24,13 +24,13 @@ Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com> --- http/http_connection.hpp | 14 +- http/http_response.hpp | 7 +- - http/routing.hpp | 70 ++++++++++ + http/routing.hpp | 71 ++++++++++ http/server_sent_event.hpp | 279 +++++++++++++++++++++++++++++++++++++ - 4 files changed, 364 insertions(+), 6 deletions(-) + 4 files changed, 365 insertions(+), 6 deletions(-) create mode 100644 http/server_sent_event.hpp diff --git a/http/http_connection.hpp b/http/http_connection.hpp -index 4482f8d..2c8bf40 100644 +index 6172b3a..fc9fc60 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp @@ -326,7 +326,7 @@ class Connection : @@ -63,7 +63,7 @@ index 4482f8d..2c8bf40 100644 // delete lambda with self shared_ptr // to enable connection destruction diff --git a/http/http_response.hpp b/http/http_response.hpp -index cd00ec8..ffd6dda 100644 +index 7965704..29c56e1 100644 --- a/http/http_response.hpp +++ b/http/http_response.hpp @@ -13,10 +13,15 @@ namespace crow @@ -93,7 +93,7 @@ index cd00ec8..ffd6dda 100644 // In case of a JSON object, set the Content-Type header void jsonMode() diff --git a/http/routing.hpp b/http/routing.hpp -index 65c7b70..0824939 100644 +index dd07523..7ddc6b0 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -6,6 +6,7 @@ @@ -104,7 +104,7 @@ index 65c7b70..0824939 100644 #include "sessions.hpp" #include "utility.hpp" #include "websocket.hpp" -@@ -390,6 +391,67 @@ class WebSocketRule : public BaseRule +@@ -398,6 +399,68 @@ class WebSocketRule : public BaseRule std::function<void(crow::websocket::Connection&)> errorHandler; }; @@ -119,10 +119,11 @@ index 65c7b70..0824939 100644 + void validate() override + {} + -+ void handle(const Request&, Response& res, const RoutingParams&) override ++ void handle(const Request&, ++ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, ++ const RoutingParams&) override + { -+ res.result(boost::beast::http::status::not_found); -+ res.end(); ++ asyncResp->res.result(boost::beast::http::status::not_found); + } + + void handleUpgrade(const Request& req, Response&, @@ -172,7 +173,7 @@ index 65c7b70..0824939 100644 template <typename T> struct RuleParameterTraits { -@@ -402,6 +464,14 @@ struct RuleParameterTraits +@@ -410,6 +473,14 @@ struct RuleParameterTraits return *p; } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch index 02d28833f..37609c154 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch @@ -1,7 +1,7 @@ -From 698d2615c5bc30ab7f89f11ed5659df8bf248ea0 Mon Sep 17 00:00:00 2001 +From bcb80fc9a86555c74b56b5b37615601d3fbfae31 Mon Sep 17 00:00:00 2001 From: AppaRao Puli <apparao.puli@linux.intel.com> Date: Tue, 16 Mar 2021 15:37:24 +0000 -Subject: [PATCH 5/6] Add SSE style subscription support to eventservice +Subject: [PATCH] Add SSE style subscription support to eventservice This commit adds the SSE style eventservice subscription style event. Using this, end user can subscribe for @@ -23,16 +23,16 @@ Change-Id: I7f4b7a34974080739c4ba968ed570489af0474de --- http/http_connection.hpp | 2 +- include/eventservice_sse.hpp | 75 +++++ - .../include/event_service_manager.hpp | 77 ++++- + .../include/event_service_manager.hpp | 109 +++++-- redfish-core/include/server_sent_events.hpp | 291 ------------------ redfish-core/lib/event_service.hpp | 4 +- src/webserver_main.cpp | 2 + - 6 files changed, 149 insertions(+), 302 deletions(-) + 6 files changed, 163 insertions(+), 320 deletions(-) create mode 100644 include/eventservice_sse.hpp delete mode 100644 redfish-core/include/server_sent_events.hpp diff --git a/http/http_connection.hpp b/http/http_connection.hpp -index 2c8bf40..1ab776c 100644 +index fc9fc60..3afb4da 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp @@ -350,7 +350,7 @@ class Connection : @@ -126,7 +126,7 @@ index 0000000..6c98e6e +} // namespace eventservice_sse +} // namespace redfish diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index 5821e2e..f4d57c2 100644 +index fa4e41a..ac644c1 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -23,13 +23,15 @@ @@ -146,7 +146,7 @@ index 5821e2e..f4d57c2 100644 #include <cstdlib> #include <ctime> #include <fstream> -@@ -46,9 +48,13 @@ using EventServiceConfig = std::tuple<bool, uint32_t, uint32_t>; +@@ -46,9 +48,27 @@ using EventServiceConfig = std::tuple<bool, uint32_t, uint32_t>; static constexpr const char* eventFormatType = "Event"; static constexpr const char* metricReportFormatType = "MetricReport"; @@ -157,11 +157,50 @@ index 5821e2e..f4d57c2 100644 +static constexpr const uint8_t maxNoOfSubscriptions = 20; +static constexpr const uint8_t maxNoOfSSESubscriptions = 10; + - #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES - static std::optional<boost::asio::posix::stream_descriptor> inotifyConn; - static constexpr const char* redfishEventLogDir = "/var/log"; -@@ -391,11 +397,9 @@ class Subscription - path, uriProto); ++#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES ++static std::optional<boost::asio::posix::stream_descriptor> inotifyConn; ++static constexpr const char* redfishEventLogDir = "/var/log"; ++static constexpr const char* redfishEventLogFile = "/var/log/redfish"; ++static constexpr const size_t iEventSize = sizeof(inotify_event); ++static int inotifyFd = -1; ++static int dirWatchDesc = -1; ++static int fileWatchDesc = -1; ++ ++// <ID, timestamp, RedfishLogId, registryPrefix, MessageId, MessageArgs> ++using EventLogObjectsType = ++ std::tuple<std::string, std::string, std::string, std::string, std::string, ++ std::vector<std::string>>; ++ + namespace message_registries + { + inline boost::beast::span<const MessageEntry> +@@ -68,24 +88,6 @@ inline boost::beast::span<const MessageEntry> + } + return boost::beast::span<const MessageEntry>(openbmc::registry); + } +-} // namespace message_registries +- +-#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES +-static std::optional<boost::asio::posix::stream_descriptor> inotifyConn; +-static constexpr const char* redfishEventLogDir = "/var/log"; +-static constexpr const char* redfishEventLogFile = "/var/log/redfish"; +-static constexpr const size_t iEventSize = sizeof(inotify_event); +-static int inotifyFd = -1; +-static int dirWatchDesc = -1; +-static int fileWatchDesc = -1; +- +-// <ID, timestamp, RedfishLogId, registryPrefix, MessageId, MessageArgs> +-using EventLogObjectsType = +- std::tuple<std::string, std::string, std::string, std::string, std::string, +- std::vector<std::string>>; +- +-namespace message_registries +-{ + static const Message* + getMsgFromRegistry(const std::string& messageKey, + const boost::beast::span<const MessageEntry>& registry) +@@ -401,11 +403,9 @@ class Subscription + path); } - Subscription(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) : @@ -175,7 +214,7 @@ index 5821e2e..f4d57c2 100644 ~Subscription() = default; -@@ -420,7 +424,7 @@ class Subscription +@@ -430,7 +430,7 @@ class Subscription if (sseConn != nullptr) { @@ -184,7 +223,7 @@ index 5821e2e..f4d57c2 100644 } } -@@ -510,6 +514,7 @@ class Subscription +@@ -520,6 +520,7 @@ class Subscription this->sendEvent( msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace)); @@ -192,7 +231,7 @@ index 5821e2e..f4d57c2 100644 } #endif -@@ -565,14 +570,39 @@ class Subscription +@@ -590,14 +591,39 @@ class Subscription return eventSeqNum; } @@ -233,7 +272,7 @@ index 5821e2e..f4d57c2 100644 }; static constexpr const bool defaultEnabledState = true; -@@ -963,6 +993,8 @@ class EventServiceManager +@@ -988,6 +1014,8 @@ class EventServiceManager subValue->updateRetryConfig(retryAttempts, retryTimeoutInterval); subValue->updateRetryPolicy(); @@ -242,7 +281,7 @@ index 5821e2e..f4d57c2 100644 return id; } -@@ -987,11 +1019,40 @@ class EventServiceManager +@@ -1012,11 +1040,40 @@ class EventServiceManager } } @@ -581,7 +620,7 @@ index 578fa19..0000000 - -} // namespace crow diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp -index be6f04d..1875ec9 100644 +index 64a2009..7c9bb7a 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -34,8 +34,6 @@ static constexpr const std::array<const char*, 1> supportedResourceTypes = { @@ -603,7 +642,7 @@ index be6f04d..1875ec9 100644 {{"@odata.id", "/redfish/v1/EventService/Subscriptions"}}}, {"Actions", diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp -index 902c32b..c871faa 100644 +index 902c32b..d4bd48c 100644 --- a/src/webserver_main.cpp +++ b/src/webserver_main.cpp @@ -5,6 +5,7 @@ @@ -614,14 +653,14 @@ index 902c32b..c871faa 100644 #include <hostname_monitor.hpp> #include <ibm/management_console_rest.hpp> #include <image_upload.hpp> -@@ -83,6 +84,7 @@ int main(int /*argc*/, char** /*argv*/) +@@ -81,6 +82,7 @@ int main(int /*argc*/, char** /*argv*/) + #endif + #ifdef BMCWEB_ENABLE_REDFISH ++ redfish::eventservice_sse::requestRoutes(app); redfish::requestRoutes(app); redfish::RedfishService redfish(app); -+ redfish::eventservice_sse::requestRoutes(app); - // Create EventServiceManager instance and initialize Config - redfish::EventServiceManager::getInstance(); -- 2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch index 4d99b2754..16e8affa5 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch @@ -1,7 +1,7 @@ -From 82185c52ae6e27cc1e086654a3b7d10e63ecc783 Mon Sep 17 00:00:00 2001 +From dda3c7a46391ef88e7c6a6f61fba7fe9133336bf Mon Sep 17 00:00:00 2001 From: AppaRao Puli <apparao.puli@linux.intel.com> Date: Wed, 17 Mar 2021 01:16:50 +0000 -Subject: [PATCH 6/6] Add EventService SSE filter support +Subject: [PATCH] Add EventService SSE filter support This commit implements the Event Service SSE stream filters support. As per redfish specification: @@ -35,9 +35,9 @@ Change-Id: I55c6f53bb5e57aa1f2d1601f1a16525a33b13bd2 include/eventservice_sse.hpp | 94 ++++++++++++++++++- redfish-core/include/error_messages.hpp | 9 ++ .../include/event_service_manager.hpp | 5 + - redfish-core/lib/event_service.hpp | 4 - + redfish-core/lib/event_service.hpp | 5 - redfish-core/src/error_messages.cpp | 26 +++++ - 5 files changed, 130 insertions(+), 8 deletions(-) + 5 files changed, 130 insertions(+), 9 deletions(-) diff --git a/include/eventservice_sse.hpp b/include/eventservice_sse.hpp index 6c98e6e..ff72c4d 100644 @@ -171,7 +171,7 @@ index 7dfdc80..922dae9 100644 } // namespace redfish diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index f4d57c2..567fb9c 100644 +index ac644c1..3661fed 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -55,6 +55,11 @@ static constexpr const char* eventServiceFile = @@ -180,24 +180,25 @@ index f4d57c2..567fb9c 100644 +static constexpr const std::array<const char*, 2> supportedEvtFormatTypes = { + eventFormatType, metricReportFormatType}; -+static constexpr const std::array<const char*, 3> supportedRegPrefixes = { -+ "Base", "OpenBMC", "Task"}; ++static constexpr const std::array<const char*, 2> supportedRegPrefixes = { ++ "OpenBMC", "TaskEvent"}; + #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES static std::optional<boost::asio::posix::stream_descriptor> inotifyConn; static constexpr const char* redfishEventLogDir = "/var/log"; diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp -index 1875ec9..4d1ac9f 100644 +index 7c9bb7a..297a4ea 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp -@@ -19,10 +19,6 @@ +@@ -18,11 +18,6 @@ + namespace redfish { - +- -static constexpr const std::array<const char*, 2> supportedEvtFormatTypes = { - eventFormatType, metricReportFormatType}; -static constexpr const std::array<const char*, 3> supportedRegPrefixes = { -- "Base", "OpenBMC", "Task"}; +- "Base", "OpenBMC", "TaskEvent"}; static constexpr const std::array<const char*, 3> supportedRetryPolicies = { "TerminateAfterRetries", "SuspendRetries", "RetryForever"}; diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0007-EventService-Log-events-for-subscription-actions.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0007-EventService-Log-events-for-subscription-actions.patch new file mode 100644 index 000000000..0b12671e5 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0007-EventService-Log-events-for-subscription-actions.patch @@ -0,0 +1,132 @@ +From 0a1390428fd6f5651669f4306f6105d33a24453c Mon Sep 17 00:00:00 2001 +From: Ayushi Smriti <smriti.ayushi@intel.com> +Date: Mon, 10 May 2021 13:03:37 +0530 +Subject: [PATCH] EventService: Log events for subscription actions + +Log redfish event for below 3 actions + - Add new subscription + - Update existing subscription properties + - Delete existing subscription +in order to notify the subscribed clients on the subscription related +information. + +Modified method name accordingly to indicate the clear purpose and +added updateSubscription method with subscription id param +to log event for subscription update. + +Tested: + - Performed all the above actions and verified the redfish event + messages are logged. + +Change-Id: I528293e55b1f3401bc2bb09c11c63ae985fbfedb +Signed-off-by: AppaRao Puli <apparao.puli@intel.com> +Signed-off-by: Ayushi Smriti <smriti.ayushi@intel.com> +--- + .../include/event_service_manager.hpp | 35 ++++++++++++++++--- + redfish-core/lib/event_service.hpp | 2 +- + 2 files changed, 32 insertions(+), 5 deletions(-) + +diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp +index 9952ef1..2b957ea 100644 +--- a/redfish-core/include/event_service_manager.hpp ++++ b/redfish-core/include/event_service_manager.hpp +@@ -22,6 +22,7 @@ + #include "registries/task_event_message_registry.hpp" + + #include <sys/inotify.h> ++#include <systemd/sd-journal.h> + + #include <boost/asio/io_context.hpp> + #include <boost/beast/core/span.hpp> +@@ -800,7 +801,7 @@ class EventServiceManager + return; + } + +- void updateSubscriptionData() ++ void persistSubscriptionData() + { + // Persist the config and subscription data. + nlohmann::json jsonData; +@@ -897,7 +898,7 @@ class EventServiceManager + + if (updateConfig) + { +- updateSubscriptionData(); ++ persistSubscriptionData(); + } + + if (updateRetryCfg) +@@ -992,7 +993,7 @@ class EventServiceManager + + if (updateFile) + { +- updateSubscriptionData(); ++ persistSubscriptionData(); + } + + #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES +@@ -1007,6 +1008,13 @@ class EventServiceManager + + // Set Subscription ID for back trace + subValue->setSubscriptionId(id); ++ ++ /* Log event for subscription addition */ ++ sd_journal_send("MESSAGE=Event subscription added(Id: %s)", id.c_str(), ++ "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s", ++ "OpenBMC.0.1.EventSubscriptionAdded", ++ "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); ++ + return id; + } + +@@ -1027,7 +1035,14 @@ class EventServiceManager + { + subscriptionsMap.erase(obj); + updateNoOfSubscribersCount(); +- updateSubscriptionData(); ++ ++ persistSubscriptionData(); ++ /* Log event for subscription delete. */ ++ sd_journal_send("MESSAGE=Event subscription removed.(Id = %s)", ++ id.c_str(), "PRIORITY=%i", LOG_INFO, ++ "REDFISH_MESSAGE_ID=%s", ++ "OpenBMC.0.1.EventSubscriptionRemoved", ++ "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); + } + } + +@@ -1049,6 +1064,18 @@ class EventServiceManager + } + } + ++ void updateSubscription(const std::string& id) ++ { ++ persistSubscriptionData(); ++ ++ /* Log event for subscription update. */ ++ sd_journal_send("MESSAGE=Event subscription updated.(Id = %s)", ++ id.c_str(), "PRIORITY=%i", LOG_INFO, ++ "REDFISH_MESSAGE_ID=%s", ++ "OpenBMC.0.1.EventSubscriptionUpdated", ++ "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); ++ } ++ + size_t getNumberOfSubscriptions() + { + return subscriptionsMap.size(); +diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp +index 297a4ea..ed4955e 100644 +--- a/redfish-core/lib/event_service.hpp ++++ b/redfish-core/lib/event_service.hpp +@@ -616,7 +616,7 @@ class EventDestination : public Node + subValue->updateRetryPolicy(); + } + +- EventServiceManager::getInstance().updateSubscriptionData(); ++ EventServiceManager::getInstance().updateSubscription(params[0]); + } + + void doDelete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README index 3954e89c1..ae010dafb 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README @@ -4,16 +4,16 @@ thee gets merged upstream. Upstream revision information: - EventService : Fix retry handling for http-client - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/40731/18 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/40731/20 - EventService: https client support - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/31735/38 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/31735/39 - Add Server-Sent-Events support - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41258/5 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41258/6 - Add SSE style subscription support to eventservice - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41319/5 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41319/6 - Add EventService SSE filter support - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41349/2 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41349/3 |