OpenPOWER: Return Unavailable Instead of NotAllowed for Delete
This commit changes the exception thrown from 'NotAllowed'
to 'Unavailable' when attempting to delete a system dump
that is currently being offloaded. This modification aligns
with the objective to return an HTTP 'Unavailable' status
via Redfish interface in this scenario.
The 'Unavailable' response more accurately reflects the
system state, as the dump is not disallowed from deletion
under normal circumstances, but temporarily unavailable
due to the ongoing offload process.
Tests:
- Attempt to delete resource dump while offloading it
- Attempt to delete system dump while offloading it
Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: I6c5d9aba16380d86e68c06537417ad9d725826e5
diff --git a/dump-extensions/openpower-dumps/resource_dump_entry.cpp b/dump-extensions/openpower-dumps/resource_dump_entry.cpp
index 17125fe..ee06fa9 100644
--- a/dump-extensions/openpower-dumps/resource_dump_entry.cpp
+++ b/dump-extensions/openpower-dumps/resource_dump_entry.cpp
@@ -49,9 +49,7 @@
lg2::error("Dump offload is in progress, cannot delete dump, "
"id: {DUMP_ID} srcdumpid: {SRC_DUMP_ID}",
"DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID);
- elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>(
- xyz::openbmc_project::Common::NotAllowed::REASON(
- "Dump offload is in progress"));
+ elog<sdbusplus::xyz::openbmc_project::Common::Error::Unavailable>();
}
lg2::info("Resource dump delete id: {DUMP_ID} srcdumpid: {SRC_DUMP_ID}",
diff --git a/dump-extensions/openpower-dumps/system_dump_entry.cpp b/dump-extensions/openpower-dumps/system_dump_entry.cpp
index 3d0fb51..5697e90 100644
--- a/dump-extensions/openpower-dumps/system_dump_entry.cpp
+++ b/dump-extensions/openpower-dumps/system_dump_entry.cpp
@@ -34,14 +34,14 @@
auto srcDumpID = sourceDumpId();
auto dumpId = id;
+ // Offload URI will be set during dump offload
+ // Prevent delete when offload is in progress
if ((!offloadUri().empty()) && (phosphor::dump::isHostRunning()))
{
lg2::error("Dump offload is in progress id: {DUMP_ID} "
"srcdumpid: {SRC_DUMP_ID}",
"DUMP_ID", dumpId, "SRC_DUMP_ID", srcDumpID);
- elog<sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed>(
- xyz::openbmc_project::Common::NotAllowed::REASON(
- "Dump offload is in progress"));
+ elog<sdbusplus::xyz::openbmc_project::Common::Error::Unavailable>();
}
lg2::info("System dump delete id: {DUMP_ID} srcdumpid: {SRC_DUMP_ID}",