summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2018-09-07 14:13:29 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2018-09-19 11:34:29 -0500
commita6963590773d4dea762571695e7c47d830aba5d7 (patch)
tree1cbd720fe1c248a8e38ef3ff2938ef4f21906d3e
parent1e648729a516d298a3eb1b9b0e88513cee48c7d8 (diff)
downloadphosphor-bmc-code-mgmt-a6963590773d4dea762571695e7c47d830aba5d7.zip
phosphor-bmc-code-mgmt-a6963590773d4dea762571695e7c47d830aba5d7.tar.gz
Fix being able to activate a Failed version
When an activation fails, the version is marked as Failed. On a subsequent activation, the bmc updater core dumps due to 2 issues during the freeSpace call: 1. The Failed activation doesn't have a Priority object, so default its priority to a large value. 2. If the subsequent activation is to the same version id, then freeSpace should not do an erase on it, because that removes the activations object that it's trying to activate. Tested: Verified that doing an activation after a version was marked as Failed did not core dump the updater anymore. Change-Id: Iba36497b53738e00283cfec55e8c666f943cd5d5 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rw-r--r--activation.cpp4
-rw-r--r--item_updater.cpp23
-rw-r--r--item_updater.hpp4
3 files changed, 22 insertions, 9 deletions
diff --git a/activation.cpp b/activation.cpp
index dc1993e..a938b8b 100644
--- a/activation.cpp
+++ b/activation.cpp
@@ -86,7 +86,7 @@ auto Activation::activation(Activations value) -> Activations
// Enable systemd signals
Activation::subscribeToSystemdSignals();
- parent.freeSpace();
+ parent.freeSpace(*this);
if (!activationProgress)
{
@@ -170,7 +170,7 @@ auto Activation::activation(Activations value) -> Activations
}
}
#endif
- parent.freeSpace();
+ parent.freeSpace(*this);
flashWrite();
diff --git a/item_updater.cpp b/item_updater.cpp
index 0fd2345..90a97d4 100644
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -583,7 +583,7 @@ void ItemUpdater::resetUbootEnvVars()
updateUbootEnvVars(lowestPriorityVersion);
}
-void ItemUpdater::freeSpace()
+void ItemUpdater::freeSpace(Activation& caller)
{
// Versions with the highest priority in front
std::priority_queue<std::pair<int, std::string>,
@@ -604,14 +604,25 @@ void ItemUpdater::freeSpace()
// remove the "running" BMC version.
// If ACTIVE_BMC_MAX_ALLOWED <= 1, there is only one active BMC,
// so remove functional version as well.
- if (versions.find(iter.second->versionId)->second->isFunctional() &&
- ACTIVE_BMC_MAX_ALLOWED > 1)
+ // Don't delete the the Activation object that called this function.
+ if ((versions.find(iter.second->versionId)
+ ->second->isFunctional() &&
+ ACTIVE_BMC_MAX_ALLOWED > 1) ||
+ (iter.second->versionId == caller.versionId))
{
continue;
}
- versionsPQ.push(std::make_pair(
- iter.second->redundancyPriority.get()->priority(),
- iter.second->versionId));
+
+ // Failed activations don't have priority, assign them a large value
+ // for sorting purposes.
+ auto priority = 999;
+ if (iter.second.get()->activation() ==
+ server::Activation::Activations::Active)
+ {
+ priority = iter.second->redundancyPriority.get()->priority();
+ }
+
+ versionsPQ.push(std::make_pair(priority, iter.second->versionId));
}
}
diff --git a/item_updater.hpp b/item_updater.hpp
index 12583f5..ac966ca 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -143,8 +143,10 @@ class ItemUpdater : public ItemUpdaterInherit
* needs to delete any BMC version(s) it will delete the
* version(s) with the highest priority, skipping the
* functional BMC version.
+ *
+ * @param[in] caller - The Activation object that called this function.
*/
- void freeSpace();
+ void freeSpace(Activation& caller);
private:
/** @brief Callback function for Software.Version match.
OpenPOWER on IntegriCloud