From c20902f3195b5bf8a941045e131aa1b863b69fd0 Mon Sep 17 00:00:00 2001 From: Divya Kumaran Chandralekha <66686927+divyachandralekha@users.noreply.github.com> Date: Tue, 7 Jan 2025 00:25:10 +0530 Subject: [PATCH] Fix stporch init exception (#3449) What I did Fixed stporch init exception Why I did it SAI retrieval of STP attributes may return either SAI_STATUS_NOT_SUPPORTED or SAI_STATUS_NOT_IMPLEMENTED. An exception has been added to handle such failures, preventing Orchagent from starting on systems where STP is not supported --- orchagent/stporch.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/orchagent/stporch.cpp b/orchagent/stporch.cpp index 38f502f321..d380609f39 100644 --- a/orchagent/stporch.cpp +++ b/orchagent/stporch.cpp @@ -20,6 +20,7 @@ StpOrch::StpOrch(DBConnector * db, DBConnector * stateDb, vector &tableN sai_attribute_t attr; sai_status_t status; + bool ret = false; m_stpTable = unique_ptr(new Table(stateDb, STATE_STP_TABLE_NAME)); @@ -28,12 +29,13 @@ StpOrch::StpOrch(DBConnector * db, DBConnector * stateDb, vector &tableN attrs.push_back(attr); status = sai_switch_api->get_switch_attribute(gSwitchId, (uint32_t)attrs.size(), attrs.data()); - if (status != SAI_STATUS_SUCCESS) + if (status == SAI_STATUS_SUCCESS) { - throw runtime_error("StpOrch initialization failure"); + m_defaultStpId = attrs[0].value.oid; + ret = true; } - - m_defaultStpId = attrs[0].value.oid; + + SWSS_LOG_NOTICE("StpOrch initialization %s", (ret == true)?"success":"failure"); };