Skip to content

Commit 9bcb9b6

Browse files
authored
Fixing appl_db FABRIC_MONITOR notification issue. (#3176)
Why I did it appl_db FABRIC_MONITOR notification issue in current code, the notification not able to get processed when the feature is disabled. This change fixed the issue.
1 parent fff544e commit 9bcb9b6

5 files changed

Lines changed: 49 additions & 32 deletions

File tree

cfgmgr/fabricmgr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FabricMgr : public Orch
2020
private:
2121
Table m_cfgFabricMonitorTable;
2222
Table m_cfgFabricPortTable;
23-
ProducerStateTable m_appFabricMonitorTable;
23+
Table m_appFabricMonitorTable;
2424
ProducerStateTable m_appFabricPortTable;
2525

2626
void doTask(Consumer &consumer);

orchagent/fabricportsorch.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,32 +1444,6 @@ void FabricPortsOrch::doTask(Consumer &consumer)
14441444
{
14451445
doFabricPortTask(consumer);
14461446
}
1447-
if (table_name == APP_FABRIC_MONITOR_DATA_TABLE_NAME)
1448-
{
1449-
SWSS_LOG_INFO("doTask for APP_FABRIC_MONITOR_DATA_TABLE_NAME");
1450-
auto it = consumer.m_toSync.begin();
1451-
while (it != consumer.m_toSync.end())
1452-
{
1453-
KeyOpFieldsValuesTuple t = it->second;
1454-
for (auto i : kfvFieldsValues(t))
1455-
{
1456-
if (fvField(i) == "monState")
1457-
{
1458-
if (fvValue(i) == "enable")
1459-
{
1460-
m_debugTimer->start();
1461-
SWSS_LOG_INFO("debugTimer started");
1462-
}
1463-
else
1464-
{
1465-
m_debugTimer->stop();
1466-
SWSS_LOG_INFO("debugTimer stopped");
1467-
}
1468-
}
1469-
}
1470-
it = consumer.m_toSync.erase(it);
1471-
}
1472-
}
14731447
}
14741448

14751449
void FabricPortsOrch::doTask(swss::SelectableTimer &timer)
@@ -1487,6 +1461,16 @@ void FabricPortsOrch::doTask(swss::SelectableTimer &timer)
14871461
{
14881462
updateFabricPortState();
14891463
}
1464+
1465+
if (checkFabricPortMonState() && !m_debugTimerEnabled)
1466+
{
1467+
m_debugTimer->start();
1468+
m_debugTimerEnabled = true;
1469+
}
1470+
else if (!checkFabricPortMonState())
1471+
{
1472+
m_debugTimerEnabled = false;
1473+
}
14901474
}
14911475
else if (timer.getFd() == m_debugTimer->getFd())
14921476
{
@@ -1497,6 +1481,12 @@ void FabricPortsOrch::doTask(swss::SelectableTimer &timer)
14971481
return;
14981482
}
14991483

1484+
if (!m_debugTimerEnabled)
1485+
{
1486+
m_debugTimer->stop();
1487+
return;
1488+
}
1489+
15001490
if (m_getFabricPortListDone)
15011491
{
15021492
SWSS_LOG_INFO("Fabric monitor enabled");

orchagent/fabricportsorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class FabricPortsOrch : public Orch, public Subject
5151

5252
bool m_getFabricPortListDone = false;
5353
bool m_isQueueStatsGenerated = false;
54+
bool m_debugTimerEnabled = false;
5455

5556
string m_defaultPollWithErrors = "0";
5657
string m_defaultPollWithNoErrors = "8";

tests/test_fabric_capacity.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ def test_voq_switch_fabric_capacity(self, vst):
1717
dvs = dvss[name]
1818
# Get the config information and choose a linecard or fabric card to test.
1919
config_db = dvs.get_config_db()
20+
adb = dvs.get_app_db()
2021
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
2122

2223
cfg_switch_type = metatbl.get("switch_type")
2324
if cfg_switch_type == "fabric":
2425

2526
max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
27+
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'disable'})
28+
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'disable'}, polling_config=max_poll)
29+
# enable monitoring
2630
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
27-
adb = dvs.get_app_db()
2831
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)
2932

3033
# get state_db infor
@@ -39,8 +42,12 @@ def test_voq_switch_fabric_capacity(self, vst):
3942
sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST": "TEST"})
4043

4144
# get current fabric capacity
42-
capacity = sdb.get_entry("FABRIC_CAPACITY_TABLE", "FABRIC_CAPACITY_DATA")['operating_links']
43-
if sdb.get_entry("FABRIC_PORT_TABLE", sdb_port)['STATUS'] == 'up':
45+
fvs = sdb.wait_for_fields("FABRIC_CAPACITY_TABLE", "FABRIC_CAPACITY_DATA",['operating_links'], polling_config=max_poll)
46+
capacity = fvs['operating_links']
47+
48+
fvs = sdb.wait_for_fields("FABRIC_PORT_TABLE", sdb_port, ['STATUS'], polling_config=max_poll)
49+
link_status = fvs['STATUS']
50+
if link_status == 'up':
4451
try:
4552
# clean up the testing port.
4653
# set TEST_CRC_ERRORS to 0
@@ -57,6 +64,21 @@ def test_voq_switch_fabric_capacity(self, vst):
5764
config_db.update_entry("FABRIC_PORT", cdb_port, {"isolateStatus": "False"})
5865
sdb.wait_for_field_match("FABRIC_PORT_TABLE", sdb_port, {"ISOLATED": "0"}, polling_config=max_poll)
5966
sdb.wait_for_field_match("FABRIC_CAPACITY_TABLE", "FABRIC_CAPACITY_DATA", {'operating_links': capacity}, polling_config=max_poll)
67+
68+
# now disable fabric link monitor
69+
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'disable'})
70+
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'disable'}, polling_config=max_poll)
71+
# isolate the link from config_db
72+
config_db.update_entry("FABRIC_PORT", cdb_port, {"isolateStatus": "True"})
73+
try:
74+
max_poll = PollingConfig(polling_interval=30, timeout=90, strict=True)
75+
sdb.wait_for_field_match("FABRIC_PORT_TABLE", sdb_port, {"ISOLATED": "1"}, polling_config=max_poll)
76+
# check if capacity reduced
77+
sdb.wait_for_field_negative_match("FABRIC_CAPACITY_TABLE", "FABRIC_CAPACITY_DATA", {'operating_links': capacity}, polling_config=max_poll)
78+
assert False, "Expecting no change here"
79+
except Exception as e:
80+
# Expect field not change here
81+
pass
6082
finally:
6183
# cleanup
6284
sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST_CRC_ERRORS": "0"})

tests/test_fabric_rate.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ def test_voq_switch_fabric_rate(self, vst):
1717
dvs = dvss[name]
1818
# Get the config info
1919
config_db = dvs.get_config_db()
20+
adb = dvs.get_app_db()
2021
metatbl = config_db.get_entry("DEVICE_METADATA", "localhost")
2122

2223
cfg_switch_type = metatbl.get("switch_type")
2324
if cfg_switch_type == "fabric":
2425

2526
max_poll = PollingConfig(polling_interval=60, timeout=600, strict=True)
27+
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'disable'})
28+
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'disable'}, polling_config=max_poll)
2629
config_db.update_entry("FABRIC_MONITOR", "FABRIC_MONITOR_DATA",{'monState': 'enable'})
27-
adb = dvs.get_app_db()
2830
adb.wait_for_field_match("FABRIC_MONITOR_TABLE","FABRIC_MONITOR_DATA", {'monState': 'enable'}, polling_config=max_poll)
2931
# get state_db infor
3032
sdb = dvs.get_state_db()
@@ -35,7 +37,9 @@ def test_voq_switch_fabric_rate(self, vst):
3537
portNum = random.randint(1, 16)
3638
sdb_port = "PORT"+str(portNum)
3739

38-
tx_rate = sdb.get_entry("FABRIC_PORT_TABLE", sdb_port)['OLD_TX_DATA']
40+
fvs = sdb.wait_for_fields("FABRIC_PORT_TABLE", sdb_port, ['OLD_TX_DATA'], polling_config=max_poll)
41+
tx_rate = fvs['OLD_TX_DATA']
42+
3943
sdb.update_entry("FABRIC_PORT_TABLE", sdb_port, {"TEST": "TEST"})
4044
sdb.wait_for_field_negative_match("FABRIC_PORT_TABLE", sdb_port, {'OLD_TX_DATA': tx_rate}, polling_config=max_poll)
4145
finally:

0 commit comments

Comments
 (0)