From fd0cafeb0580aa74c58d3b5827e1a85d5dba18ed Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Wed, 13 Oct 2021 00:01:20 +0800 Subject: [PATCH] [portorch]: Skip to create port if the lane set isn't available in ASIC (#1923) * Skip create port if the lane set isn't available in ASIC Signed-off-by: Ze Gan * Fix port breakout Signed-off-by: Ze Gan * Revert "Fix port breakout" This reverts commit b6c62b9a9cf4c4b4ccc5ab82ddb9732c899f8dea. * Revert "Skip create port if the lane set isn't available in ASIC" This reverts commit f521da377ba8dbc888fdc9cb7156450079339824. * Skip if add port failure Signed-off-by: Ze Gan * Fix bug Signed-off-by: Ze Gan * Skip if init port failure Signed-off-by: Ze Gan --- orchagent/orch.cpp | 17 +++++++++++++++++ orchagent/portsorch.cpp | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index d970c83f07d3..226512f388e4 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -705,6 +705,23 @@ task_process_status Orch::handleSaiCreateStatus(sai_api_t api, sai_status_t stat exit(EXIT_FAILURE); } break; + case SAI_API_HOSTIF: + switch (status) + { + case SAI_STATUS_SUCCESS: + return task_success; + case SAI_STATUS_FAILURE: + /* + * Host interface maybe failed due to lane not available. + * In some scenarios, like SONiC virtual machine, the invalid lane may be not enabled by VM configuration, + * So just ignore the failure and report an error log. + */ + return task_ignore; + default: + SWSS_LOG_ERROR("Encountered failure in create operation, exiting orchagent, SAI API: %s, status: %s", + sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); + exit(EXIT_FAILURE); + } default: switch (status) { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 68028e2c219d..a8bcef67c730 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2747,7 +2747,9 @@ void PortsOrch::doPortTask(Consumer &consumer) if (!initPort(get<0>(it->second), get<5>(it->second), get<4>(it->second), it->first)) { - throw runtime_error("PortsOrch initialization failure."); + // Failure has been recorded in initPort + it++; + continue; } initPortSupportedSpeeds(get<0>(it->second), m_portListLaneMap[it->first]);