-
Notifications
You must be signed in to change notification settings - Fork 692
[202012] [teammgrd]: Improve LAGs cleanup on shutdown #1831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
|
||
| pid = static_cast<pid_t>(std::stoul(res, nullptr, 10)); | ||
| aliasPidMap[alias] = pid; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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)