common: activation progress not taking effect
'class Device' has member function
```
bool setUpdateProgress(uint8_t progress) const;
```
to update the activation status, which set the activation status for
device->softwarePending.
'softwarePending' however was only set on the class after the update to
the device already succeeded. So 'Device::updateDevice' could not
update the activation progress via 'Device::setUpdateProgress'
Fix this bug by setting 'softwarePending' before 'updateDevice' is
called.
Tested: With SPI Device Code Updater.
The activation progress is now set as expected.
```
curl --silent --insecure --user root:root https://${bmc}/redfish/v1/TaskService/Tasks/0
```
Output:
```
{
"@odata.id": "/redfish/v1/TaskService/Tasks/0",
"@odata.type": "#Task.v1_4_3.Task",
"EndTime": "2025-02-18T14:05:46+00:00",
"HidePayload": false,
"Id": "0",
"Messages": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has started.",
"MessageArgs": [
"0"
],
"MessageId": "TaskEvent.1.0.TaskStarted",
"MessageSeverity": "OK",
"Resolution": "None."
},
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has changed to progress 10 percent complete.",
"MessageArgs": [
"0",
"10"
],
"MessageId": "TaskEvent.1.0.TaskProgressChanged",
"MessageSeverity": "OK",
"Resolution": "None."
},
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has changed to progress 20 percent complete.",
"MessageArgs": [
"0",
"20"
],
"MessageId": "TaskEvent.1.0.TaskProgressChanged",
"MessageSeverity": "OK",
"Resolution": "None."
},
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has changed to progress 70 percent complete.",
"MessageArgs": [
"0",
"70"
],
"MessageId": "TaskEvent.1.0.TaskProgressChanged",
"MessageSeverity": "OK",
"Resolution": "None."
},
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has changed to progress 100 percent complete.",
"MessageArgs": [
"0",
"100"
],
"MessageId": "TaskEvent.1.0.TaskProgressChanged",
"MessageSeverity": "OK",
"Resolution": "None."
},
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The task with Id '0' has completed.",
"MessageArgs": [
"0"
],
"MessageId": "TaskEvent.1.0.TaskCompletedOK",
"MessageSeverity": "OK",
"Resolution": "None."
}
],
"Name": "Task 0",
"Payload": {
"HttpHeaders": [],
"HttpOperation": "POST",
"JsonBody": "null",
"TargetUri": "/redfish/v1/UpdateService/update"
},
"PercentComplete": 90,
"StartTime": "2025-02-18T14:04:47+00:00",
"TaskMonitor": "/redfish/v1/TaskService/TaskMonitors/0",
"TaskState": "Completed",
"TaskStatus": "OK"
}
```
Change-Id: I4b22a37215357b83300f8368f75d3c025cd5d06b
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/common/include/device.hpp b/common/include/device.hpp
index 56fc920..2a52276 100644
--- a/common/include/device.hpp
+++ b/common/include/device.hpp
@@ -106,8 +106,7 @@
// update function
sdbusplus::async::task<bool> continueUpdateWithMappedPackage(
const uint8_t* componentImage, size_t componentImageSize,
- const std::string& componentVersion, RequestedApplyTimes applyTime,
- const std::unique_ptr<Software>& softwarePendingIn);
+ const std::string& componentVersion, RequestedApplyTimes applyTime);
// @brief extracts the information we need from the pldm package
// @returns true on success
diff --git a/common/src/device.cpp b/common/src/device.cpp
index 471697c..2367213 100644
--- a/common/src/device.cpp
+++ b/common/src/device.cpp
@@ -96,36 +96,38 @@
co_return false;
}
+ std::unique_ptr<Software> softwarePendingOld = std::move(softwarePending);
+
+ softwarePending = std::move(softwarePendingIn);
+ softwarePendingIn = nullptr;
+
const bool success = co_await continueUpdateWithMappedPackage(
- componentImage, componentImageSize, componentVersion, applyTime,
- softwarePendingIn);
+ componentImage, componentImageSize, componentVersion, applyTime);
- if (success)
+ if (!success)
{
- if (applyTime == RequestedApplyTimes::Immediate)
- {
- softwareCurrent = std::move(softwarePendingIn);
-
- // In case an immediate update is triggered after an update for
- // onReset.
- softwarePending = nullptr;
-
- debug("Successfully updated to software version {SWID}", "SWID",
- softwareCurrent->swid);
- }
- else if (applyTime == RequestedApplyTimes::OnReset)
- {
- softwarePending = std::move(softwarePendingIn);
- }
- }
- else
- {
- softwarePendingIn->setActivation(ActivationFailed);
+ softwarePending->setActivation(ActivationFailed);
error("Failed to update the software for {SWID}", "SWID",
softwareCurrent->swid);
+
+ softwarePending = std::move(softwarePendingOld);
+
+ co_return false;
+ }
+
+ if (applyTime == RequestedApplyTimes::Immediate)
+ {
+ softwareCurrent = std::move(softwarePending);
+
+ // In case an immediate update is triggered after an update for
+ // onReset.
+ softwarePending = nullptr;
+
+ debug("Successfully updated to software version {SWID}", "SWID",
+ softwareCurrent->swid);
}
- co_return success;
+ co_return true;
}
std::string Device::getEMConfigType() const
@@ -157,22 +159,21 @@
// NOLINTBEGIN(readability-static-accessed-through-instance)
sdbusplus::async::task<bool> Device::continueUpdateWithMappedPackage(
const uint8_t* matchingComponentImage, size_t componentImageSize,
- const std::string& componentVersion, RequestedApplyTimes applyTime,
- const std::unique_ptr<Software>& softwarePendingIn)
+ const std::string& componentVersion, RequestedApplyTimes applyTime)
// NOLINTEND(readability-static-accessed-through-instance)
{
- softwarePendingIn->setActivation(ActivationInterface::Activations::Ready);
+ softwarePending->setActivation(ActivationInterface::Activations::Ready);
- softwarePendingIn->setVersion(componentVersion);
+ softwarePending->setVersion(componentVersion);
- std::string objPath = softwarePendingIn->objectPath;
+ std::string objPath = softwarePending->objectPath;
- softwarePendingIn->softwareActivationProgress =
+ softwarePending->softwareActivationProgress =
std::make_unique<SoftwareActivationProgress>(ctx, objPath.c_str());
- softwarePendingIn->setActivationBlocksTransition(true);
+ softwarePending->setActivationBlocksTransition(true);
- softwarePendingIn->setActivation(
+ softwarePending->setActivation(
ActivationInterface::Activations::Activating);
bool success =
@@ -180,13 +181,13 @@
if (success)
{
- softwarePendingIn->setActivation(
+ softwarePending->setActivation(
ActivationInterface::Activations::Active);
}
- softwarePendingIn->setActivationBlocksTransition(false);
+ softwarePending->setActivationBlocksTransition(false);
- softwarePendingIn->softwareActivationProgress = nullptr;
+ softwarePending->softwareActivationProgress = nullptr;
if (!success)
{
@@ -200,13 +201,13 @@
{
co_await resetDevice();
- co_await softwarePendingIn->createInventoryAssociations(true);
+ co_await softwarePending->createInventoryAssociations(true);
- softwarePendingIn->enableUpdate(allowedApplyTimes);
+ softwarePending->enableUpdate(allowedApplyTimes);
}
else
{
- co_await softwarePendingIn->createInventoryAssociations(false);
+ co_await softwarePending->createInventoryAssociations(false);
}
co_return true;