From 0558e2392116c8792dcd698fec555fdf1d6f4f76 Mon Sep 17 00:00:00 2001 From: Shi Su Date: Wed, 2 Jun 2021 17:01:49 +0000 Subject: [PATCH 01/12] Add failure handling for SAI get operations --- orchagent/aclorch.cpp | 22 ++++-- orchagent/bufferorch.cpp | 8 +- orchagent/copporch.cpp | 6 +- orchagent/crmorch.cpp | 18 ++++- orchagent/fabricportsorch.cpp | 36 +++++++-- orchagent/fdborch.cpp | 6 +- orchagent/fgnhgorch.cpp | 10 ++- orchagent/macsecorch.cpp | 15 ++-- orchagent/natorch.cpp | 53 +++++++++++++ orchagent/neighorch.cpp | 6 +- orchagent/orch.cpp | 30 +++++++ orchagent/orch.h | 1 + orchagent/portsorch.cpp | 143 ++++++++++++++++++++++++++++------ orchagent/qosorch.cpp | 24 +++++- orchagent/routeorch.cpp | 6 +- orchagent/switchorch.cpp | 5 ++ 16 files changed, 335 insertions(+), 54 deletions(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 7f2ccfb50c..d2ee99b186 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2309,7 +2309,11 @@ void AclOrch::init(vector& connectors, PortsOrch *portOrch, Mirr else { SWSS_LOG_ERROR("Failed to get ACL entry priority min/max values, rv:%d", status); - throw "AclOrch initialization failure"; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + throw "AclOrch initialization failure"; + } } queryAclActionCapability(); @@ -2376,7 +2380,11 @@ void AclOrch::queryAclActionCapability() SWSS_LOG_WARN("Failed to query ACL %s action capabilities - " "API assumed to be not implemented, using defaults", stage_str); - initDefaultAclActionCapabilities(stage); + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + initDefaultAclActionCapabilities(stage); + } } // put capabilities in state DB @@ -2388,10 +2396,14 @@ void AclOrch::queryAclActionCapability() SWSS_LOG_WARN("Failed to query maximum ACL action count - " "API assumed to be not implemented, using defaults capabilities for both %s and %s", STAGE_INGRESS, STAGE_EGRESS); - for (auto stage: {ACL_STAGE_INGRESS, ACL_STAGE_EGRESS}) + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) { - initDefaultAclActionCapabilities(stage); - putAclActionCapabilityInDB(stage); + for (auto stage: {ACL_STAGE_INGRESS, ACL_STAGE_EGRESS}) + { + initDefaultAclActionCapabilities(stage); + putAclActionCapabilityInDB(stage); + } } } diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 5aa42f4265..16b72d5d87 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -149,8 +149,12 @@ void BufferOrch::initBufferConstants() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get Maximum memory size, rv:%d", status); - // This is not a mandatory attribute so in case of failure we just return - return; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + // This is not a mandatory attribute so in case of failure we just return + return; + } } vector fvVector; diff --git a/orchagent/copporch.cpp b/orchagent/copporch.cpp index 403fcb98d9..34d83dd274 100644 --- a/orchagent/copporch.cpp +++ b/orchagent/copporch.cpp @@ -179,7 +179,11 @@ void CoppOrch::initDefaultTrapGroup() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get default trap group, rv:%d", status); - throw "CoppOrch initialization failure"; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + throw "CoppOrch initialization failure"; + } } SWSS_LOG_INFO("Get default trap group"); diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index e0eb24239b..a95022707d 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -488,7 +488,11 @@ void CrmOrch::getResAvailableCounters() break; } SWSS_LOG_ERROR("Failed to get switch attribute %u , rv:%d", attr.id, status); - break; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + break; + } } res.second.countersMap[CRM_COUNTERS_TABLE_KEY].availableCounter = attr.value.u32; @@ -517,7 +521,11 @@ void CrmOrch::getResAvailableCounters() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get switch attribute %u , rv:%d", attr.id, status); - break; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + break; + } } for (uint32_t i = 0; i < attr.value.aclresource.count; i++) @@ -541,7 +549,11 @@ void CrmOrch::getResAvailableCounters() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get ACL table attribute %u , rv:%d", attr.id, status); - break; + task_process_status handle_status = handleSaiGetStatus(SAI_API_ACL, status); + if (handle_status != task_process_status::task_success) + { + break; + } } cnt.second.availableCounter = attr.value.u32; diff --git a/orchagent/fabricportsorch.cpp b/orchagent/fabricportsorch.cpp index a4644dfffc..1adb84ec08 100644 --- a/orchagent/fabricportsorch.cpp +++ b/orchagent/fabricportsorch.cpp @@ -88,7 +88,11 @@ int FabricPortsOrch::getFabricPortList() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get fabric port number, rv:%d", status); - return FABRIC_PORT_ERROR; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + return FABRIC_PORT_ERROR; + } } m_fabricPortCount = attr.value.u32; SWSS_LOG_NOTICE("Get %d fabric ports", m_fabricPortCount); @@ -101,7 +105,11 @@ int FabricPortsOrch::getFabricPortList() status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); if (status != SAI_STATUS_SUCCESS) { - throw runtime_error("FabricPortsOrch get port list failure"); + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("FabricPortsOrch get port list failure"); + } } for (i = 0; i < m_fabricPortCount; i++) @@ -113,7 +121,11 @@ int FabricPortsOrch::getFabricPortList() status = sai_port_api->get_port_attribute(fabric_port_list[i], 1, &attr); if (status != SAI_STATUS_SUCCESS) { - throw runtime_error("FabricPortsOrch get port lane failure"); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("FabricPortsOrch get port lane failure"); + } } int lane = attr.value.u32list.list[0]; m_fabricLanePortMap[lane] = fabric_port_list[i]; @@ -198,7 +210,11 @@ void FabricPortsOrch::updateFabricPortState() { // Port may not be ready for query SWSS_LOG_ERROR("Failed to get fabric port (%d) status, rv:%d", lane, status); - return; + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + return; + } } if (m_portStatus.find(lane) != m_portStatus.end() && @@ -215,7 +231,11 @@ void FabricPortsOrch::updateFabricPortState() status = sai_port_api->get_port_attribute(port, 1, &attr); if (status != SAI_STATUS_SUCCESS) { - throw runtime_error("FabricPortsOrch get remote id failure"); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("FabricPortsOrch get remote id failure"); + } } remote_peer = attr.value.u32; @@ -223,7 +243,11 @@ void FabricPortsOrch::updateFabricPortState() status = sai_port_api->get_port_attribute(port, 1, &attr); if (status != SAI_STATUS_SUCCESS) { - throw runtime_error("FabricPortsOrch get remote port index failure"); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("FabricPortsOrch get remote port index failure"); + } } remote_port = attr.value.u32; } diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index af46d958ec..7dc74372c9 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -503,7 +503,11 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port) { SWSS_LOG_ERROR("Failed to get bridge port ID for FDB entry %s, rv:%d", mac.to_string().c_str(), status); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_FDB, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } if (!m_portsOrch->getPortByBridgePortId(attr.value.oid, port)) diff --git a/orchagent/fgnhgorch.cpp b/orchagent/fgnhgorch.cpp index de791678ac..f1328df37f 100644 --- a/orchagent/fgnhgorch.cpp +++ b/orchagent/fgnhgorch.cpp @@ -294,11 +294,15 @@ bool FgNhgOrch::createFineGrainedNextHopGroup(FGNextHopGroupEntry &syncd_fg_rout { SWSS_LOG_ERROR("Failed to query next hop group %s SAI_NEXT_HOP_GROUP_ATTR_REAL_SIZE, rv:%d", nextHops.to_string().c_str(), status); - if (!removeFineGrainedNextHopGroup(&syncd_fg_route_entry)) + task_process_status handle_status = handleSaiGetStatus(SAI_API_NEXT_HOP_GROUP, status); + if (handle_status != task_process_status::task_success) { - SWSS_LOG_ERROR("Failed to clean-up after next hop group real_size query failure"); + if (!removeFineGrainedNextHopGroup(&syncd_fg_route_entry)) + { + SWSS_LOG_ERROR("Failed to clean-up after next hop group real_size query failure"); + } + return parseHandleSaiStatusFailure(handle_status); } - return false; } fgNhgEntry->real_bucket_size = nhg_attr.value.u32; } diff --git a/orchagent/macsecorch.cpp b/orchagent/macsecorch.cpp index c5510a16fa..14c852c207 100644 --- a/orchagent/macsecorch.cpp +++ b/orchagent/macsecorch.cpp @@ -854,15 +854,20 @@ bool MACsecOrch::initMACsecObject(sai_object_id_t switch_id) attrs.clear(); attr.id = SAI_MACSEC_ATTR_SCI_IN_INGRESS_MACSEC_ACL; attrs.push_back(attr); - if (sai_macsec_api->get_macsec_attribute( - macsec_obj.first->second.m_ingress_id, - static_cast(attrs.size()), - attrs.data()) != SAI_STATUS_SUCCESS) + status = sai_macsec_api->get_macsec_attribute( + macsec_obj.first->second.m_ingress_id, + static_cast(attrs.size()), + attrs.data()); + if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_WARN( "Cannot get MACsec attribution SAI_MACSEC_ATTR_SCI_IN_INGRESS_MACSEC_ACL at the switch 0x%" PRIx64, switch_id); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_MACSEC, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } macsec_obj.first->second.m_sci_in_ingress_macsec_acl = attrs.front().value.booldata; diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index 283110efd1..58881508f8 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -115,6 +115,7 @@ NatOrch::NatOrch(DBConnector *appDb, DBConnector *stateDb, vector tmp_lane_set; @@ -459,7 +475,11 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vectorget_port_attribute(id, 1, &attr); if (status == SAI_STATUS_SUCCESS) + { speed = attr.value.u32; + } + else + { + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } + } return status == SAI_STATUS_SUCCESS; } @@ -1994,7 +2041,11 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get queue type and index for queue %" PRIu64 " rv:%d", queue_id, status); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_QUEUE, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } switch (attr[0].value.s32) @@ -3860,7 +3911,11 @@ void PortsOrch::initializeQueues(Port &port) if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get number of queues for port %s rv:%d", port.m_alias.c_str(), status); - throw runtime_error("PortsOrch initialization failure."); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("PortsOrch initialization failure."); + } } SWSS_LOG_INFO("Get %d queues for port %s", attr.value.u32, port.m_alias.c_str()); @@ -3880,7 +3935,11 @@ void PortsOrch::initializeQueues(Port &port) if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get queue list for port %s rv:%d", port.m_alias.c_str(), status); - throw runtime_error("PortsOrch initialization failure."); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("PortsOrch initialization failure."); + } } SWSS_LOG_INFO("Get queues for port %s", port.m_alias.c_str()); @@ -3896,7 +3955,11 @@ void PortsOrch::initializePriorityGroups(Port &port) if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get number of priority groups for port %s rv:%d", port.m_alias.c_str(), status); - throw runtime_error("PortsOrch initialization failure."); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("PortsOrch initialization failure."); + } } SWSS_LOG_INFO("Get %d priority groups for port %s", attr.value.u32, port.m_alias.c_str()); @@ -3917,7 +3980,11 @@ void PortsOrch::initializePriorityGroups(Port &port) if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Fail to get priority group list for port %s rv:%d", port.m_alias.c_str(), status); - throw runtime_error("PortsOrch initialization failure."); + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + throw runtime_error("PortsOrch initialization failure."); + } } SWSS_LOG_INFO("Get priority groups for port %s", port.m_alias.c_str()); } @@ -3932,7 +3999,11 @@ void PortsOrch::initializePortMaximumHeadroom(Port &port) if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_NOTICE("Unable to get the maximum headroom for port %s rv:%d, ignored", port.m_alias.c_str(), status); - return; + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + return; + } } vector fvVector; @@ -5413,7 +5484,11 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id, { SWSS_LOG_ERROR("Failed to get port attr serdes id %d to port pid:0x%" PRIx64, port_attr.id, port_id); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } if (port_attr.value.oid != SAI_NULL_OBJECT_ID) @@ -5477,7 +5552,11 @@ void PortsOrch::removePortSerdesAttribute(sai_object_id_t port_id) { SWSS_LOG_DEBUG("Failed to get port attr serdes id %d to port pid:0x%" PRIx64, port_attr.id, port_id); - return; + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); + if (handle_status != task_process_status::task_success) + { + return; + } } if (port_attr.value.oid != SAI_NULL_OBJECT_ID) @@ -5886,7 +5965,11 @@ bool PortsOrch::getSystemPorts() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_INFO("Failed to get number of system ports, rv:%d", status); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } m_systemPortCount = attr.value.u32; @@ -5907,7 +5990,11 @@ bool PortsOrch::getSystemPorts() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get system port list, rv:%d", status); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } uint32_t spcnt = attr.value.objlist.count; @@ -5919,7 +6006,11 @@ bool PortsOrch::getSystemPorts() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get system port config info spid:%" PRIx64, system_port_list[i]); - return false; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SYSTEM_PORT, status); + if (handle_status != task_process_status::task_success) + { + return parseHandleSaiStatusFailure(handle_status); + } } SWSS_LOG_NOTICE("SystemPort(0x%" PRIx64 ") - port_id:%u, switch_id:%u, core:%u, core_port:%u, speed:%u, voqs:%u", @@ -6102,7 +6193,11 @@ bool PortsOrch::addSystemPorts() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get system port config info spid:%" PRIx64, system_port_oid); - continue; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SYSTEM_PORT, status); + if (handle_status != task_process_status::task_success) + { + continue; + } } //Create or update system port and add to the port list. @@ -6121,7 +6216,11 @@ bool PortsOrch::addSystemPorts() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get local port oid of local system port spid:%" PRIx64, system_port_oid); - continue; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SYSTEM_PORT, status); + if (handle_status != task_process_status::task_success) + { + continue; + } } //System port for local port. Update the system port info in the existing physical port diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 31e61b5433..c2e15aa763 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -933,7 +933,11 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to get number of scheduler groups for port:%s", port.m_alias.c_str()); - return SAI_NULL_OBJECT_ID; + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, sai_status); + if (handle_status != task_process_status::task_success) + { + return SAI_NULL_OBJECT_ID; + } } /* Get total groups list on the port */ @@ -947,7 +951,11 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to get scheduler group list for port:%s", port.m_alias.c_str()); - return SAI_NULL_OBJECT_ID; + task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, sai_status); + if (handle_status != task_process_status::task_success) + { + return SAI_NULL_OBJECT_ID; + } } m_scheduler_group_port_info[port.m_port_id] = { @@ -969,7 +977,11 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to get child count for scheduler group:0x%" PRIx64 " of port:%s", group_id, port.m_alias.c_str()); - return SAI_NULL_OBJECT_ID; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SCHEDULER_GROUP, sai_status); + if (handle_status != task_process_status::task_success) + { + return SAI_NULL_OBJECT_ID; + } } uint32_t child_count = attr.value.u32; @@ -988,7 +1000,11 @@ sai_object_id_t QosOrch::getSchedulerGroup(const Port &port, const sai_object_id if (SAI_STATUS_SUCCESS != sai_status) { SWSS_LOG_ERROR("Failed to get child list for scheduler group:0x%" PRIx64 " of port:%s", group_id, port.m_alias.c_str()); - return SAI_NULL_OBJECT_ID; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SCHEDULER_GROUP, sai_status); + if (handle_status != task_process_status::task_success) + { + return SAI_NULL_OBJECT_ID; + } } m_scheduler_group_port_info[port.m_port_id].child_groups[ii] = std::move(child_groups); diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 0f688a64d0..3be2bda7f3 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -48,7 +48,11 @@ RouteOrch::RouteOrch(DBConnector *db, vector &tableNames, { SWSS_LOG_WARN("Failed to get switch attribute number of ECMP groups. \ Use default value. rv:%d", status); - m_maxNextHopGroupCount = DEFAULT_NUMBER_OF_ECMP_GROUPS; + task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); + if (handle_status != task_process_status::task_success) + { + m_maxNextHopGroupCount = DEFAULT_NUMBER_OF_ECMP_GROUPS; + } } else { diff --git a/orchagent/switchorch.cpp b/orchagent/switchorch.cpp index 77c8336123..a9f298f1d8 100644 --- a/orchagent/switchorch.cpp +++ b/orchagent/switchorch.cpp @@ -360,6 +360,7 @@ void SwitchOrch::doTask(SelectableTimer &timer) else { SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_TEMP_LIST: %d", status); + handleSaiGetStatus(SAI_API_SWITCH, status); } } @@ -384,6 +385,7 @@ void SwitchOrch::doTask(SelectableTimer &timer) { m_sensorsMaxTempSupported = false; SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_TEMP: %d", status); + handleSaiGetStatus(SAI_API_SWITCH, status); } } @@ -408,6 +410,7 @@ void SwitchOrch::doTask(SelectableTimer &timer) { m_sensorsAvgTempSupported = false; SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_AVERAGE_TEMP: %d", status); + handleSaiGetStatus(SAI_API_SWITCH, status); } } } @@ -441,6 +444,7 @@ void SwitchOrch::initSensorsTable() else { SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS: 0x%x", status); + handleSaiGetStatus(SAI_API_SWITCH, status); } } @@ -465,6 +469,7 @@ void SwitchOrch::initSensorsTable() else { SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_TEMP_LIST: %d", status); + handleSaiGetStatus(SAI_API_SWITCH, status); } } From 424029266e2ae64a225c83b981fd1e70bae73649 Mon Sep 17 00:00:00 2001 From: Shi Su Date: Wed, 2 Jun 2021 18:20:03 +0000 Subject: [PATCH 02/12] Skip orchagent exit in mock test --- orchagent/orch.cpp | 7 +++++-- tests/mock_tests/portal.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 355878a230..475a259ed0 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -786,8 +786,11 @@ task_process_status Orch::handleSaiGetStatus(sai_api_t api, sai_status_t status, case SAI_STATUS_NOT_IMPLEMENTED: SWSS_LOG_ERROR("Encountered failure in get operation due to the function is not implemented, exiting orchagent, SAI API: %s", sai_serialize_api(api).c_str()); - // exit(EXIT_FAILURE); - break; // TODO: enable EXIT_FAILURE +#ifdef MOCK_TEST + exit(EXIT_FAILURE); +#else + break; +#endif default: SWSS_LOG_ERROR("Encountered failure in get operation, SAI API: %s, status: %s", sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); diff --git a/tests/mock_tests/portal.h b/tests/mock_tests/portal.h index 7dab40036b..596d1efef2 100644 --- a/tests/mock_tests/portal.h +++ b/tests/mock_tests/portal.h @@ -2,12 +2,14 @@ #define private public #define protected public +#define MOCK_TEST #include "aclorch.h" #include "crmorch.h" #undef protected #undef private +#undef MOCK_TEST struct Portal { From ff4cbf3c5c1135682670594ed4f39236e007ad54 Mon Sep 17 00:00:00 2001 From: Shi Su Date: Wed, 23 Jun 2021 03:12:25 +0000 Subject: [PATCH 03/12] undo changes for mock tests --- orchagent/bufferorch.cpp | 8 ++------ orchagent/orch.cpp | 4 ---- orchagent/portsorch.cpp | 12 ++---------- tests/mock_tests/portal.h | 2 -- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 16b72d5d87..5aa42f4265 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -149,12 +149,8 @@ void BufferOrch::initBufferConstants() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get Maximum memory size, rv:%d", status); - task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); - if (handle_status != task_process_status::task_success) - { - // This is not a mandatory attribute so in case of failure we just return - return; - } + // This is not a mandatory attribute so in case of failure we just return + return; } vector fvVector; diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 475a259ed0..e5cc0b02b3 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -786,11 +786,7 @@ task_process_status Orch::handleSaiGetStatus(sai_api_t api, sai_status_t status, case SAI_STATUS_NOT_IMPLEMENTED: SWSS_LOG_ERROR("Encountered failure in get operation due to the function is not implemented, exiting orchagent, SAI API: %s", sai_serialize_api(api).c_str()); -#ifdef MOCK_TEST exit(EXIT_FAILURE); -#else - break; -#endif default: SWSS_LOG_ERROR("Encountered failure in get operation, SAI API: %s, status: %s", sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index d7deb86024..ed61771fd9 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -3999,11 +3999,7 @@ void PortsOrch::initializePortMaximumHeadroom(Port &port) if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_NOTICE("Unable to get the maximum headroom for port %s rv:%d, ignored", port.m_alias.c_str(), status); - task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); - if (handle_status != task_process_status::task_success) - { - return; - } + return; } vector fvVector; @@ -5965,11 +5961,7 @@ bool PortsOrch::getSystemPorts() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_INFO("Failed to get number of system ports, rv:%d", status); - task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); - if (handle_status != task_process_status::task_success) - { - return parseHandleSaiStatusFailure(handle_status); - } + return false; } m_systemPortCount = attr.value.u32; diff --git a/tests/mock_tests/portal.h b/tests/mock_tests/portal.h index 596d1efef2..7dab40036b 100644 --- a/tests/mock_tests/portal.h +++ b/tests/mock_tests/portal.h @@ -2,14 +2,12 @@ #define private public #define protected public -#define MOCK_TEST #include "aclorch.h" #include "crmorch.h" #undef protected #undef private -#undef MOCK_TEST struct Portal { From 04ae8f7e4131cdebcb559179551ecf03b0890f5d Mon Sep 17 00:00:00 2001 From: Shi Su Date: Wed, 23 Jun 2021 19:18:48 +0000 Subject: [PATCH 04/12] Undo a few changes --- orchagent/crmorch.cpp | 6 +----- orchagent/natorch.cpp | 1 - orchagent/portsorch.cpp | 6 +----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index a95022707d..bdd899057a 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -549,11 +549,7 @@ void CrmOrch::getResAvailableCounters() if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get ACL table attribute %u , rv:%d", attr.id, status); - task_process_status handle_status = handleSaiGetStatus(SAI_API_ACL, status); - if (handle_status != task_process_status::task_success) - { - break; - } + break; } cnt.second.availableCounter = attr.value.u32; diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index 58881508f8..fbe4155571 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -3599,7 +3599,6 @@ bool NatOrch::getNatCounters(const NatEntry::iterator &iter) { SWSS_LOG_ERROR("Failed to get Counters for SNAT entry [src-ip %s], bytes = %" PRIu64 ", pkts = %" PRIu64 "", ipAddr.to_string().c_str(), nat_entry_attr[0].value.u64, nat_entry_attr[1].value.u64); - handleSaiGetStatus(SAI_API_NAT, status); } else { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index ed61771fd9..3972437fd9 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -5548,11 +5548,7 @@ void PortsOrch::removePortSerdesAttribute(sai_object_id_t port_id) { SWSS_LOG_DEBUG("Failed to get port attr serdes id %d to port pid:0x%" PRIx64, port_attr.id, port_id); - task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); - if (handle_status != task_process_status::task_success) - { - return; - } + return; } if (port_attr.value.oid != SAI_NULL_OBJECT_ID) From 30d3069832bb0dcefdfd3dab5b564f0e364beefb Mon Sep 17 00:00:00 2001 From: Shi Su Date: Mon, 28 Jun 2021 21:57:26 +0000 Subject: [PATCH 05/12] Fix return value --- orchagent/orch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index e5cc0b02b3..440219bbef 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -791,7 +791,7 @@ task_process_status Orch::handleSaiGetStatus(sai_api_t api, sai_status_t status, SWSS_LOG_ERROR("Encountered failure in get operation, SAI API: %s, status: %s", sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); } - return task_failed; + return task_need_retry; } bool Orch::parseHandleSaiStatusFailure(task_process_status status) From bf7ed8bbffd4ccacdc3f81cc835421a6852ef14a Mon Sep 17 00:00:00 2001 From: Shi Su Date: Tue, 29 Jun 2021 16:56:55 +0000 Subject: [PATCH 06/12] Skip handling for getNaptCounters --- orchagent/natorch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index fbe4155571..b08f16abcc 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -3819,7 +3819,6 @@ bool NatOrch::getNaptCounters(const NaptEntry::iterator &iter) SWSS_LOG_ERROR("Failed to get Counters for SNAPT entry for [proto %s, src-ip %s, src-port %d], bytes = %" PRIu64 ", pkts = %" PRIu64 "", naptKey.prototype.c_str(), naptKey.ip_address.to_string().c_str(), naptKey.l4_port, nat_entry_attr[0].value.u64, nat_entry_attr[1].value.u64); - handleSaiGetStatus(SAI_API_NAT, status); } else { From c31063ef76526e33a4b28991884e7c172ba2890c Mon Sep 17 00:00:00 2001 From: Shi Su Date: Wed, 30 Jun 2021 20:59:18 +0000 Subject: [PATCH 07/12] Address review comments --- orchagent/aclorch.cpp | 16 ++++------------ orchagent/fdborch.cpp | 2 +- orchagent/fgnhgorch.cpp | 2 +- orchagent/macsecorch.cpp | 2 +- orchagent/natorch.cpp | 34 +--------------------------------- orchagent/orch.cpp | 4 ++-- orchagent/portsorch.cpp | 18 +++++++++--------- 7 files changed, 19 insertions(+), 59 deletions(-) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index d2ee99b186..a2f5482a36 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2380,11 +2380,7 @@ void AclOrch::queryAclActionCapability() SWSS_LOG_WARN("Failed to query ACL %s action capabilities - " "API assumed to be not implemented, using defaults", stage_str); - task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); - if (handle_status != task_process_status::task_success) - { - initDefaultAclActionCapabilities(stage); - } + initDefaultAclActionCapabilities(stage); } // put capabilities in state DB @@ -2396,14 +2392,10 @@ void AclOrch::queryAclActionCapability() SWSS_LOG_WARN("Failed to query maximum ACL action count - " "API assumed to be not implemented, using defaults capabilities for both %s and %s", STAGE_INGRESS, STAGE_EGRESS); - task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); - if (handle_status != task_process_status::task_success) + for (auto stage: {ACL_STAGE_INGRESS, ACL_STAGE_EGRESS}) { - for (auto stage: {ACL_STAGE_INGRESS, ACL_STAGE_EGRESS}) - { - initDefaultAclActionCapabilities(stage); - putAclActionCapabilityInDB(stage); - } + initDefaultAclActionCapabilities(stage); + putAclActionCapabilityInDB(stage); } } diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index 7dc74372c9..229dec0b15 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -506,7 +506,7 @@ bool FdbOrch::getPort(const MacAddress& mac, uint16_t vlan, Port& port) task_process_status handle_status = handleSaiGetStatus(SAI_API_FDB, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } diff --git a/orchagent/fgnhgorch.cpp b/orchagent/fgnhgorch.cpp index f1328df37f..4111665e09 100644 --- a/orchagent/fgnhgorch.cpp +++ b/orchagent/fgnhgorch.cpp @@ -301,7 +301,7 @@ bool FgNhgOrch::createFineGrainedNextHopGroup(FGNextHopGroupEntry &syncd_fg_rout { SWSS_LOG_ERROR("Failed to clean-up after next hop group real_size query failure"); } - return parseHandleSaiStatusFailure(handle_status); + return false; } } fgNhgEntry->real_bucket_size = nhg_attr.value.u32; diff --git a/orchagent/macsecorch.cpp b/orchagent/macsecorch.cpp index 14c852c207..ead1bfa81c 100644 --- a/orchagent/macsecorch.cpp +++ b/orchagent/macsecorch.cpp @@ -866,7 +866,7 @@ bool MACsecOrch::initMACsecObject(sai_object_id_t switch_id) task_process_status handle_status = handleSaiGetStatus(SAI_API_MACSEC, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } macsec_obj.first->second.m_sci_in_ingress_macsec_acl = attrs.front().value.booldata; diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index b08f16abcc..97021b6c5e 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -4299,22 +4299,6 @@ bool NatOrch::checkIfNatEntryIsActive(const NatEntry::iterator &iter, time_t now return 1; } } - else - { - task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); - if (handle_status != task_process_status::task_success) - { - return parseHandleSaiStatusFailure(handle_status); - } - } - } - } - else - { - task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); - if (handle_status != task_process_status::task_success) - { - return parseHandleSaiStatusFailure(handle_status); } } return 0; @@ -4429,22 +4413,6 @@ bool NatOrch::checkIfNaptEntryIsActive(const NaptEntry::iterator &iter, time_t n return 1; } } - else - { - task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); - if (handle_status != task_process_status::task_success) - { - return parseHandleSaiStatusFailure(handle_status); - } - } - } - } - else - { - task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); - if (handle_status != task_process_status::task_success) - { - return parseHandleSaiStatusFailure(handle_status); } } return 0; @@ -4576,7 +4544,7 @@ bool NatOrch::checkIfTwiceNaptEntryIsActive(const TwiceNaptEntry::iterator &iter task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return 1; } } return 0; diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 440219bbef..54e0eece51 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -760,9 +760,9 @@ task_process_status Orch::handleSaiRemoveStatus(sai_api_t api, sai_status_t stat default: SWSS_LOG_ERROR("Encountered failure in remove operation, exiting orchagent, SAI API: %s, status: %s", sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); - exit(EXIT_FAILURE); + throw std::logic_error("SAI get function not implemented"); } - return task_need_retry; + return task_failed; } task_process_status Orch::handleSaiGetStatus(sai_api_t api, sai_status_t status, void *context) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 3972437fd9..7176736562 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -987,7 +987,7 @@ bool PortsOrch::getPortAdminStatus(sai_object_id_t id, bool &up) task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } @@ -1970,11 +1970,11 @@ bool PortsOrch::getPortSpeed(sai_object_id_t id, sai_uint32_t &speed) task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } - return status == SAI_STATUS_SUCCESS; + return true; } bool PortsOrch::setPortAdvSpeeds(sai_object_id_t port_id, std::vector& speed_list) @@ -2044,7 +2044,7 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin task_process_status handle_status = handleSaiGetStatus(SAI_API_QUEUE, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } @@ -5483,7 +5483,7 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id, task_process_status handle_status = handleSaiGetStatus(SAI_API_PORT, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } @@ -5497,7 +5497,7 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id, task_process_status handle_status = handleSaiRemoveStatus(SAI_API_PORT, status); if (handle_status != task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } } @@ -5526,7 +5526,7 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id, task_process_status handle_status = handleSaiCreateStatus(SAI_API_PORT, status); if (handle_status != task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } SWSS_LOG_NOTICE("Created port serdes object 0x%" PRIx64 " for port 0x%" PRIx64, port_serdes_id, port_id); @@ -5981,7 +5981,7 @@ bool PortsOrch::getSystemPorts() task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } @@ -5997,7 +5997,7 @@ bool PortsOrch::getSystemPorts() task_process_status handle_status = handleSaiGetStatus(SAI_API_SYSTEM_PORT, status); if (handle_status != task_process_status::task_success) { - return parseHandleSaiStatusFailure(handle_status); + return false; } } From 8b94fb23b0b9c879466328a5a63dea0286c57f3b Mon Sep 17 00:00:00 2001 From: Shi Su Date: Wed, 30 Jun 2021 21:06:53 +0000 Subject: [PATCH 08/12] Address review comment - 2 --- orchagent/natorch.cpp | 16 ---------------- orchagent/portsorch.cpp | 4 ++-- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index 97021b6c5e..99f125c805 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -4469,14 +4469,6 @@ bool NatOrch::checkIfTwiceNatEntryIsActive(const TwiceNatEntry::iterator &iter, return 1; } } - else - { - task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); - if (handle_status != task_process_status::task_success) - { - return parseHandleSaiStatusFailure(handle_status); - } - } return 0; } @@ -4539,14 +4531,6 @@ bool NatOrch::checkIfTwiceNaptEntryIsActive(const TwiceNaptEntry::iterator &iter return 1; } } - else - { - task_process_status handle_status = handleSaiGetStatus(SAI_API_NAT, status); - if (handle_status != task_process_status::task_success) - { - return 1; - } - } return 0; } diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 7176736562..97a61d2538 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -5497,7 +5497,7 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id, task_process_status handle_status = handleSaiRemoveStatus(SAI_API_PORT, status); if (handle_status != task_success) { - return false; + return parseHandleSaiStatusFailure(handle_status); } } } @@ -5526,7 +5526,7 @@ bool PortsOrch::setPortSerdesAttribute(sai_object_id_t port_id, task_process_status handle_status = handleSaiCreateStatus(SAI_API_PORT, status); if (handle_status != task_success) { - return false; + return parseHandleSaiStatusFailure(handle_status); } } SWSS_LOG_NOTICE("Created port serdes object 0x%" PRIx64 " for port 0x%" PRIx64, port_serdes_id, port_id); From 74f401825da2e7c30807ce2bb3a22e3eceffebfb Mon Sep 17 00:00:00 2001 From: Shi Su Date: Thu, 1 Jul 2021 03:25:55 +0000 Subject: [PATCH 09/12] Fix natorch --- orchagent/natorch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index 99f125c805..df220a6b16 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -3895,7 +3895,6 @@ bool NatOrch::getTwiceNaptCounters(const TwiceNaptEntry::iterator &iter) SWSS_LOG_DEBUG("Failed to get Counters for Twice NAPT entry for [proto %s, src ip %s, src port %d, dst ip %s, dst port %d], as not yet added to HW", key.prototype.c_str(), key.src_ip.to_string().c_str(), key.src_l4_port, key.dst_ip.to_string().c_str(), key.dst_l4_port); - handleSaiGetStatus(SAI_API_NAT, status); } else { From c340b3e03b4c3dc06647cb1b9a08b8be38c02aa8 Mon Sep 17 00:00:00 2001 From: Shi Su Date: Thu, 1 Jul 2021 15:55:45 +0000 Subject: [PATCH 10/12] Fix a mistake of placing the change in a wrong function --- orchagent/orch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 54e0eece51..14187b79b4 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -760,9 +760,9 @@ task_process_status Orch::handleSaiRemoveStatus(sai_api_t api, sai_status_t stat default: SWSS_LOG_ERROR("Encountered failure in remove operation, exiting orchagent, SAI API: %s, status: %s", sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); - throw std::logic_error("SAI get function not implemented"); + exit(EXIT_FAILURE); } - return task_failed; + return task_need_retry; } task_process_status Orch::handleSaiGetStatus(sai_api_t api, sai_status_t status, void *context) @@ -786,12 +786,12 @@ task_process_status Orch::handleSaiGetStatus(sai_api_t api, sai_status_t status, case SAI_STATUS_NOT_IMPLEMENTED: SWSS_LOG_ERROR("Encountered failure in get operation due to the function is not implemented, exiting orchagent, SAI API: %s", sai_serialize_api(api).c_str()); - exit(EXIT_FAILURE); + throw std::logic_error("SAI get function not implemented"); default: SWSS_LOG_ERROR("Encountered failure in get operation, SAI API: %s, status: %s", sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); } - return task_need_retry; + return task_failed; } bool Orch::parseHandleSaiStatusFailure(task_process_status status) From b4dc2e3583b063e2f2403cb4b0ca103d510f06ae Mon Sep 17 00:00:00 2001 From: Shi Su Date: Fri, 2 Jul 2021 16:39:28 +0000 Subject: [PATCH 11/12] Remove handling for unnecessary scenario --- orchagent/natorch.cpp | 2 -- orchagent/routeorch.cpp | 6 +----- orchagent/switchorch.cpp | 5 ----- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/orchagent/natorch.cpp b/orchagent/natorch.cpp index df220a6b16..283110efd1 100644 --- a/orchagent/natorch.cpp +++ b/orchagent/natorch.cpp @@ -115,7 +115,6 @@ NatOrch::NatOrch(DBConnector *appDb, DBConnector *stateDb, vector &tableNames, { SWSS_LOG_WARN("Failed to get switch attribute number of ECMP groups. \ Use default value. rv:%d", status); - task_process_status handle_status = handleSaiGetStatus(SAI_API_SWITCH, status); - if (handle_status != task_process_status::task_success) - { - m_maxNextHopGroupCount = DEFAULT_NUMBER_OF_ECMP_GROUPS; - } + m_maxNextHopGroupCount = DEFAULT_NUMBER_OF_ECMP_GROUPS; } else { diff --git a/orchagent/switchorch.cpp b/orchagent/switchorch.cpp index a9f298f1d8..77c8336123 100644 --- a/orchagent/switchorch.cpp +++ b/orchagent/switchorch.cpp @@ -360,7 +360,6 @@ void SwitchOrch::doTask(SelectableTimer &timer) else { SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_TEMP_LIST: %d", status); - handleSaiGetStatus(SAI_API_SWITCH, status); } } @@ -385,7 +384,6 @@ void SwitchOrch::doTask(SelectableTimer &timer) { m_sensorsMaxTempSupported = false; SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_TEMP: %d", status); - handleSaiGetStatus(SAI_API_SWITCH, status); } } @@ -410,7 +408,6 @@ void SwitchOrch::doTask(SelectableTimer &timer) { m_sensorsAvgTempSupported = false; SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_AVERAGE_TEMP: %d", status); - handleSaiGetStatus(SAI_API_SWITCH, status); } } } @@ -444,7 +441,6 @@ void SwitchOrch::initSensorsTable() else { SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_MAX_NUMBER_OF_TEMP_SENSORS: 0x%x", status); - handleSaiGetStatus(SAI_API_SWITCH, status); } } @@ -469,7 +465,6 @@ void SwitchOrch::initSensorsTable() else { SWSS_LOG_ERROR("ASIC sensors : failed to get SAI_SWITCH_ATTR_TEMP_LIST: %d", status); - handleSaiGetStatus(SAI_API_SWITCH, status); } } From fce41abb7089cf7649c209ee068dca693164f07b Mon Sep 17 00:00:00 2001 From: Shi Su Date: Fri, 2 Jul 2021 16:45:30 +0000 Subject: [PATCH 12/12] Remove handling for another unnecessary scenario --- orchagent/portsorch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 97a61d2538..096e9e4a65 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1787,7 +1787,6 @@ void PortsOrch::getPortSupportedSpeeds(const std::string& alias, sai_object_id_t { SWSS_LOG_ERROR("Failed to get a list of supported speeds for port %s id=%" PRIx64 ". Error=%d", alias.c_str(), port_id, status); - handleSaiGetStatus(SAI_API_PORT, status); } supported_speeds.clear(); // return empty