diff --git a/teamsyncd/teamsync.cpp b/teamsyncd/teamsync.cpp index 846d474a6c..a0fe0ad93e 100644 --- a/teamsyncd/teamsync.cpp +++ b/teamsyncd/teamsync.cpp @@ -25,7 +25,8 @@ TeamSync::TeamSync(DBConnector *db, DBConnector *stateDb, Select *select) : m_select(select), m_lagTable(db, APP_LAG_TABLE_NAME), m_lagMemberTable(db, APP_LAG_MEMBER_TABLE_NAME), - m_stateLagTable(stateDb, STATE_LAG_TABLE_NAME) + m_stateLagTable(stateDb, STATE_LAG_TABLE_NAME), + m_stateWarmRestartEnableTable(stateDb, STATE_WARM_RESTART_ENABLE_TABLE_NAME) { WarmStart::initialize(TEAMSYNCD_APP_NAME, "teamd"); WarmStart::checkWarmStart(TEAMSYNCD_APP_NAME, "teamd"); @@ -215,13 +216,25 @@ void TeamSync::removeLag(const string &lagName) void TeamSync::cleanTeamSync() { SWSS_LOG_ENTER(); - SWSS_LOG_NOTICE("Cleaning up LAG teamd resources ..."); - for (const auto& it: m_teamSelectables) + std::string team_value, system_value; + m_stateWarmRestartEnableTable.hget("system", "enable", system_value); + m_stateWarmRestartEnableTable.hget("teamd", "enable", team_value); + if (system_value == "true" || team_value == "true") { - /* Cleanup LAG */ - removeLag(it.first); + SWSS_LOG_NOTICE("Warm restart enabled, skip cleaning teamd"); } + else + { + SWSS_LOG_NOTICE("Cleaning up LAG teamd resources ..."); + + for (const auto& it: m_teamSelectables) + { + /* Cleanup LAG */ + removeLag(it.first); + } + } + return; } diff --git a/teamsyncd/teamsync.h b/teamsyncd/teamsync.h index 406953e312..fc2e69ce56 100644 --- a/teamsyncd/teamsync.h +++ b/teamsyncd/teamsync.h @@ -71,6 +71,7 @@ class TeamSync : public NetMsg ProducerStateTable m_lagTable; ProducerStateTable m_lagMemberTable; Table m_stateLagTable; + Table m_stateWarmRestartEnableTable; bool m_warmstart; std::unordered_map> m_stateLagTablePreserved;