Skip to content

Commit

Permalink
[teammgrd]: Add retry logic for starting port channel with teamd (#756)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shuotian Cheng authored and yxieca committed Jan 16, 2019
1 parent 6cf834c commit 85f6322
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <unistd.h>

#include "exec.h"
#include "teammgr.h"
#include "logger.h"
Expand Down Expand Up @@ -160,7 +158,12 @@ void TeamMgr::doLagTask(Consumer &consumer)

if (m_lagList.find(alias) == m_lagList.end())
{
addLag(alias, min_links, fallback);
if (addLag(alias, min_links, fallback) == task_need_retry)
{
it++;
continue;
}

m_lagList.insert(alias);
}

Expand Down Expand Up @@ -363,7 +366,7 @@ bool TeamMgr::setLagMtu(const string &alias, const string &mtu)
return true;
}

bool TeamMgr::addLag(const string &alias, int min_links, bool fallback)
task_process_status TeamMgr::addLag(const string &alias, int min_links, bool fallback)
{
SWSS_LOG_ENTER();

Expand Down Expand Up @@ -400,12 +403,18 @@ bool TeamMgr::addLag(const string &alias, int min_links, bool fallback)
<< " -t " << alias
<< " -c " << conf.str()
<< " -L " << dump_path
<< " -d";
EXEC_WITH_ERROR_THROW(cmd.str(), res);
<< " -g -d";

if (exec(cmd.str(), res) != 0)
{
SWSS_LOG_INFO("Failed to start port channel %s with teamd, retry...",
alias.c_str());
return task_need_retry;
}

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

return true;
return task_success;
}

bool TeamMgr::removeLag(const string &alias)
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/teammgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TeamMgr : public Orch
void doLagMemberTask(Consumer &consumer);
void doPortUpdateTask(Consumer &consumer);

bool addLag(const string &alias, int min_links, bool fall_back);
task_process_status addLag(const string &alias, int min_links, bool fall_back);
bool removeLag(const string &alias);
task_process_status addLagMember(const string &lag, const string &member);
bool removeLagMember(const string &lag, const string &member);
Expand Down

0 comments on commit 85f6322

Please sign in to comment.