Skip to content

Commit

Permalink
Start populating ReachabilityGroupList in switch state
Browse files Browse the repository at this point in the history
Summary: As titled. The need to use the new field of ReachabilityGroupList to pass the exact group IDs.

Reviewed By: jasmeetbagga

Differential Revision: D65992985

fbshipit-source-id: 104990cdeeac62e7861028b55fab016e9b6ff0c2
  • Loading branch information
Ron He authored and facebook-github-bot committed Nov 22, 2024
1 parent 71e9110 commit fbf7ea9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
44 changes: 24 additions & 20 deletions fboss/agent/ApplyThriftConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,24 +1241,29 @@ void ThriftConfigApplier::processReachabilityGroup(
}
}

auto updateReachabilityGroupListSize =
[&](const auto fabricSwitchId, const auto reachabilityGroupListSize) {
auto matcher = HwSwitchMatcher(std::unordered_set<SwitchID>(
{static_cast<SwitchID>(fabricSwitchId)}));
if (new_->getSwitchSettings()
->getNodeIf(matcher.matcherString())
->getReachabilityGroupListSize() != reachabilityGroupListSize) {
auto newMultiSwitchSettings = new_->getSwitchSettings()->clone();
auto newSwitchSettings =
newMultiSwitchSettings->getNodeIf(matcher.matcherString())
->clone();
newSwitchSettings->setReachabilityGroupListSize(
reachabilityGroupListSize);
newMultiSwitchSettings->updateNode(
matcher.matcherString(), newSwitchSettings);
new_->resetSwitchSettings(newMultiSwitchSettings);
}
};
auto updateReachabilityGroups = [&](const auto fabricSwitchId,
const auto&
destinationId2ReachabilityGroup) {
std::vector<int> reachabilityGroups;
for (const auto& [_, groupId] : destinationId2ReachabilityGroup) {
reachabilityGroups.push_back(groupId);
}

auto matcher = HwSwitchMatcher(
std::unordered_set<SwitchID>({static_cast<SwitchID>(fabricSwitchId)}));
auto currReachabilityGroups = new_->getSwitchSettings()
->getNodeIf(matcher.matcherString())
->getReachabilityGroups();
if (currReachabilityGroups != reachabilityGroups) {
auto newMultiSwitchSettings = new_->getSwitchSettings()->clone();
auto newSwitchSettings =
newMultiSwitchSettings->getNodeIf(matcher.matcherString())->clone();
newSwitchSettings->setReachabilityGroups(reachabilityGroups);
newMultiSwitchSettings->updateNode(
matcher.matcherString(), newSwitchSettings);
new_->resetSwitchSettings(newMultiSwitchSettings);
}
};

bool parallelVoqLinks = haveParallelLinksToInterfaceNodes(
cfg_,
Expand Down Expand Up @@ -1320,8 +1325,7 @@ void ThriftConfigApplier::processReachabilityGroup(
newPort->setReachabilityGroupId(reachabilityGroupId);
}
}
updateReachabilityGroupListSize(
fabricSwitchId, destinationId2ReachabilityGroup.size());
updateReachabilityGroups(fabricSwitchId, destinationId2ReachabilityGroup);
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions fboss/agent/test/ReachabilityGroupTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ class ReachabilityGroupTest : public ::testing::Test {
const auto& state = sw_->getState();
for (const auto& [_, switchSettings] :
std::as_const(*state->getSwitchSettings())) {
if (expectedSize > 0) {
EXPECT_TRUE(switchSettings->getReachabilityGroupListSize().has_value());
EXPECT_EQ(
switchSettings->getReachabilityGroupListSize().value(),
expectedSize);
} else {
EXPECT_FALSE(
switchSettings->getReachabilityGroupListSize().has_value());
}
EXPECT_EQ(switchSettings->getReachabilityGroups().size(), expectedSize);
}
}

Expand Down

0 comments on commit fbf7ea9

Please sign in to comment.