Skip to content

Commit 4248d01

Browse files
Ndancejicyxieca
andcommitted
[muxorch] set mux state to init upon warm reboot (sonic-net#2834)
Warm reboot with manual mux mode was causing orchagent crash. Initializing mux state to INIT upon warm reboot, the state will then be updated to reflect previous APPDB state. Signed-off-by: Nikola Dancejic <[email protected]> Co-authored-by: Ying Xie <[email protected]>
1 parent 3ca4b84 commit 4248d01

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

orchagent/muxorch.cpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "routeorch.h"
2525
#include "fdborch.h"
2626
#include "qosorch.h"
27+
#include "warm_restart.h"
2728

2829
/* Global variables */
2930
extern Directory<Orch*> gDirectory;
@@ -373,9 +374,18 @@ MuxCable::MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress
373374
state_machine_handlers_.insert(handler_pair(MUX_STATE_INIT_STANDBY, &MuxCable::stateStandby));
374375
state_machine_handlers_.insert(handler_pair(MUX_STATE_ACTIVE_STANDBY, &MuxCable::stateStandby));
375376

376-
/* Set initial state to "standby" */
377-
stateStandby();
378-
state_ = MuxState::MUX_STATE_STANDBY;
377+
if (WarmStart::isWarmStart()) {
378+
/* Warmboot case, Set initial state to "init"
379+
* State will be updated to previous value upon APP DB sync
380+
*/
381+
state_ = MuxState::MUX_STATE_INIT;
382+
}
383+
else
384+
{
385+
/* Set initial state to "standby" */
386+
stateStandby();
387+
state_ = MuxState::MUX_STATE_STANDBY;
388+
}
379389
}
380390

381391
bool MuxCable::stateInitActive()

tests/test_mux.py

+37
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,43 @@ def test_soc_ip(self, dvs, dvs_route, setup_vlan, setup_mux_cable, testlog):
11841184

11851185
self.create_and_test_soc(appdb, asicdb, dvs, dvs_route)
11861186

1187+
def test_warm_boot_mux_state(
1188+
self, dvs, dvs_route, setup_vlan, setup_mux_cable, setup_tunnel,
1189+
remove_peer_switch, neighbor_cleanup, testlog
1190+
):
1191+
"""
1192+
test mux initialization during warm boot.
1193+
"""
1194+
appdb = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)
1195+
apdb = dvs.get_app_db()
1196+
1197+
self.set_mux_state(appdb, "Ethernet0", "active")
1198+
self.set_mux_state(appdb, "Ethernet4", "active")
1199+
self.set_mux_state(appdb, "Ethernet8", "standby")
1200+
1201+
# Execute the warm reboot
1202+
dvs.runcmd("config warm_restart enable swss")
1203+
dvs.stop_swss()
1204+
dvs.start_swss()
1205+
1206+
time.sleep(5)
1207+
1208+
fvs = apdb.get_entry(self.APP_MUX_CABLE, "Ethernet0")
1209+
for key in fvs:
1210+
if key == "state":
1211+
assert fvs[key] == "active", "Ethernet0 Mux state is not active after warm boot, state: {}".format(fvs[key])
1212+
1213+
fvs = apdb.get_entry(self.APP_MUX_CABLE, "Ethernet4")
1214+
for key in fvs:
1215+
if key == "state":
1216+
assert fvs[key] == "active", "Ethernet4 Mux state is not active after warm boot, state: {}".format(fvs[key])
1217+
1218+
fvs = apdb.get_entry(self.APP_MUX_CABLE, "Ethernet8")
1219+
for key in fvs:
1220+
if key == "state":
1221+
assert fvs[key] == "standby", "Ethernet8 Mux state is not standby after warm boot, state: {}".format(fvs[key])
1222+
1223+
11871224
# Add Dummy always-pass test at end as workaroud
11881225
# for issue when Flaky fail on final test it invokes module tear-down before retrying
11891226
def test_nonflaky_dummy():

0 commit comments

Comments
 (0)