Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,53 @@ void TeamMgr::doTask(Consumer &consumer)
}
}


void TeamMgr::cleanTeamProcesses()
{
SWSS_LOG_ENTER();
SWSS_LOG_NOTICE("Cleaning up LAGs during shutdown...");
for (const auto& it: m_lagList)

std::unordered_map<std::string, pid_t> aliasPidMap;

for (const auto& alias: m_lagList)
{
std::string res;
pid_t pid;

{
std::stringstream cmd;
cmd << "cat " << shellquote("/var/run/teamd/" + alias + ".pid");
EXEC_WITH_ERROR_THROW(cmd.str(), res);
Copy link
Copy Markdown
Collaborator Author

@nazariig nazariig Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the performance is sufficient, we can probably gain more by replacing this part with FILE I/O API (in scope of 1024 LAGs)


pid = static_cast<pid_t>(std::stoul(res, nullptr, 10));
aliasPidMap[alias] = pid;
Copy link
Copy Markdown
Collaborator Author

@nazariig nazariig Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PIDs can be updated during LAG SET/REMOVE operations to gain more performance on shutdown (in scope of 1024 LAGs)


SWSS_LOG_INFO("Read port channel %s pid %d", alias.c_str(), pid);
}

{
std::stringstream cmd;
cmd << "kill -TERM " << pid;
EXEC_WITH_ERROR_THROW(cmd.str(), res);
Copy link
Copy Markdown
Collaborator Author

@nazariig nazariig Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the performance is sufficient, we can probably gain more by replacing this part with signals API (in scope of 1024 LAGs)


SWSS_LOG_INFO("Sent SIGTERM to port channel %s pid %d", alias.c_str(), pid);
}
}

for (const auto& cit: aliasPidMap)
{
//This will call team -k kill -t <teamdevicename> which internally send SIGTERM
removeLag(it);
const auto &alias = cit.first;
const auto &pid = cit.second;

std::stringstream cmd;
std::string res;

SWSS_LOG_NOTICE("Waiting for port channel %s to stop...", alias.c_str());

cmd << "tail -f --pid=" << pid << " /dev/null";
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the performance is sufficient, we can probably gain more by replacing this part with signals API (in scope of 1024 LAGs)

EXEC_WITH_ERROR_THROW(cmd.str(), res);
}

return;
SWSS_LOG_NOTICE("LAGs cleanup is done");
}

void TeamMgr::doLagTask(Consumer &consumer)
Expand Down
5 changes: 3 additions & 2 deletions cfgmgr/teammgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char **argv)
}

while (!received_sigterm)
{
{
Selectable *sel;
int ret;

Expand All @@ -91,7 +91,8 @@ int main(int argc, char **argv)
catch (const exception &e)
{
SWSS_LOG_ERROR("Runtime error: %s", e.what());
return EXIT_FAILURE;
}

return -1;
return EXIT_SUCCESS;
}