Skip to content

Add pmon configuration resolution HLD - #2362

Open
aditya-nexthop wants to merge 3 commits into
sonic-net:masterfrom
nexthop-ai:aditya.XcvrdConfigHld
Open

Add pmon configuration resolution HLD#2362
aditya-nexthop wants to merge 3 commits into
sonic-net:masterfrom
nexthop-ai:aditya.XcvrdConfigHld

Conversation

@aditya-nexthop

@aditya-nexthop aditya-nexthop commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Add the High Level Design for how pmon daemons resolve their runtime tunables from the per-platform pmon_daemon_control.json, replacing the per-tunable command-line-flag mechanism.

Today a tunable is plumbed end-to-end as a flag: the platform sets it in pmon_daemon_control.json, sonic-cfggen loads that file while rendering docker-pmon.supervisord.conf.j2, the template flattens it into --flag value, argparse re-parses it, and the daemon constructor grows a parameter. Adding one knob means editing four places, and it has to be redone per daemon — thermalctld carries five tunables this way today, xcvrd two.

The design defines a shared PmonDaemonConfig resolver in sonic_py_common that owns everything not specific to a daemon: locating the file (hwsku over platform, mirroring docker_init.j2), extracting the daemon's section, layering it over the built-in defaults, coercing types, validating ranges, and degrading to defaults on any error. A daemon adopts it by declaring a dataclass subclass with a section name and one field per tunable. Adoption is per-daemon and independent, so a daemon that has not migrated is unaffected. xcvrd is the first adopter; thermalctld is written out as a worked example.

Adding a tunable becomes one field plus one FieldSpec entry, and changing a value only requires restarting the daemon rather than having pmon regenerate the whole supervisord template.

Also covered:

  • Validation. Ranges are enforced after type coercion, with a documented type, valid range, default, and boundary semantics per tunable. Coercion alone is not validation: a negative interval coerces to a perfectly good int but is not a valid cadence, and consumers today disagree about what happens next. An out-of-range value keeps the built-in default and logs a warning — never fatal, so a bad tunable cannot keep a daemon down.
  • Where the shared resolver lives. sonic_py_common is already a universal dependency of every pmon daemon. Alternatives considered and rejected: keeping the resolver private to xcvrd, a new shared wheel in sonic-platform-daemons, folding it into DaemonBase, and sourcing tunables from Config DB.
  • Top-level keys vs the daemon section (§9.3). Top-level skip_* / delay_* / capability keys are pmon orchestration settings consumed by the supervisord template; the nested "<daemon>" object is the daemon's own runtime config. skip_xcvrd and delay_xcvrd gate process startup and can never move daemon-side; the two mgr capability flags could, and are deliberately left alone because migrating them relocates a key platforms already set.
  • Warmboot/fastboot impact, memory, restrictions, unit and system test plans, and open items.

The doc lives at doc/pmon/pmon_daemon_config_hld.md and is linked from sonic_docs_toc.md under the pmon section, matching its pmon-wide scope.

Revision history: v0.1 initial; v0.2 generalizes the resolver to PmonDaemonConfig and adds per-field range validation, following review feedback.

Associated code PRs to be merged in order:
sonic-net/sonic-buildimage#28859
sonic-net/sonic-platform-daemons#854
sonic-net/sonic-buildimage#28306

Add the High Level Design describing how xcvrd resolves its runtime
tunables via a single XcvrdConfig object that reads the xcvrd section of
pmon_daemon_control.json directly, replacing the per-tunable
command-line-flag mechanism. Adding a new tunable becomes a one-field
change to XcvrdConfig, and changing a flag at runtime only requires
restarting xcvrd rather than having pmon regenerate the whole
supervisord template.

Link the new HLD from sonic_docs_toc.md under the xrcvd section.

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@aditya-nexthop

Copy link
Copy Markdown
Contributor Author

@prgeor

moshemos
moshemos previously approved these changes Jul 14, 2026
@Junchao-Mellanox

Copy link
Copy Markdown
Contributor

Hi @aditya-nexthop , it is a good idea to simplify the flow of adding parameters to xcvrd. Based on your proposal, I think we could do it more generic. How about changing XcvrdConfig to PmonDaemonConfig? Other daemons like thermalctld, psud could also be beneficial from this new desing.

@prgeor

prgeor commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Hi @aditya-nexthop , it is a good idea to simplify the flow of adding parameters to xcvrd. Based on your proposal, I think we could do it more generic. How about changing XcvrdConfig to PmonDaemonConfig? Other daemons like thermalctld, psud could also be beneficial from this new desing.

@Junchao-Mellanox I have requested @aditya-nexthop for a community review

Comment thread doc/xrcvd/xcvrd_config_hld.md Outdated
…nges

Restructure the design around a shared PmonDaemonConfig base in sonic_py_common
- the one library every pmon daemon already depends on - with per-daemon
subclasses declaring a section name and their fields. The resolution mechanism
is not xcvrd-specific: thermalctld already hand-plumbs five tunables through the
same template -> argparse -> constructor path. xcvrd is the first adopter, other
daemons migrate in their own changes, and thermalctld is written out as a worked
example. Record why sonic_py_common beats an xcvrd-private resolver, a new
shared wheel, or folding into DaemonBase.

Add a FieldSpec validation layer that enforces a declared range after type
coercion, plus a per-field table of types, ranges, and defaults. Coercion alone
lets through values that are not valid configuration, and the consumers disagree
today: DomInfoUpdateTask rejects a negative dom_update_interval, while
DomThermalInfoUpdateTask never checks poll_interval, so a negative value leaves
the next scheduled poll permanently in the past and the sweep runs back-to-back.
Out-of-range values keep the built-in default and log; never fatal. Fields that
are genuinely unbounded must say so explicitly.

Add section 9.3 stating the boundary the platform files already follow but never
documented: top-level skip_/delay_/capability keys are pmon orchestration
settings consumed by the supervisord template, while the nested "<daemon>"
object is the daemon's own runtime config. skip_xcvrd and delay_xcvrd can never
move daemon-side; the two mgr capability flags could, and are left alone because
migrating them relocates a key platforms already set.

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

The design now defines a shared PmonDaemonConfig in sonic_py_common with xcvrd
as its first adopter and thermalctld as a worked example, so doc/xrcvd hid it
from the maintainers it is aimed at. doc/pmon already holds the pmon-wide
designs. Rename to match the component and module name.

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@aditya-nexthop

Copy link
Copy Markdown
Contributor Author

I moved the file to the pmon directory as we have increased the scope.

@aditya-nexthop aditya-nexthop changed the title Add xcvrd configuration resolution HLD Add pmon configuration resolution HLD Aug 6, 2026
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.

6 participants