Skip to content

Commit bd652a0

Browse files
authored
[muxorch] Adding case for maintaining current state (#2280)
* [muxorch] Adding case for maintaining current state What I did: Added a case where if current and previous Mux states are the same, post a log entry that acknowleges this change and returns without doing anything.
1 parent 6b6dda6 commit bd652a0

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

orchagent/muxorch.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,19 @@ void MuxCable::setState(string new_state)
451451
new_state = muxStateValToString.at(ns);
452452

453453
auto it = muxStateTransition.find(make_pair(state_, ns));
454-
455454
if (it == muxStateTransition.end())
456455
{
457456
// Update HW Mux cable state anyways
458457
mux_cb_orch_->updateMuxState(mux_name_, new_state);
459-
SWSS_LOG_ERROR("State transition from %s to %s is not-handled ",
460-
muxStateValToString.at(state_).c_str(), new_state.c_str());
458+
if (strcmp(new_state.c_str(), muxStateValToString.at(state_).c_str()) == 0)
459+
{
460+
SWSS_LOG_NOTICE("[%s] Maintaining current MUX state", mux_name_.c_str());
461+
}
462+
else
463+
{
464+
SWSS_LOG_ERROR("State transition from %s to %s is not-handled ",
465+
muxStateValToString.at(state_).c_str(), new_state.c_str());
466+
}
461467
return;
462468
}
463469

tests/test_mux.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ class TestMuxTunnelBase():
9595
TC_TO_QUEUE_MAP = {str(i):str(i) for i in range(0, 8)}
9696
DSCP_TO_TC_MAP = {str(i):str(1) for i in range(0, 64)}
9797
TC_TO_PRIORITY_GROUP_MAP = {str(i):str(i) for i in range(0, 8)}
98-
98+
99+
def check_syslog(self, dvs, marker, err_log, expected_cnt):
100+
(exitcode, num) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \"%s\" | wc -l" % (marker, err_log)])
101+
assert num.strip() >= str(expected_cnt)
102+
99103
def create_vlan_interface(self, dvs):
100104
confdb = dvs.get_config_db()
101105

@@ -309,6 +313,15 @@ def create_and_test_neighbor(self, confdb, appdb, asicdb, dvs, dvs_route):
309313
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV4)
310314
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV6)
311315

316+
marker = dvs.add_log_marker()
317+
318+
self.set_mux_state(appdb, "Ethernet0", "active")
319+
self.set_mux_state(appdb, "Ethernet0", "active")
320+
self.check_syslog(dvs, marker, "Maintaining current MUX state", 1)
321+
322+
self.set_mux_state(appdb, "Ethernet0", "init")
323+
self.check_syslog(dvs, marker, "State transition from active to init is not-handled", 1)
324+
312325
def create_and_test_fdb(self, appdb, asicdb, dvs, dvs_route):
313326

314327
self.set_mux_state(appdb, "Ethernet0", "active")

0 commit comments

Comments
 (0)