Skip to content

Commit 85f6322

Browse files
Shuotian Chengyxieca
Shuotian Cheng
authored andcommitted
[teammgrd]: Add retry logic for starting port channel with teamd (#756)
teamd command may fail when failed to allocate memory to create the port channel. Retry logic make sure the creation will be successful. Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
1 parent 6cf834c commit 85f6322

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

cfgmgr/teammgr.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <unistd.h>
2-
31
#include "exec.h"
42
#include "teammgr.h"
53
#include "logger.h"
@@ -160,7 +158,12 @@ void TeamMgr::doLagTask(Consumer &consumer)
160158

161159
if (m_lagList.find(alias) == m_lagList.end())
162160
{
163-
addLag(alias, min_links, fallback);
161+
if (addLag(alias, min_links, fallback) == task_need_retry)
162+
{
163+
it++;
164+
continue;
165+
}
166+
164167
m_lagList.insert(alias);
165168
}
166169

@@ -363,7 +366,7 @@ bool TeamMgr::setLagMtu(const string &alias, const string &mtu)
363366
return true;
364367
}
365368

366-
bool TeamMgr::addLag(const string &alias, int min_links, bool fallback)
369+
task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fallback)
367370
{
368371
SWSS_LOG_ENTER();
369372

@@ -400,12 +403,18 @@ bool TeamMgr::addLag(const string &alias, int min_links, bool fallback)
400403
<< " -t " << alias
401404
<< " -c " << conf.str()
402405
<< " -L " << dump_path
403-
<< " -d";
404-
EXEC_WITH_ERROR_THROW(cmd.str(), res);
406+
<< " -g -d";
407+
408+
if (exec(cmd.str(), res) != 0)
409+
{
410+
SWSS_LOG_INFO("Failed to start port channel %s with teamd, retry...",
411+
alias.c_str());
412+
return task_need_retry;
413+
}
405414

406415
SWSS_LOG_NOTICE("Start port channel %s with teamd", alias.c_str());
407416

408-
return true;
417+
return task_success;
409418
}
410419

411420
bool TeamMgr::removeLag(const string &alias)

cfgmgr/teammgr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TeamMgr : public Orch
3737
void doLagMemberTask(Consumer &consumer);
3838
void doPortUpdateTask(Consumer &consumer);
3939

40-
bool addLag(const string &alias, int min_links, bool fall_back);
40+
task_process_status addLag(const string &alias, int min_links, bool fall_back);
4141
bool removeLag(const string &alias);
4242
task_process_status addLagMember(const string &lag, const string &member);
4343
bool removeLagMember(const string &lag, const string &member);

0 commit comments

Comments
 (0)