Skip to content

[manual cherry-pick][PR:26931] Apply per-link link training via golden config, preserve deploy-time golden config across minigraph reloads - #1423

Open
frank-nexthop wants to merge 1 commit into
Azure:202512from
nexthop-ai:cherry/msft-202512/26931
Open

frank-nexthop wants to merge 1 commit into
Azure:202512from
nexthop-ai:cherry/msft-202512/26931

Conversation

@frank-nexthop

@frank-nexthop frank-nexthop commented Sep 18, 2026

Copy link
Copy Markdown

Manual cherry pick of sonic-net/sonic-mgmt#26931 (master commit 5ab9811b).

Wires per-link link training into deploy-mg via golden config, driven by the LinkTraining column of sonic_lab_links.csv, and keeps it applied across test-time minigraph reloads by re-applying just PORT.<intf>.link_training after a non-override reload. reload_minigraph_with_golden_config also restores the deploy-time golden config from .origin.backup after moving the test's temporary one aside.

Hand-resolved: the three conflicts (generate_golden_config_db.py argument_spec, config_sonic_basedon_testbed.yml, tests/conftest.py imports) were only with neighbouring master-only additions that 202512 does not carry (enabled_dpu_indices / lacp_fast_rate module params, generate_c0_golden_config_db, the is_pfcwd_hw_recovery_enabled import). The PR's own hunks are unchanged. Only DUTs whose lab links CSV rows carry a LinkTraining value render a different golden config; single-asic only, multi-asic is skipped with a warning.

…golden config across minigraph reloads (#26931)

Wire per-link link training (LT) into deploy-mg via golden config,
driven by the `LinkTraining` column of `sonic_lab_links.csv` (parsed
into `device_conn` by `conn_graph_facts`), and keep it applied across
test-time minigraph reloads by re-applying just the
`PORT.<intf>.link_training` field after a non-override reload.

DAC-cabled testbeds need link training on DUT-fanout links. Minigraph
cannot express LT, and CONFIG_DB edits are lost when sonic-mgmt reverts
config between tests. Golden config is the delivery path; this extends
it from t0-f2-only to any topology, per link from the lab links CSV.

LT injection (deploy-mg):
- `ansible/library/generate_golden_config_db.py`: new `device_conn`
  param and a topology-agnostic `apply_link_training_from_device_conn()`
  post-pass that sets `PORT.<intf>.link_training` for ports whose CSV row
  says `on`/`off`. Because `--override_config` replaces PORT wholesale,
  the pass bases PORT on the minigraph-derived table (rendered with an
  explicit `-p <port_config>`) when the topology generator emitted none.
  Blank CSV values are left untouched; multi-asic is skipped with a
  warning.
- `ansible/config_sonic_basedon_testbed.yml`: pass
  `device_conn[inventory_hostname]` into both generator invocations.

LT preservation (test time):
- `tests/common/config_reload.py`: after a non-override minigraph
  reload on a DUT, re-apply `link_training` from
  `golden_config_db.json.origin.backup` (falling back to the golden
  config path) with `sonic-db-cli hset`, only for ports present in the
  reloaded PORT table. Override (`-o`) reloads are unchanged.
- `tests/common/utilities.py`: `reload_minigraph_with_golden_config`
  restores the deploy-time golden config from `.origin.backup` after
  moving the test's temporary one aside.
- `tests/common/constants.py`, `tests/conftest.py`: share the golden
  config path constants.

Hand-resolved cherry-pick of sonic-net/sonic-mgmt#26931 onto
msft-202512. The three conflicts were with neighbouring master-only
additions this lineage does not carry (`enabled_dpu_indices` /
`lacp_fast_rate` module params, `generate_c0_golden_config_db`, the
`is_pfcwd_hw_recovery_enabled` import); the PR's own hunks are
unchanged.

(cherry picked from commit 5ab9811baeb593a78dd0acf26356e4133a702e15)
Signed-off-by: Frank Jiang <frank@nexthop.ai>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@frank-nexthop

Copy link
Copy Markdown
Author

frank-nexthop please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree

@frank-nexthop

Copy link
Copy Markdown
Author

bingwang-ms This is the cherry-pick to 202512.

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.

2 participants