Skip to content

Commit 42b28bb

Browse files
authored
vnet_route_check.py should not report VNET routes in APP DB but not in STATE DB and ASIC DB as mismatches (sonic-net#3991)
<!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md failure_prs.log skip_prs.log Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "closes #xxxx", "fixes #xxxx" or "resolves #xxxx" so that GitHub automatically closes the related issue when the PR is merged. If you are adding/modifying/removing any command or utility script, please also make sure to add/modify/remove any unit tests from the tests directory as appropriate. If you are modifying or removing an existing 'show', 'config' or 'sonic-clear' subcommand, or you are adding a new subcommand, please make sure you also update the Command Line Reference Guide (doc/Command-Reference.md) to reflect your changes. Please provide the following information: --> #### What I did Changed `vnet_route_check.py` so that when a VNET route is missing in STATE DB, then it is treated as an inactive route. This means that when the script is called without `-a` and `--all` options, if a route in APP DB is missing in both STATE DB and ASIC DB, it will not be reported as a mismatch. #### How I did it 1. Changed the logic in `vnet_route_check.py`. 2. Added a new test and modified an existing test in `vnet_route_check_test.py` to verify the desired behavior. #### How to verify it Run the tests in `vnet_route_check_test.py`. #### Previous command output (if the output of a command-line utility has changed) N/A #### New command output (if the output of a command-line utility has changed) N/A
1 parent f36ac95 commit 42b28bb

2 files changed

Lines changed: 30 additions & 14 deletions

File tree

scripts/vnet_route_check.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
RC_ERR = -1
5151
default_vrf_oid = ""
5252

53-
report_level = syslog.LOG_ERR
53+
report_level = syslog.LOG_WARNING
5454
write_to_syslog = True
5555

5656

@@ -374,7 +374,7 @@ def filter_active_vnet_routes(vnet_routes: dict):
374374
exists, fvs = vnet_route_tunnel_table.get(key)
375375
if not exists:
376376
print_message(syslog.LOG_WARNING, f"VNET_ROUTE_TUNNEL_TABLE|{key} does not exist in STATE DB.")
377-
active_routes.append(prefix) # Treating "prefix" as an active route
377+
# Treating "prefix" as an inactive route
378378
continue
379379
fvs_dict = dict(fvs)
380380
if fvs_dict.get("state") == "active":

tests/vnet_route_check_test.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@
567567
"12": {
568568
DESCR: "An IPv6 VNET route that is missing in STATE DB and ASIC DB",
569569
ARGS: "vnet_route_check",
570-
RET: -1,
571570
PRE: {
572571
APPL_DB: {
573572
VXLAN_TUNNEL_TABLE: {
@@ -592,17 +591,6 @@
592591
}
593592
}
594593
},
595-
RESULT: {
596-
"results": {
597-
"missed_in_asic_db_routes": {
598-
"Vnet_v6": {
599-
"routes": [
600-
"fd01:fc00::1/128"
601-
]
602-
}
603-
}
604-
}
605-
}
606594
},
607595
"13": {
608596
DESCR: "A VNET route is missing in STATE DB and another inactive route is missing in ASIC DB",
@@ -641,6 +629,34 @@
641629
}
642630
}
643631
}
632+
},
633+
"14": {
634+
DESCR: "An IPv4 VNET route that is missing in STATE DB and ASIC DB",
635+
ARGS: "vnet_route_check",
636+
PRE: {
637+
APPL_DB: {
638+
VXLAN_TUNNEL_TABLE: {
639+
"tunnel_v4": {"src_ip": "10.1.0.32"}
640+
},
641+
VNET_TABLE: {
642+
"Vnet_v4_in_v4-0": [("vxlan_tunnel", "tunnel_v4"), ("scope", "default"), ("vni", "10002"),
643+
("peer_list", "")]
644+
},
645+
VNET_ROUTE_TABLE: {
646+
"Vnet_v4_in_v4-0:150.62.191.1/32": {"endpoint": "100.251.7.1,100.251.7.2"}
647+
}
648+
},
649+
ASIC_DB: {
650+
ASIC_STATE: {
651+
"SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000d76": {
652+
"SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000d4b"
653+
},
654+
"SAI_OBJECT_TYPE_VIRTUAL_ROUTER": {
655+
"oid:0x3000000000d4b": {"": ""}
656+
},
657+
}
658+
}
659+
},
644660
}
645661
}
646662

0 commit comments

Comments
 (0)