Skip to content

Commit 7f3f498

Browse files
theasianpianistYogapriya-cisco
authored andcommitted
Accept detailed SAI status codes in dashportmaporch.cpp (sonic-net#3770)
What I did Check for specific SAI status codes instead of just SAI_STATUS_NOT_EXECUTED and respond accordingly Why I did it sonic-net/sonic-sairedis#1613 means that SAI should return accurate states codes for each entry in a bulk operation. Prior to this change, any failure in a bulk op meant the status for all objects involved was set to SAI_STATUS_NOT_EXECUTED. Signed-off-by: Yogapriya Mohankumar <ymohanku@cisco.com>
1 parent f1c6ad6 commit 7f3f498

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

orchagent/dash/dashportmaporch.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ bool DashPortMapOrch::addPortMapRangePost(DashPortMapRangeBulkContext &ctxt)
464464
sai_status_t status = *it_status++;
465465
if (status != SAI_STATUS_SUCCESS)
466466
{
467-
if (status == SAI_STATUS_NOT_EXECUTED)
467+
if (status == SAI_STATUS_ITEM_ALREADY_EXISTS)
468468
{
469-
SWSS_LOG_INFO("Port map range for %s not created, will retry later", ctxt.parent_map_id.c_str());
470-
return false;
469+
SWSS_LOG_INFO("Port map range for %s already exists", ctxt.parent_map_id.c_str());
470+
return true;
471471
}
472472
SWSS_LOG_ERROR("Failed to create port map range for %s, status: %s", ctxt.parent_map_id.c_str(), sai_serialize_status(status).c_str());
473473
task_process_status handle_status = handleSaiCreateStatus((sai_api_t)SAI_API_DASH_OUTBOUND_PORT_MAP, status);
@@ -523,10 +523,10 @@ bool DashPortMapOrch::removePortMapRangePost(DashPortMapRangeBulkContext &ctxt)
523523
sai_status_t status = *it_status++;
524524
if (status != SAI_STATUS_SUCCESS)
525525
{
526-
if (status == SAI_STATUS_NOT_EXECUTED)
526+
if (status == SAI_STATUS_ITEM_NOT_FOUND)
527527
{
528-
SWSS_LOG_INFO("Port map range for %s not removed, will retry later", ctxt.parent_map_id.c_str());
529-
return false;
528+
SWSS_LOG_INFO("Port map range for %s already removed", ctxt.parent_map_id.c_str());
529+
return true;
530530
}
531531
SWSS_LOG_ERROR("Failed to remove port map range for %s, status: %s", ctxt.parent_map_id.c_str(), sai_serialize_status(status).c_str());
532532
task_process_status handle_status = handleSaiCreateStatus((sai_api_t)SAI_API_DASH_OUTBOUND_PORT_MAP, status);

tests/mock_tests/dashportmaporch_ut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ namespace dashportmaporch_test
168168
EXPECT_CALL(*mock_sai_dash_outbound_port_map_api, create_outbound_port_map_port_range_entries).Times(2);
169169
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_TABLE_NAME, port_map1, dash::outbound_port_map::OutboundPortMap());
170170
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_RANGE_TABLE_NAME, key, port_map_range);
171-
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_RANGE_TABLE_NAME, key, port_map_range, true, false);
171+
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_RANGE_TABLE_NAME, key, port_map_range);
172172
}
173173

174174
TEST_F(DashPortMapOrchTest, RemoveNonexistPortMapRange)
@@ -179,7 +179,7 @@ namespace dashportmaporch_test
179179

180180
EXPECT_CALL(*mock_sai_dash_outbound_port_map_api, remove_outbound_port_map_port_range_entries);
181181
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_TABLE_NAME, port_map1, dash::outbound_port_map::OutboundPortMap());
182-
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_RANGE_TABLE_NAME, port_map_range_key, dash::outbound_port_map_range::OutboundPortMapRange(), false, false);
182+
SetDashTable(APP_DASH_OUTBOUND_PORT_MAP_RANGE_TABLE_NAME, port_map_range_key, dash::outbound_port_map_range::OutboundPortMapRange(), false);
183183
}
184184

185185
TEST_F(DashPortMapOrchTest, AddPortRangeWithoutPortMap)

0 commit comments

Comments
 (0)