Skip to content

Commit

Permalink
Enforce switchover when target state is standby AND mux mode is `st…
Browse files Browse the repository at this point in the history
…andby` (#281)

Description of PR
Summary:
Fixes # (issue)
Enforce switchover when target state is standby AND mux mode is standby.

sign-off: Jing Zhang [email protected]

Type of change
 Bug fix
 New feature
 Doc/Design
 Unit test
Approach
What is the motivation for this PR?
Soc agent can always restart and set the forwarding state to default "active" on host side. If this happens during ToR maintenance ( mux mode != auto), we still need to correct the state to "standby".

Work item tracking
Microsoft ADO (number only):
30158450
  • Loading branch information
zjswhhh authored and mssonicbld committed Dec 10, 2024
1 parent 7bd6566 commit 6a67b79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/link_manager/LinkManagerStateMachineActiveActive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,8 @@ void ActiveActiveStateMachine::switchMuxState(
if (forceSwitch ||
mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Auto ||
mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Detached ||
(mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Active && label == mux_state::MuxState::Label::Active)) {
(mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Active && label == mux_state::MuxState::Label::Active) ||
(mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Standby && label == mux_state::MuxState::Label::Standby)) {
MUXLOGWARNING(
boost::format("%s: Switching MUX state to '%s'") %
mMuxPortConfig.getPortName() %
Expand Down
22 changes: 22 additions & 0 deletions test/LinkManagerStateMachineActiveActiveTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,28 @@ TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveConfigStandby)
VALIDATE_STATE(Active, Active, Up);
}

TEST_F(LinkManagerStateMachineActiveActiveTest, ConfigStandbySocAgentRestart)
{
setMuxActive();

handleMuxConfig("standby", 1);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 2);
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Standby);
VALIDATE_STATE(Active, Standby, Up);

handleMuxState("standby", 3);
VALIDATE_STATE(Active, Standby, Up);

handleMuxState("active", 3);
VALIDATE_STATE(Active, Standby, Up);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 3);

handleMuxConfig("auto", 1);
EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 4);
EXPECT_EQ(mDbInterfacePtr->mLastSetMuxState, mux_state::MuxState::Label::Active);
VALIDATE_STATE(Active, Active, Up);
}

TEST_F(LinkManagerStateMachineActiveActiveTest, MuxActiveLinkProberPeerActive)
{
setMuxActive();
Expand Down

0 comments on commit 6a67b79

Please sign in to comment.