Skip to content

Commit

Permalink
Move updates of platform name BIOS read counters
Browse files Browse the repository at this point in the history
Summary: This change ensures PM will also have the counters, since PM calls `getPlatformNameFromBios` rather than `getPlatormName`. No changes otherwise.

Reviewed By: kimdo8736

Differential Revision: D64415597

fbshipit-source-id: 463d1740380c3194e88c3d8d666a67481602bfff
  • Loading branch information
rationalis authored and facebook-github-bot committed Oct 16, 2024
1 parent a5160e9 commit 3a79cc4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fboss/platform/helpers/PlatformNameLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ std::string PlatformNameLib::getPlatformNameFromBios(bool writeToCache) const {
platformUtils_->execCommand(dmidecodeCommand);
if (exitStatus != 0) {
XLOG(ERR) << "Failed to get platform name from bios: " << stdout;
fb303::fbData->setCounter(kPlatformNameBiosReadFailures, 1);
throw std::runtime_error("Failed to get platform name from bios");
}
standardOut = folly::trimWhitespace(standardOut).str();
Expand All @@ -61,6 +62,7 @@ std::string PlatformNameLib::getPlatformNameFromBios(bool writeToCache) const {
if (writeToCache) {
platformFsUtils_->writeStringToFile(result, kCachePath, true);
}
fb303::fbData->setCounter(kPlatformNameBiosReadFailures, 0);
return result;
}

Expand All @@ -73,11 +75,8 @@ std::optional<std::string> PlatformNameLib::getPlatformName() const {
return result;
}
try {
auto nameFromBios = getPlatformNameFromBios();
fb303::fbData->setCounter(kPlatformNameBiosReadFailures, 0);
return nameFromBios;
return getPlatformNameFromBios();
} catch (const std::exception& e) {
fb303::fbData->setCounter(kPlatformNameBiosReadFailures, 1);
return std::nullopt;
}
}
Expand Down

0 comments on commit 3a79cc4

Please sign in to comment.