From f480d9ead3f53e0b47f4090b820aba05999deace Mon Sep 17 00:00:00 2001 From: lguohan Date: Wed, 4 Sep 2019 11:55:27 -0700 Subject: [PATCH] Revert "Remove the platform check for remove/add port action at init phase. (#1006)" This reverts commit 5be3963793d5d04807931f016faf1fcca87f6286. --- orchagent/portsorch.cpp | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 45c174158e5..d30fbcb8a6c 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1637,10 +1637,19 @@ void PortsOrch::doPortTask(Consumer &consumer) { if (m_lanesAliasSpeedMap.find(it->first) == m_lanesAliasSpeedMap.end()) { - if (!removePort(it->second)) + char *platform = getenv("platform"); + if (platform && (strstr(platform, BFN_PLATFORM_SUBSTRING) || strstr(platform, MLNX_PLATFORM_SUBSTRING))) { - throw runtime_error("PortsOrch initialization failure."); + if (!removePort(it->second)) + { + throw runtime_error("PortsOrch initialization failure."); + } + } + else + { + SWSS_LOG_NOTICE("Failed to remove Port %" PRIx64 " due to missing SAI remove_port API.", it->second); } + it = m_portListLaneMap.erase(it); } else @@ -1655,11 +1664,22 @@ void PortsOrch::doPortTask(Consumer &consumer) if (m_portListLaneMap.find(it->first) == m_portListLaneMap.end()) { - if (!addPort(it->first, get<1>(it->second), get<2>(it->second), get<3>(it->second))) + // work around to avoid syncd termination on SAI error due missing create_port SAI API + // can be removed when SAI redis return NotImplemented error + char *platform = getenv("platform"); + if (platform && (strstr(platform, BFN_PLATFORM_SUBSTRING) || strstr(platform, MLNX_PLATFORM_SUBSTRING))) { - throw runtime_error("PortsOrch initialization failure."); + if (!addPort(it->first, get<1>(it->second), get<2>(it->second), get<3>(it->second))) + { + throw runtime_error("PortsOrch initialization failure."); + } + + port_created = true; + } + else + { + SWSS_LOG_NOTICE("Failed to create Port %s due to missing SAI create_port API.", get<0>(it->second).c_str()); } - port_created = true; } else { @@ -2723,7 +2743,7 @@ bool PortsOrch::removeVlan(Port vlan) SWSS_LOG_ENTER(); if (m_port_ref_count[vlan.m_alias] > 0) { - SWSS_LOG_ERROR("Failed to remove ref count %d VLAN %s", + SWSS_LOG_ERROR("Failed to remove ref count %d VLAN %s", m_port_ref_count[vlan.m_alias], vlan.m_alias.c_str()); return false; @@ -2907,8 +2927,8 @@ bool PortsOrch::removeLag(Port lag) if (m_port_ref_count[lag.m_alias] > 0) { - SWSS_LOG_ERROR("Failed to remove ref count %d LAG %s", - m_port_ref_count[lag.m_alias], + SWSS_LOG_ERROR("Failed to remove ref count %d LAG %s", + m_port_ref_count[lag.m_alias], lag.m_alias.c_str()); return false; }