Skip to content

Add platform-level fallback for buffer and QoS templates to support Generic HWSKU#4538

Open
yifei-micas wants to merge 1 commit into
sonic-net:masterfrom
yifei-micas:fix/issue-25747
Open

Add platform-level fallback for buffer and QoS templates to support Generic HWSKU#4538
yifei-micas wants to merge 1 commit into
sonic-net:masterfrom
yifei-micas:fix/issue-25747

Conversation

@yifei-micas

Copy link
Copy Markdown

Fixes #25747

What I did

Add platform-level fallback for buffer and QoS template files during config qos reload to support the Generic HWSKU initiative (HLD #2309).
Previously these files (buffers_dynamic.json.j2, buffers.json.j2, qos.json.j2) were required to exist in each HWSKU directory, causing duplication.
Now they are looked up in the following order:

  1. HWSKU directory (per‑HWSKU override)
  2. Platform directory (shared for all HWSKUs on that platform)
  3. (For qos.json.j2 only) a global template: /usr/share/sonic/templates/qos_config.j2

How I did it

  • In config/main.py, inside the reload function (which implements config qos reload):
    • Changed _, hwsku_path = device_info.get_paths_to_platform_and_hwsku_dirs() to platform_path, hwsku_path so both directories are available.
    • For dynamic buffer template: check hwsku_path/.../buffers_dynamic.json.j2; if missing, try platform_path/.../buffers_dynamic.json.j2.
    • For traditional buffer template (buffers.json.j2): same fallback logic.
    • For QoS template (qos.json.j2): check HWSKU, then platform, then the hardcoded global template path.
  • Added os.path.isfile checks before each fallback attempt.
  • Ensured existing HWSKUs with their own templates continue to work unchanged.

How to verify it

  • Remove buffers_dynamic.json.j2, buffers.json.j2, or qos.json.j2 from a HWSKU directory.
  • Run config qos reload (e.g., sudo config qos reload).
  • Verify that the command succeeds and uses the platform‑level file (or the global template for qos.json.j2 when platform file also missing).
  • Verify that HWSKUs that still have their own custom templates load the per‑HWSKU file (no regression).

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

…eneric HWSKU

Why I did it
As part of Generic HWSKU initiative (HLD sonic-net#2309), buffer and QoS templates should be shareable at platform level to reduce duplication. Previously they were required per HWSKU. This change adds fallback from HWSKU → platform → global (for qos) during .

Fixes #25747

How I did it
- Obtain both platform_path and hwsku_path in config/main.py reload()
- Add fallback logic for buffers_dynamic.json.j2, buffers.json.j2, qos.json.j2
- For qos.json.j2, add global fallback /usr/share/sonic/templates/qos_config.j2

How to verify it
- Remove template files from HWSKU dir, run , verify fallback works
- Ensure per-HWSKU overrides still work

Signed-off-by: Yifei Li <yifei@micasnetworks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Enhance buffer and QoS template to support generic HWSKU

1 participant