-
Notifications
You must be signed in to change notification settings - Fork 1k
[warm upgrade] Catch the regression before it becomes a problem - mine and police the protocol convergence timings #23114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vaibhavhd
merged 3 commits into
sonic-net:master
from
ravaliyel:ryeluri/control-plane-gating
Mar 23, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import os | ||
| import re | ||
| import json | ||
| import logging | ||
|
|
||
|
|
||
| def controlplane_gating(reboot_timing_dict): | ||
| THRESHOLDS_FILE = os.path.join(os.path.dirname(__file__), 'hwsku_session_thresholds.json') | ||
| LACP_WIGGLE_ROOM = 10.0 # seconds | ||
| BGP_WIGGLE_ROOM = 10.0 # seconds | ||
|
|
||
| def _get_float(d, key): | ||
| val = d.get(key) | ||
| try: | ||
| return float(val) if val is not None and str(val).strip() != "" else None | ||
| except (ValueError, TypeError): | ||
| return None | ||
|
|
||
| def _extract_version(val): | ||
| m = re.search(r"(\d{6})", str(val)) | ||
| return m.group(1) if m else None | ||
|
|
||
| hwsku = reboot_timing_dict.get("HwSku") | ||
|
|
||
| try: | ||
| with open(THRESHOLDS_FILE, 'r') as f: | ||
| thresholds = json.load(f) | ||
| except Exception: | ||
| thresholds = {} | ||
|
|
||
| if hwsku not in thresholds: | ||
| logging.warning( | ||
| "HwSku=%s not found in thresholds file. Skipping controlplane gating.", | ||
| hwsku | ||
| ) | ||
| return [] | ||
|
|
||
| lacp_val = _get_float(reboot_timing_dict, "lacp_session_max_wait") | ||
| bgp_val = _get_float(reboot_timing_dict, "bgp") | ||
| base_version = _extract_version(reboot_timing_dict.get("BaseImage")) | ||
| target_version = _extract_version(reboot_timing_dict.get("TargetImage")) | ||
|
|
||
| try: | ||
| lacp_avg = float(thresholds[hwsku][base_version][target_version]["LACP"]["AVG"]) | ||
| except Exception: | ||
| lacp_avg = None | ||
| try: | ||
| bgp_avg = float(thresholds[hwsku][base_version][target_version]["BGP"]["AVG"]) | ||
| except Exception: | ||
| bgp_avg = None | ||
|
|
||
| if lacp_avg is None or bgp_avg is None: | ||
| logging.warning( | ||
| "No thresholds found for HwSku=%s, BaseImage=%s, TargetImage=%s. " | ||
| "Skipping controlplane gating.", hwsku, base_version, target_version | ||
| ) | ||
| return [] | ||
|
|
||
| checks = [ | ||
| ("LACP", lacp_val, lacp_avg, LACP_WIGGLE_ROOM), | ||
| ("BGP", bgp_val, bgp_avg, BGP_WIGGLE_ROOM), | ||
| ] | ||
| gating_failures = [] | ||
| for label, val, avg, wiggle in checks: | ||
| if val is not None and avg is not None and val > (avg + wiggle): | ||
| gating_failures.append( | ||
| f"{label} session recovery {val:.2f}s exceeded allowed threshold " | ||
| f"(AVG + wiggle room): {avg:.2f}s + {wiggle:.2f}s " | ||
| f"for {hwsku} {base_version}->{target_version}" | ||
| ) | ||
| logging.info("Gating failure: %s", gating_failures[-1]) | ||
| return gating_failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "Example-HwSKU-Model-A": { | ||
| "202405": { | ||
| "202411": { | ||
| "LACP": {"AVG": 210.0, "P95": 225.0, "MAX": 240.0}, | ||
| "BGP": {"AVG": 205.0, "P95": 220.0, "MAX": 235.0} | ||
| } | ||
| }, | ||
| "202411": { | ||
| "202505": { | ||
| "LACP": {"AVG": 215.0, "P95": 230.0, "MAX": 245.0}, | ||
| "BGP": {"AVG": 208.0, "P95": 222.0, "MAX": 238.0} | ||
| } | ||
| } | ||
| }, | ||
| "Example-HwSKU-Model-B": { | ||
| "202405": { | ||
| "202411": { | ||
| "LACP": {"AVG": 200.0, "P95": 218.0, "MAX": 232.0}, | ||
| "BGP": {"AVG": 203.0, "P95": 215.0, "MAX": 228.0} | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.