Skip to content

Commit

Permalink
bgp-monitor: Do not issue global count gets if vrf flag set
Browse files Browse the repository at this point in the history
Currently when the vrf flag is set, we get the global counts and the
individual vrf counts. This causes changes to the number of peers
to be counted twice, once in the global counts, and again for the
individual vrf.
To avoid this, do not issue gets to the global counts path when vrf flag
is set. The counts will be on a per-vrf basis in that case

Fixes=Bug839875

Change-Id: Iada53e3744d515835c5b156417a6465d305dd513
  • Loading branch information
cianmcgrath committed Jul 26, 2023
1 parent 0128339 commit 773a7c7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
26 changes: 17 additions & 9 deletions bgp-monitor-action-pack/bgp-monitor/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ def IsStatsDiffExpected(prevStats, currentStats, expectedDiff: int):
]

prevBGPStats = {}
# Do a point in time get to get counts from before the CC
for batch in client.get(query, start=ccStart, end=ccStart):
extractBGPStats(batch, prevBGPStats)
# Get the vrf counts if parameter set
if useVrfCounts:
# The basic query is the global count (the sum of all vrf counts). To avoid double-counting
# changes (changes in vrf A will reflect in the global counts and be counted as a change of 2),
# do not include these if the vrfs flag has been passed
if not useVrfCounts:
# Do a point in time get to get counts from before the CC
for batch in client.get(query, start=ccStart, end=ccStart):
extractBGPStats(batch, prevBGPStats)
else:
# Get the vrf counts if parameter set
for batch in client.get(vrfQuery, start=ccStart, end=ccStart):
extractBGPStats(batch, prevBGPStats, useVrfCounts)

Expand All @@ -81,10 +85,14 @@ def IsStatsDiffExpected(prevStats, currentStats, expectedDiff: int):

# Get current bgp stats counts
currBGPStats = {}
for batch in client.get(query):
extractBGPStats(batch, currBGPStats)
# Get the vrf counts if parameter set
if useVrfCounts:
# The basic query is the global count (the sum of all vrf counts). To avoid double-counting
# changes (changes in vrf A will reflect in the global counts and be counted as a change of 2),
# do not include these if the vrfs flag has been passed
if not useVrfCounts:
for batch in client.get(query):
extractBGPStats(batch, currBGPStats)
else:
# Get the vrf counts if parameter set
for batch in client.get(vrfQuery):
extractBGPStats(batch, currBGPStats, useVrfCounts)

Expand Down
2 changes: 1 addition & 1 deletion bgp-monitor-action-pack/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: PACKAGE
version: 1.3.1
version: 1.3.2
name: bgp-monitor Action package
description: Action package containing a script that checks BGP stats are stable across a Change Control
26 changes: 17 additions & 9 deletions bgp-monitor-per-stat-action-pack/bgp-monitor-per-stat/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,15 @@ def computeActualDiff(prevStats, currentStats, useVrfCounts) -> dict:
]

prevBGPStats = {}
# Do a point in time get to get counts from before the CC
for batch in client.get(query, start=ccStart, end=ccStart):
extractBGPStats(batch, prevBGPStats)
# Get the vrf counts if parameter set
if useVrfCounts:
# The basic query is the global count (the sum of all vrf counts). To avoid double-counting
# changes (changes in vrf A will reflect in the global counts and be counted as a change of 2),
# do not include these if the vrfs flag has been passed
if not useVrfCounts:
# Do a point in time get to get counts from before the CC
for batch in client.get(query, start=ccStart, end=ccStart):
extractBGPStats(batch, prevBGPStats)
else:
# Get the vrf counts if parameter set
for batch in client.get(vrfQuery, start=ccStart, end=ccStart):
extractBGPStats(batch, prevBGPStats, useVrfCounts)

Expand All @@ -134,10 +138,14 @@ def computeActualDiff(prevStats, currentStats, useVrfCounts) -> dict:

# Get current bgp stats counts
currBGPStats = {}
for batch in client.get(query):
extractBGPStats(batch, currBGPStats)
# Get the vrf counts if parameter set
if useVrfCounts:
# The basic query is the global count (the sum of all vrf counts). To avoid double-counting
# changes (changes in vrf A will reflect in the global counts and be counted as a change of 2),
# do not include these if the vrfs flag has been passed
if not useVrfCounts:
for batch in client.get(query):
extractBGPStats(batch, currBGPStats)
else:
# Get the vrf counts if parameter set
for batch in client.get(vrfQuery):
extractBGPStats(batch, currBGPStats, useVrfCounts)

Expand Down
2 changes: 1 addition & 1 deletion bgp-monitor-per-stat-action-pack/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: PACKAGE
version: 1.0.0
version: 1.0.1
name: bgp-monitor-per-stat Action package
description: Action package containing a script that checks BGP statistics on a per-stat basis are stable across a Change Control

0 comments on commit 773a7c7

Please sign in to comment.