Skip to content

Commit 352968a

Browse files
Re-sync with internal repository
The internal and external repositories are out of sync. This Pull Request attempts to brings them back in sync by patching the GitHub repository. Please carefully review this patch. You must disable ShipIt for your project in order to merge this pull request. DO NOT IMPORT this pull request. Instead, merge it directly on GitHub using the MERGE BUTTON. Re-enable ShipIt after merging. fbshipit-source-id: 29a7b631e2673f536e3daf48fb6fa62d0651349a
1 parent 65f327d commit 352968a

54 files changed

Lines changed: 8743 additions & 412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ are expressed as structured configurations rather than imperative scripts.
1111

1212
See the [documentation](https://github.com/facebook/DNE-Taac) for setup instructions.
1313

14+
## Running TAAC modules under OSS
15+
16+
TAAC's Python modules (e.g. `taac.libs.taac_runner`) include Meta-internal imports that aren't shipped in this slice. Set `TAAC_OSS=1` so the imports take their OSS branch:
17+
18+
```bash
19+
export TAAC_OSS=1
20+
python3 -c 'import taac.libs.taac_runner; print("ok")'
21+
```
22+
23+
Some runtime functionality is stubbed in OSS mode (NDS drainer, COOP patcher, ValidationStep, AristaSSHHelper, etc.) and will raise `NotImplementedError` if invoked on a code path that requires it. Imports succeed; trying to actually use those features fails.
24+
1425
## License
1526

1627
This project is licensed under the Apache License 2.0 — see the [LICENSE](LICENSE) file for details.

taac/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ class BgpPlusPlusProfile(Enum):
362362
RDMA_PORT: str = "4791"
363363
DHCPV6_MULTICAST_ADDR: str = "fe80::a00:27ff:fefe:8f95"
364364
DHCPV6_SERVER_MULTICAST_ADDR: str = "ff02::1:2"
365+
# Ethernet multicast MAC for DHCPv6 servers (ff02::1:2) per RFC 2464 §7
366+
# (33:33: prefix + low-32-bits of IPv6 multicast addr). Used as Ethernet
367+
# DMAC when the IPv6 DIP is DHCPV6_SERVER_MULTICAST_ADDR; sending a
368+
# multicast IPv6 destination wrapped in a unicast Ethernet DMAC produces
369+
# a malformed frame at L2.
370+
DHCPV6_SERVER_MULTICAST_MAC: str = "33:33:00:01:00:02"
365371
DHCPV6_SERVER_PORT: str = "547"
366372
DHCPV6_RELAY_PORT: str = "546"
367373
DHCPV4_BROADCAST_ADDR: str = "255.255.255.255"
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22
# pyre-unsafe
3+
import os
34
import typing as t
45

5-
from taac.ai_bb.dsf.dsf_test_handler import DsfTestHandler
66
from taac.custom_test_handlers.base_custom_test_handler import (
77
BaseCustomTestHandler,
88
)
99
from taac.custom_test_handlers.patcher_cleanup_handler import (
1010
PatcherCleanupHandler,
1111
)
1212

13+
TAAC_OSS = os.environ.get("TAAC_OSS", "").lower() in ("1", "true", "yes")
1314

1415
# pyre-ignore
1516
CUSTOM_TEST_HANDLERS: t.List[BaseCustomTestHandler] = [
16-
DsfTestHandler,
1717
PatcherCleanupHandler,
1818
]
19+
20+
if not TAAC_OSS:
21+
# DsfTestHandler lives in the Meta-internal taac.ai_bb subpackage which
22+
# isn't shipped in the OSS slice.
23+
from taac.ai_bb.dsf.dsf_test_handler import DsfTestHandler
24+
25+
# pyre-ignore[6]: registry holds handler classes, annotated as instances.
26+
CUSTOM_TEST_HANDLERS.append(DsfTestHandler)

taac/driver/fboss_switch.py

Lines changed: 89 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,81 @@
3636
# =============================================================================
3737
# Third-party (PyPI / OSS-compatible)
3838
# =============================================================================
39-
import bunch
39+
if t.TYPE_CHECKING:
40+
# Keep Pyre on the real `bunch` types; the runtime fallback below would
41+
# otherwise widen `bunch.Bunch` to `Bunch | SimpleNamespace`, which breaks
42+
# callers (and the `import *` re-export in dne/drivers/fboss_switch.py).
43+
import bunch
44+
else:
45+
try:
46+
import bunch
47+
except ImportError:
48+
# bunch is abandoned (last updated 2011), use types.SimpleNamespace as replacement
49+
from types import SimpleNamespace as Bunch
50+
51+
class BunchModule:
52+
"""Compatibility wrapper for abandoned bunch module"""
53+
54+
Bunch = Bunch
55+
56+
bunch = BunchModule()
4057

4158
# =============================================================================
4259
# FBOSS thrift types & clients (already OSS'd)
4360
# =============================================================================
4461
import neteng.fboss.bgp_thrift.types as fboss_bgp_thrift_types
4562
import neteng.fboss.fsdb.types as fsdb_types
4663
import pexpect
47-
from fboss.fb_thrift_clients import FbossAgentClient, FbossAgentClientWrapper
64+
65+
TAAC_OSS = os.environ.get("TAAC_OSS", "").lower() in ("1", "true", "yes")
66+
67+
# `t.TYPE_CHECKING or` keeps the real FbossAgentClient visible to Pyre so
68+
# `with self._get_fboss_agent_client() as client:` type-checks as a context
69+
# manager (the OSS stub below is a runtime-only fallback).
70+
if t.TYPE_CHECKING or not TAAC_OSS:
71+
from fboss.fb_thrift_clients import FbossAgentClient, FbossAgentClientWrapper
72+
else:
73+
# OSS stubs - fboss.fb_thrift_clients is Meta-internal
74+
# Use FbossCtrl from OSS bindings as base
75+
class FbossAgentClient: # type: ignore
76+
"""OSS stub - using FbossCtrl from neteng.fboss.ctrl.clients"""
77+
78+
def __init__(self, hostname: str, port: int = 5909, timeout: int = 30):
79+
from neteng.fboss.ctrl.clients import FbossCtrl
80+
81+
self.hostname = hostname
82+
self.port = port
83+
self.timeout = timeout
84+
self._client = FbossCtrl
85+
86+
class FbossAgentClientWrapper: # type: ignore
87+
"""OSS stub - context manager wrapper for FbossCtrl"""
88+
89+
def __init__(self, host: str, timeout: int = 30):
90+
self.host = host
91+
self.timeout = timeout
92+
self._client = None
93+
94+
def __enter__(self):
95+
from neteng.fboss.ctrl.clients import FbossCtrl
96+
97+
# In OSS, return the client class - actual instantiation happens elsewhere
98+
return FbossCtrl
99+
100+
def __exit__(self, *args):
101+
pass
102+
103+
48104
from neteng.fboss.bgp_attr.types import TBgpAfi, TIpPrefix
49105
from neteng.fboss.bgp_route_types.types import TBgpPath, TRibEntry
50106
from neteng.fboss.bgp_thrift.clients import TBgpService
51-
from neteng.fboss.bgp_thrift.types import TBgpPeerState, TBgpSession, TOriginatedRoute
107+
from neteng.fboss.bgp_thrift.types import (
108+
TBgpPeerState,
109+
TBgpSession,
110+
TGetUpdateGroupInfoRequest,
111+
TGetUpdateGroupInfoResponse,
112+
TOriginatedRoute,
113+
)
52114
from neteng.fboss.ctrl.clients import FbossCtrl
53115
from neteng.fboss.ctrl.types import (
54116
AggregatePortThrift,
@@ -155,8 +217,6 @@
155217
to_fb_uqdn,
156218
)
157219

158-
TAAC_OSS = os.environ.get("TAAC_OSS", "").lower() in ("1", "true", "yes")
159-
160220
if not TAAC_OSS:
161221
from openr.py.openr.cli.utils.commands import OpenrCtrlCmd
162222
from openr.py.openr.clients.openr_client import get_openr_ctrl_cpp_client
@@ -1802,6 +1862,14 @@ async def async_get_bgp_sessions(self) -> Sequence[TBgpSession]:
18021862
async with await self._get_bgp_client() as bgp_client:
18031863
return await bgp_client.getBgpSessions()
18041864

1865+
async def async_get_update_group_info(
1866+
self, group_id: t.Optional[int] = None
1867+
) -> TGetUpdateGroupInfoResponse:
1868+
"""Get BGP++ Update Group info (the API behind ``show bgpcpp update-group``)."""
1869+
request = TGetUpdateGroupInfoRequest(group_id=group_id)
1870+
async with await self._get_bgp_client() as bgp_client:
1871+
return await bgp_client.getUpdateGroupInfo(request)
1872+
18051873
@async_retryable(
18061874
retries=30,
18071875
sleep_time=2,
@@ -2508,11 +2576,15 @@ def _bounce_specific_interface_using_wedge_qsfp_util(
25082576
return True
25092577

25102578
async def async_do_rapid_interface_flaps(
2511-
self, interface_names: Tuple[str], interval_to_link_up: int, total_flaps: int
2579+
self,
2580+
interface_names: Tuple[str],
2581+
interval_to_link_up: int,
2582+
total_flaps: int,
2583+
down_time_sec: float = 0.1,
25122584
) -> None:
25132585
for _ in range(total_flaps):
25142586
interface_names_str = " ".join(interface_names)
2515-
flap_command = f"wedge_qsfp_util -tx_disable {interface_names_str} && sleep 0.1 && wedge_qsfp_util -tx_enable {interface_names_str}"
2587+
flap_command = f"wedge_qsfp_util -tx_disable {interface_names_str} && sleep {down_time_sec} && wedge_qsfp_util -tx_enable {interface_names_str}"
25162588
await self.async_run_cmd_on_shell(flap_command)
25172589
await asyncio.sleep(interval_to_link_up)
25182590
self.logger.info("Flap command executed")
@@ -4384,12 +4456,16 @@ async def async_get_bgp_drain_state(self) -> t.Dict[str, t.Any]:
43844456
async with await self._get_bgp_client() as bgp_client:
43854457
drain_state = await bgp_client.getDrainState()
43864458
return {
4387-
"drain_state": drain_state.drain_state.name
4388-
if drain_state.drain_state is not None
4389-
else "UNKNOWN",
4390-
"drained_interfaces": list(drain_state.drained_interfaces)
4391-
if drain_state.drained_interfaces
4392-
else [],
4459+
"drain_state": (
4460+
drain_state.drain_state.name
4461+
if drain_state.drain_state is not None
4462+
else "UNKNOWN"
4463+
),
4464+
"drained_interfaces": (
4465+
list(drain_state.drained_interfaces)
4466+
if drain_state.drained_interfaces
4467+
else []
4468+
),
43934469
}
43944470

43954471
async def async_get_all_interface_names(

taac/health_checks/all_health_checks.py

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import os
44
import typing as t
55

6+
TAAC_OSS = os.environ.get("TAAC_OSS", "").lower() in ("1", "true", "yes")
7+
68
from taac.health_checks.abstract_health_check import (
79
AbstractDeviceHealthCheck,
810
AbstractIxiaHealthCheck,
@@ -42,12 +44,12 @@
4244
from taac.health_checks.device_health_checks.bgp_tcpdump_health_check import (
4345
BgpTcpdumpHealthCheck,
4446
)
47+
from taac.health_checks.device_health_checks.bgp_update_group_health_check import (
48+
BgpUpdateGroupHealthCheck,
49+
)
4550
from taac.health_checks.device_health_checks.clear_counters_health_check import (
4651
ClearCountersHealthCheck,
4752
)
48-
from taac.health_checks.device_health_checks.cpu_utilization_health_check import (
49-
CpuUtilizationHealthCheck,
50-
)
5153
from taac.health_checks.device_health_checks.device_core_dumps_health_check import (
5254
DeviceCoreDumpsHealthCheck,
5355
)
@@ -63,9 +65,6 @@
6365
from taac.health_checks.device_health_checks.file_exists_health_check import (
6466
FileExistsHealthCheck,
6567
)
66-
from taac.health_checks.device_health_checks.generic_ods_health_check import (
67-
GenericOdsHealthCheck,
68-
)
6968
from taac.health_checks.device_health_checks.hardware_capacity_health_check import (
7069
HardwareCapacityHealthCheck,
7170
)
@@ -78,9 +77,6 @@
7877
from taac.health_checks.device_health_checks.log_parsing_health_check import (
7978
LogParsingHealthCheck,
8079
)
81-
from taac.health_checks.device_health_checks.memory_utilization_health_check import (
82-
MemoryUtilizationHealthCheck,
83-
)
8480
from taac.health_checks.device_health_checks.oomd_kill_health_check import (
8581
OomdKillHealthCheck,
8682
)
@@ -132,15 +128,6 @@
132128
from taac.health_checks.device_health_checks.systemctl_active_state_health_check import (
133129
SystemctlActiveStateHealthCheck,
134130
)
135-
from taac.health_checks.device_health_checks.tm_reconciliation_firing_health_check import (
136-
TmReconciliationFiringHealthCheck,
137-
)
138-
from taac.health_checks.device_health_checks.ucmp_traffic_distribution_health_check import (
139-
UcmpTrafficDistributionHealthCheck,
140-
)
141-
from taac.health_checks.device_health_checks.unclean_exit_health_check import (
142-
UncleanExitHealthCheck,
143-
)
144131
from taac.health_checks.device_health_checks.wedge_agent_configured_health_check import (
145132
WedgeAgentConfiguredHealthCheck,
146133
)
@@ -156,12 +143,6 @@
156143
from taac.health_checks.dsf_health_checks.dsf_fsdb_subscriber_timestamp_health_check import (
157144
DsfFsdbSubscriberTimestampHealthCheck,
158145
)
159-
from taac.health_checks.dsf_health_checks.dsf_pfc_health_check import (
160-
DsfPfcHealthCheck,
161-
)
162-
from taac.health_checks.dsf_health_checks.dsf_traffic_rebalance_health_check import (
163-
DsfTrafficRebalanceHealthCheck,
164-
)
165146
from taac.health_checks.ixia_health_checks.ixia_packet_loss_health_check import (
166147
IxiaPacketLossHealthCheck,
167148
)
@@ -209,8 +190,6 @@
209190
)
210191
from taac.health_check.health_check import types as hc_types
211192

212-
TAAC_OSS = os.environ.get("TAAC_OSS", "").lower() in ("1", "true", "yes")
213-
214193
HealthCheck = t.Union[
215194
t.Type[AbstractIxiaHealthCheck],
216195
t.Type[AbstractDeviceHealthCheck],
@@ -223,32 +202,33 @@
223202
DrainStateHealthCheck,
224203
DsfDrainStateHealthCheck,
225204
DsfFabricReachabilityHealthCheck,
226-
DsfTrafficRebalanceHealthCheck,
205+
# DsfTrafficRebalanceHealthCheck, # neteng.test_infra.dne.taac dep, excluded in OSS
227206
DsfFsdbSessionHealthCheck,
228207
DsfFsdbSubscriberTimestampHealthCheck,
229208
NdpHealthCheck,
230209
IxiaPortStatsHealthCheck,
231210
SystemctlActiveStateHealthCheck,
232211
WedgeAgentConfiguredHealthCheck,
233-
DsfPfcHealthCheck,
212+
# DsfPfcHealthCheck, # neteng.test_infra.dne.taac dep, excluded in OSS
234213
CoreDumpsHealthCheck,
235214
PortStateHealthCheck,
236215
LldpHealthCheck,
237216
IxiaTrafficRateHealthCheck,
238217
PfcWdHealthCheck,
239218
CpuQueueHealthCheck,
240-
UncleanExitHealthCheck,
241-
CpuUtilizationHealthCheck,
242-
MemoryUtilizationHealthCheck,
219+
# UncleanExitHealthCheck, # ODS-dependent (taac.internal), excluded in OSS
220+
# CpuUtilizationHealthCheck, # ODS-dependent (taac.internal), excluded in OSS
221+
# MemoryUtilizationHealthCheck, # ODS-dependent (taac.internal), excluded in OSS
243222
BgpSessionEstablishedHealthCheck,
244223
BgpConvergenceHealthCheck,
245224
BgpGracefulRestartHealthCheck,
225+
BgpUpdateGroupHealthCheck,
246226
HardwareCapacityHealthCheck,
247227
BgpStaleRouteHealthCheck,
248228
BgpNonBestRouteHealthCheck,
249229
BgpTcpdumpHealthCheck,
250230
L2EntryThresholdHealthCheck,
251-
GenericOdsHealthCheck,
231+
# GenericOdsHealthCheck, # ODS-dependent (taac.internal), excluded in OSS
252232
OomdKillHealthCheck,
253233
EcmpGroupAndMemberCountHealthCheck,
254234
DeviceCoreDumpsHealthCheck,
@@ -268,7 +248,7 @@
268248
BgpFibProgrammingCheck,
269249
PortSpeedHealthCheck,
270250
PortSpeedSnapshotHealthCheck,
271-
UcmpTrafficDistributionHealthCheck,
251+
# UcmpTrafficDistributionHealthCheck, # ODS-dependent (taac.internal), excluded in OSS
272252
BgpRouteCountVerificationHealthCheck,
273253
BgpMultipathNextHopCountHealthCheck,
274254
RouteConvergenceTimeHealthCheck,
@@ -282,7 +262,7 @@
282262
OpenrKvstoreConsistencyHealthCheck,
283263
AristaFbossNextHopValidityHealthCheck,
284264
PortChannelExpectedStateHealthCheck,
285-
TmReconciliationFiringHealthCheck,
265+
# TmReconciliationFiringHealthCheck, # ODS-dependent (taac.internal), excluded in OSS
286266
TmKernelStateSnapshotHealthCheck,
287267
]
288268

0 commit comments

Comments
 (0)