Skip to content

Commit

Permalink
Use fabric level to determine if single stage cluster or not
Browse files Browse the repository at this point in the history
Summary: As titled. Previously we count the unique cluster ID - rather we can directly check if we have any nodes with layer 2 fabric.

Reviewed By: jasmeetbagga

Differential Revision:
D65866155

Privacy Context Container: L1125642

fbshipit-source-id: 48da484cec212b2337239469dc8fc3021aca3bb6
  • Loading branch information
Ron He authored and facebook-github-bot committed Nov 22, 2024
1 parent 601be7a commit 808901a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
11 changes: 3 additions & 8 deletions fboss/agent/ApplyThriftConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,7 @@ void ThriftConfigApplier::processReachabilityGroup(
const std::vector<SwitchID>& localFabricSwitchIds) {
std::unordered_map<std::string, std::vector<uint32_t>> switchNameToSwitchIds;

// TODO(zecheng): Update to look at DsfNode layer config once available.

// To determine if Dsf cluster is single stage:
// If there's more than one clusterIds in dsfNode map, it's in multi-stage.
std::unordered_set<int> clusterIds;
bool isSingleStageCluster = true;
for (const auto& [_, dsfNodeMap] : std::as_const(*new_->getDsfNodes())) {
for (const auto& [_, dsfNode] : std::as_const(*dsfNodeMap)) {
std::string nodeName = dsfNode->getName();
Expand All @@ -1240,12 +1236,11 @@ void ThriftConfigApplier::processReachabilityGroup(
} else {
switchNameToSwitchIds[nodeName] = {dsfNode->getID()};
}
if (auto clusterId = dsfNode->getClusterId()) {
clusterIds.insert(*clusterId);
if (auto fabricLevel = dsfNode->getFabricLevel()) {
isSingleStageCluster &= (fabricLevel.value() < 2);
}
}
}
bool isSingleStageCluster = clusterIds.size() <= 1;

auto updateReachabilityGroupListSize =
[&](const auto fabricSwitchId, const auto reachabilityGroupListSize) {
Expand Down
19 changes: 14 additions & 5 deletions fboss/agent/test/TestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,12 @@ cfg::SwitchConfig testConfigFabricSwitch(
cfg::PortProfileID::PROFILE_25G_1_NRZ_CL74_COPPER;
cfg.ports()[p].portType() = cfg::PortType::FABRIC_PORT;
}
auto myNode =
makeDsfNodeCfg(kFabricSwitchIdBegin, cfg::DsfNodeType::FABRIC_NODE);
auto myNode = makeDsfNodeCfg(
kFabricSwitchIdBegin,
cfg::DsfNodeType::FABRIC_NODE,
std::nullopt,
cfg::AsicType::ASIC_TYPE_RAMON3,
fabricLevel);
cfg.dsfNodes()->insert({*myNode.switchId(), myNode});

auto nextFabricSwitchId = kFabricSwitchIdBegin + switchIdGap;
Expand All @@ -583,9 +587,14 @@ cfg::SwitchConfig testConfigFabricSwitch(
if (fabricLevel == 2) {
clusterId = i + 1;
remoteFabricLevel = 1;
} else if (i >= dualStageNeighborLevel2FabricNodes.value()) {
clusterId = 1;
remoteFabricLevel = 2;
} else {
if (i < dualStageNeighborLevel2FabricNodes.value()) {
// Fabric nodes
remoteFabricLevel = 2;
} else {
// Interface nodes
clusterId = 1;
}
}
}

Expand Down

0 comments on commit 808901a

Please sign in to comment.