Skip to content

Commit

Permalink
[teammgrd]: Handle LAGs cleanup gracefully on Warm/Fast reboot. (#1934)
Browse files Browse the repository at this point in the history
Fixed LAGs cleanup on Warm/Fast reboot
  • Loading branch information
nazariig authored Nov 2, 2021
1 parent e92c1df commit 67278be
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,44 @@ void TeamMgr::cleanTeamProcesses()
std::string res;
pid_t pid;

try
{
std::stringstream cmd;
cmd << "cat " << shellquote("/var/run/teamd/" + alias + ".pid");
EXEC_WITH_ERROR_THROW(cmd.str(), res);
}
catch (const std::exception &e)
{
// Handle Warm/Fast reboot scenario
SWSS_LOG_NOTICE("Skipping non-existent port channel %s pid...", alias.c_str());
continue;
}

try
{
pid = static_cast<pid_t>(std::stoul(res, nullptr, 10));
aliasPidMap[alias] = pid;

SWSS_LOG_INFO("Read port channel %s pid %d", alias.c_str(), pid);
}
catch (const std::exception &e)
{
SWSS_LOG_ERROR("Failed to read port channel %s pid: %s", alias.c_str(), e.what());
continue;
}

try
{
std::stringstream cmd;
cmd << "kill -TERM " << pid;
EXEC_WITH_ERROR_THROW(cmd.str(), res);

SWSS_LOG_INFO("Sent SIGTERM to port channel %s pid %d", alias.c_str(), pid);
SWSS_LOG_NOTICE("Sent SIGTERM to port channel %s pid %d", alias.c_str(), pid);
}
catch (const std::exception &e)
{
SWSS_LOG_ERROR("Failed to send SIGTERM to port channel %s pid %d: %s", alias.c_str(), pid, e.what());
aliasPidMap.erase(alias);
}
}

Expand Down

0 comments on commit 67278be

Please sign in to comment.