summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorJason M. Bills <jason.m.bills@linux.intel.com>2019-10-29 22:46:33 +0300
committerJason Bills <jason.m.bills@linux.intel.com>2019-12-02 19:53:55 +0300
commit3e0414fd3f3b8b08ef3960f66fa056d8376e3544 (patch)
treedc08b0f784baa1dab2ec75dbfb7e41b34d20b2eb /redfish-core
parent4363d3b256d469c5c133e5714f3e3be2f29b5e65 (diff)
downloadbmcweb-3e0414fd3f3b8b08ef3960f66fa056d8376e3544.tar.xz
Return no-content instead of waiting for OnDemand
Since an OnDemand crashdump could take some time it may cause the request to time out before the response can be sent. The correct fix for this is to implement the Redfish Task Monitor service to handle all asynchronous tasks. Until then, this change will return 204 (no content) and add the OnDemand log to the Entries list. When Task Monitor is implemented it can return 202 (accepted) with the location of the Task to poll. Tested: Used Postman to trigger the OnDemand action and immediately got a 204 response. Polled the Entries list and saw the OnDemand entry after it was ready. Change-Id: I3e2692ec5d377823072e0d610fa3ca17a9259a37 Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/log_services.hpp90
1 files changed, 1 insertions, 89 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 1447f21549..149b9f6889 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1723,12 +1723,6 @@ class CrashdumpEntryCollection : public Node
// enough to hold them
for (const std::string &objpath : resp)
{
- // Ignore the on-demand log
- if (objpath.compare(crashdumpOnDemandPath) == 0)
- {
- continue;
- }
-
// Get the log ID
std::size_t lastPos = objpath.rfind("/");
if (lastPos == std::string::npos)
@@ -1879,86 +1873,6 @@ class OnDemandCrashdump : public Node
const std::vector<std::string> &params) override
{
std::shared_ptr<AsyncResp> asyncResp = std::make_shared<AsyncResp>(res);
- static std::unique_ptr<sdbusplus::bus::match::match> onDemandLogMatcher;
-
- // Only allow one OnDemand Log request at a time
- if (onDemandLogMatcher != nullptr)
- {
- messages::serviceTemporarilyUnavailable(asyncResp->res, "30");
- return;
- }
- // Make this static so it survives outside this method
- static boost::asio::steady_timer timeout(*req.ioService);
-
- timeout.expires_after(std::chrono::seconds(30));
- timeout.async_wait([asyncResp](const boost::system::error_code &ec) {
- onDemandLogMatcher = nullptr;
- if (ec)
- {
- // operation_aborted is expected if timer is canceled before
- // completion.
- if (ec != boost::asio::error::operation_aborted)
- {
- BMCWEB_LOG_ERROR << "Async_wait failed " << ec;
- }
- return;
- }
- BMCWEB_LOG_ERROR << "Timed out waiting for on-demand log";
-
- messages::internalError(asyncResp->res);
- });
-
- auto onDemandLogMatcherCallback =
- [asyncResp](sdbusplus::message::message &m) {
- BMCWEB_LOG_DEBUG << "OnDemand log available match fired";
- timeout.cancel();
-
- sdbusplus::message::object_path objPath;
- boost::container::flat_map<
- std::string, boost::container::flat_map<
- std::string, std::variant<std::string>>>
- interfacesAdded;
- m.read(objPath, interfacesAdded);
- const std::string *log = std::get_if<std::string>(
- &interfacesAdded[crashdumpInterface]["Log"]);
- if (log == nullptr)
- {
- messages::internalError(asyncResp->res);
- // Careful with onDemandLogMatcher. It is a unique_ptr to
- // the match object inside which this lambda is executing.
- // Once it is set to nullptr, the match object will be
- // destroyed and the lambda will lose its context, including
- // res, so it needs to be the last thing done.
- onDemandLogMatcher = nullptr;
- return;
- }
- nlohmann::json crashdumpJson =
- nlohmann::json::parse(*log, nullptr, false);
- if (crashdumpJson.is_discarded())
- {
- messages::internalError(asyncResp->res);
- // Careful with onDemandLogMatcher. It is a unique_ptr to
- // the match object inside which this lambda is executing.
- // Once it is set to nullptr, the match object will be
- // destroyed and the lambda will lose its context, including
- // res, so it needs to be the last thing done.
- onDemandLogMatcher = nullptr;
- return;
- }
- asyncResp->res.jsonValue = crashdumpJson;
- // Careful with onDemandLogMatcher. It is a unique_ptr to the
- // match object inside which this lambda is executing. Once it
- // is set to nullptr, the match object will be destroyed and the
- // lambda will lose its context, including res, so it needs to
- // be the last thing done.
- onDemandLogMatcher = nullptr;
- };
- onDemandLogMatcher = std::make_unique<sdbusplus::bus::match::match>(
- *crow::connections::systemBus,
- sdbusplus::bus::match::rules::interfacesAdded() +
- sdbusplus::bus::match::rules::argNpath(0,
- crashdumpOnDemandPath),
- std::move(onDemandLogMatcherCallback));
auto generateonDemandLogCallback =
[asyncResp](const boost::system::error_code ec,
@@ -1980,11 +1894,9 @@ class OnDemandCrashdump : public Node
{
messages::internalError(asyncResp->res);
}
-
- timeout.cancel();
- onDemandLogMatcher = nullptr;
return;
}
+ asyncResp->res.result(boost::beast::http::status::no_content);
};
crow::connections::systemBus->async_method_call(
std::move(generateonDemandLogCallback), crashdumpObject,