Skip to content

Commit

Permalink
[orchagent] Do not pollute logs when unknown field is found
Browse files Browse the repository at this point in the history
This will prevent future unittest failing since there is syslog rate
limitting in place, causing message drop when large amount of messages
is arriving
  • Loading branch information
kcudnik committed May 24, 2024
1 parent 5ffb0b5 commit 8380149
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions orchagent/port/porthlpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <unordered_map>
#include <string>
#include <exception>
#include <set>

#include <boost/algorithm/string.hpp>

Expand Down Expand Up @@ -777,6 +778,8 @@ bool PortHelper::parsePortConfig(PortConfig &port) const
{
SWSS_LOG_ENTER();

std::set<std::string> unknown;

for (const auto &cit : port.fieldValueMap)
{
const auto &field = cit.first;
Expand Down Expand Up @@ -1029,6 +1032,11 @@ bool PortHelper::parsePortConfig(PortConfig &port) const
}
else
{
if (unknown.find(field) != unknown.end())
continue; // do not pollute logs with the same unknown field

unknown.insert(field);

SWSS_LOG_WARN("Unknown field(%s): skipping ...", field.c_str());
}
}
Expand Down

0 comments on commit 8380149

Please sign in to comment.