From 85f63223a252f011c0240dc405bf25c8259dd136 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Wed, 16 Jan 2019 09:53:03 -0800 Subject: [PATCH] [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 --- cfgmgr/teammgr.cpp | 23 ++++++++++++++++------- cfgmgr/teammgr.h | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cfgmgr/teammgr.cpp b/cfgmgr/teammgr.cpp index e8bacd60dfdc..c3c5f53d3d50 100644 --- a/cfgmgr/teammgr.cpp +++ b/cfgmgr/teammgr.cpp @@ -1,5 +1,3 @@ -#include - #include "exec.h" #include "teammgr.h" #include "logger.h" @@ -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); } @@ -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(); @@ -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) diff --git a/cfgmgr/teammgr.h b/cfgmgr/teammgr.h index adabc58aadfe..ce3864150f44 100644 --- a/cfgmgr/teammgr.h +++ b/cfgmgr/teammgr.h @@ -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);