Skip to content

[xcvrd] Replace dom_* configuration flags with XcvrdConfig resolver - #854

Open
aditya-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:aditya.xcvrdconfig
Open

[xcvrd] Replace dom_* configuration flags with XcvrdConfig resolver#854
aditya-nexthop wants to merge 2 commits into
sonic-net:masterfrom
nexthop-ai:aditya.xcvrdconfig

Conversation

@aditya-nexthop

@aditya-nexthop aditya-nexthop commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

HLD Link

Adds XcvrdConfig, which resolves dom_temperature_poll_interval and dom_update_interval from the "xcvrd" section of pmon_daemon_control.json (hwsku file takes precedence over platform file, no cross-file merge — mirrors docker_init.j2), falling back to built-in defaults (None) when unset.

DaemonXcvrd now builds self.config = XcvrdConfig() (resolved via XcvrdConfig.resolve()) instead of taking dom_temperature_poll_interval/dom_update_interval as constructor args; call sites read from self.config instead of instance attributes.

Motivation and Context

Previously, adding a new xcvrd tunable required threading a new --flag through argparse, the supervisord template, and the DaemonXcvrd constructor. Moving tunables into the per-platform pmon_daemon_control.json file (which platform owners already maintain for other daemons) means a new knob only requires a new dataclass field on XcvrdConfig — no template or constructor changes.

How Has This Been Tested?

Ran the full sonic-xcvrd pytest suite (tests/test_xcvrd_config.py, tests/test_xcvrd.py) inside the SONiC build slave container:

420 passed, 3 warnings in 10.83s
xcvrd/xcvrd_utilities/xcvrd_config.py   88 stmts, 99% coverage

New tests in tests/test_xcvrd_config.py cover: default values, platform-section overrides, partial overrides, None/0 handling, string-to-int coercion, invalid/unknown keys, hwsku-vs-platform file precedence, missing/malformed files, and end-to-end resolve().

tests/test_xcvrd.py updated to verify DaemonXcvrd wires self.config from XcvrdConfig.resolve().

Additional Information (Optional)

After this PR merges, sonic-net/sonic-buildimage#28306 removes the no longer necessary lines from the Jinja template.

Adds XcvrdConfig, which resolves dom_temperature_poll_interval and
dom_update_interval from the "xcvrd" section of pmon_daemon_control.json
(hwsku file taking precedence over platform file), falling back to
built-in defaults (None) when unset. This replaces the old --dom_* argparse
flags and threading a new command-line flag through the supervisord
template, so adding a new tunable only requires a new dataclass field.

DaemonXcvrd now builds self.config = XcvrdConfig() (or resolves it) instead
of taking dom_temperature_poll_interval/dom_update_interval constructor
args; call sites read from self.config instead.

Signed-off-by: aditya-nexthop <aditya@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

XcvrdConfig owned the whole resolution mechanism: locating
pmon_daemon_control.json, extracting the section, merging, coercing, and error
handling. None of that is xcvrd-specific, and thermalctld would have to copy it
verbatim to get the same benefit, so it moves to
sonic_py_common.pmon_daemon_config.PmonDaemonConfig. This module is left as
xcvrd's schema: the section it owns, its fields, and their specs.

Replace _FIELD_CASTERS with _FIELD_SPECS so each tunable declares a valid range
alongside its caster. Coercion alone let through values that are not valid
configuration, and the two consumers disagreed about what happened next:
DomInfoUpdateTask rejected a negative dom_update_interval and fell back to its
60s default, while DomThermalInfoUpdateTask never checked poll_interval at all.
A negative value there left the next scheduled poll permanently in the past, so
the sweep ran back-to-back with no delay: a typo like -60 produced maximum
transceiver I2C load instead of one poll per minute. Bounds are now enforced in
one place, after coercion, so the stringified form is caught too. A rejected
value keeps the built-in default and logs a warning; it never stops xcvrd from
starting. The DomInfoUpdateTask guard stays as defense-in-depth for direct
constructor callers.

Depends on the sonic-py-common change adding PmonDaemonConfig
(sonic-net/sonic-buildimage#28859), which must merge first.

Signed-off-by: aditya-nexthop <aditya@nexthop.ai>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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