summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-10 18:58:48 +0300
committerEd Tanous <ed@tanous.net>2024-04-24 21:52:58 +0300
commit6b54e4e08678c0e32ed02adc87237f6ffa936691 (patch)
treec94d20795381c578232495ce7979af71039d07a2
parent1d1d7784f7858880f4dd732fd287517daf1e1785 (diff)
downloadbmcweb-6b54e4e08678c0e32ed02adc87237f6ffa936691.tar.xz
Handle error code properly
As part of the previous patch tests, UpdateService shows this bug, where on a multipart parser failure, the dbus match object gets instantiated, and eventually fails. This leads to mediocre logging, and possibly could leave update service in an undesirable state. Fix the error by moving the conditional up. Tested: Filling a 16MB file with all zeros and sending it now no longer logs that a monitor has been set up, and returns immediately instead of waiting for timeout. ``` dd if=/dev/zero of=zeros-file bs=1048576 count=16 of=16mb.txt curl -k --location POST https://192.168.7.2/redfish/v1/UpdateService/update -F 'UpdateParameters={"Targets":[]} ;type=application/json' -H "Expect:" --user "root:0penBmc" -F UpdateFile=@16mb.txt -v ``` Change-Id: I0962d15c624936b4fa199a675123702003dd697b Signed-off-by: Ed Tanous <ed@tanous.net>
-rw-r--r--redfish-core/lib/update_service.hpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 14f8ecfd61..0418d269b9 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -668,6 +668,7 @@ inline void setApplyTime(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
inline void
updateMultipartContext(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const crow::Request& req,
const MultipartParser& parser)
{
const std::string* uploadData = nullptr;
@@ -754,6 +755,9 @@ inline void
setApplyTime(asyncResp, *applyTime);
+ // Setup callback for when new software detected
+ monitorForSoftwareAvailable(asyncResp, req, "/redfish/v1/UpdateService");
+
uploadImageFile(asyncResp->res, *uploadData);
}
@@ -783,10 +787,6 @@ inline void
{
MultipartParser parser;
- // Setup callback for when new software detected
- monitorForSoftwareAvailable(asyncResp, req,
- "/redfish/v1/UpdateService");
-
ParserError ec = parser.parse(req);
if (ec != ParserError::PARSER_SUCCESS)
{
@@ -796,7 +796,8 @@ inline void
messages::internalError(asyncResp->res);
return;
}
- updateMultipartContext(asyncResp, parser);
+
+ updateMultipartContext(asyncResp, req, parser);
}
else
{