summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorSui Chen <suichen@google.com>2022-03-25 00:59:52 +0300
committerEd Tanous <ed@tanous.net>2022-04-12 21:43:57 +0300
commit54417b02efbfe896d6ef442cfc6a721314aac3f8 (patch)
tree4fdce17342f38ef369ab6fee76953c707a0c3d83 /redfish-core
parent928fefb9a542b816d7c0418077def2b3874d1b0f (diff)
downloadbmcweb-54417b02efbfe896d6ef442cfc6a721314aac3f8.tar.xz
Skip on log entries not found in the message registry
Because logs populated by fillEventLogEntryJson are expected to be found in the message registry log entries that get returned in this function should have non-empty message and severity, because of the way registries work. Currently, for a log entry that is not present in the registry, the function will use its log entry as-is and leave the message and severity fields empty. This can cause the Redfish Service Validator to generate an error. This change fixes the fillEventLogEntryJson function so that when a log message is not found in the registry, the message is not used for populating the response, and is logged for further analysis. TESTED: First populate an offending entry. echo "1970-01-01T00:00:47.991326+00:00 OpenBMC.1.0.ServiceStarted," > \ /var/log/redfish Then run the Service Validator. Before this change: URL: /redfish/v1/Systems/system/LogServices/EventLog/Entries/60 *** /redfish/v1/Systems/system/LogServices/EventLog/Entries/60 Type (LogEntry.v1_8_0.LogEntry), GET SUCCESS (time: 0) Severity: Empty string found - Services should omit properties if not supported Severity: Value Enum not found in ['OK', 'Warning', 'Critical'] Message: Empty string found - Services should omit properties if not supported FAIL... After: the above response disappears from the response, the Validator error disappears, and the following appears in the system journal: (1970-01-01 13:01:47) [WARNING "log_services.hpp":1129] Log entry not found in registry: 1970-01-01T00:00:47.991326+00:00 OpenBMC.1.0.ServiceStarted, Signed-off-by: Sui Chen <suichen@google.com> Change-Id: Ifa600d1de0e6e0cea33e9e8dfde621ee9d4e3325
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/log_services.hpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index b79fd03e9f..49911f31d4 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1129,14 +1129,14 @@ static int fillEventLogEntryJson(const std::string& logEntryID,
// Get the Message from the MessageRegistry
const registries::Message* message = registries::getMessage(messageID);
- std::string msg;
- std::string severity;
- if (message != nullptr)
+ if (message == nullptr)
{
- msg = message->message;
- severity = message->messageSeverity;
+ BMCWEB_LOG_WARNING << "Log entry not found in registry: " << logEntry;
+ return 0;
}
+ std::string msg = message->message;
+
// Get the MessageArgs from the log if there are any
std::span<std::string> messageArgs;
if (logEntryFields.size() > 1)
@@ -1186,7 +1186,7 @@ static int fillEventLogEntryJson(const std::string& logEntryID,
{"MessageId", std::move(messageID)},
{"MessageArgs", messageArgs},
{"EntryType", "Event"},
- {"Severity", std::move(severity)},
+ {"Severity", message->messageSeverity},
{"Created", std::move(timestamp)}};
return 0;
}