Skip to content

Commit 67278be

Browse files
authored
[teammgrd]: Handle LAGs cleanup gracefully on Warm/Fast reboot. (sonic-net#1934)
Fixed LAGs cleanup on Warm/Fast reboot
1 parent e92c1df commit 67278be

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

cfgmgr/teammgr.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -132,23 +132,44 @@ void TeamMgr::cleanTeamProcesses()
132132
std::string res;
133133
pid_t pid;
134134

135+
try
135136
{
136137
std::stringstream cmd;
137138
cmd << "cat " << shellquote("/var/run/teamd/" + alias + ".pid");
138139
EXEC_WITH_ERROR_THROW(cmd.str(), res);
140+
}
141+
catch (const std::exception &e)
142+
{
143+
// Handle Warm/Fast reboot scenario
144+
SWSS_LOG_NOTICE("Skipping non-existent port channel %s pid...", alias.c_str());
145+
continue;
146+
}
139147

148+
try
149+
{
140150
pid = static_cast<pid_t>(std::stoul(res, nullptr, 10));
141151
aliasPidMap[alias] = pid;
142152

143153
SWSS_LOG_INFO("Read port channel %s pid %d", alias.c_str(), pid);
144154
}
155+
catch (const std::exception &e)
156+
{
157+
SWSS_LOG_ERROR("Failed to read port channel %s pid: %s", alias.c_str(), e.what());
158+
continue;
159+
}
145160

161+
try
146162
{
147163
std::stringstream cmd;
148164
cmd << "kill -TERM " << pid;
149165
EXEC_WITH_ERROR_THROW(cmd.str(), res);
150166

151-
SWSS_LOG_INFO("Sent SIGTERM to port channel %s pid %d", alias.c_str(), pid);
167+
SWSS_LOG_NOTICE("Sent SIGTERM to port channel %s pid %d", alias.c_str(), pid);
168+
}
169+
catch (const std::exception &e)
170+
{
171+
SWSS_LOG_ERROR("Failed to send SIGTERM to port channel %s pid %d: %s", alias.c_str(), pid, e.what());
172+
aliasPidMap.erase(alias);
152173
}
153174
}
154175

0 commit comments

Comments
 (0)