pmon: tolerate /dev reordering and bus hot-plug#27852
Open
ashwnsri wants to merge 1 commit into
Open
Conversation
Aimed at sonic-net#25142 pmon runs against a fixed --device list captured at 'docker create', which breaks in two ways: a block-device partition (e.g. sda1) named in kernel probe order can disappear after a disk reorder and fail 'docker start', and a bus node that appears after create (i2c/cpld/fpga/ipmi/uio/spidev/gpiochip/mtd) is denied and invisible to the container. Pass reorder-invariant whole disks, pre-authorize the hot-plug device classes, and keep the container's /dev in sync at runtime. The change is strictly narrower than --privileged and adds no /dev bind-mount. files/build_templates/docker_image_ctl.j2 - get_pmon_device_mounts(): skip block-device partitions and pass the reorder-invariant whole disk instead. - get_pmon_device_cgroup_rules() (new): emit 'c <major>:* rwm' for each hot-pluggable bus class so a sibling created after 'docker create' (e.g. an i2c bus behind a mux on optic insert) is already permitted. - start(): pass those rules as --device-cgroup-rule on docker create. - postStartAction(): call pmon-dev-bridge.sh resync to converge /dev. files/image_config/pmon/pmon-dev-bridge.sh (new) - Helper that mirrors allowed character bus nodes into the running pmon container(s): 'resync' converges every allowed node on start; 'event add|remove' handles a single udev hot-plug event via mknod/rm. files/image_config/udev/rules.d/99-pmon-dev-bridge.rules (new) - udev rule forwarding add/remove uevents to pmon-dev-bridge.sh so the container's device view tracks hot-plug after creation. files/build_templates/sonic_debian_extension.j2 - Install pmon-dev-bridge.sh to /usr/local/bin (mode 755) at image build time. Signed-off-by: Ashwin Srinivasan <asrinivasan@juniper.net>
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azpw retry |
Collaborator
|
Retrying failed(or canceled) jobs... |
Collaborator
|
This PR has backport request for branch(es): 202605. ---Powered by SONiC BuildBot
|
Contributor
Author
|
/azpw retry |
Collaborator
|
Retrying failed(or canceled) jobs... |
Contributor
Author
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why I did it
Aimed at #25142
pmon runs against a fixed --device list captured at 'docker create', which breaks in two ways: a block-device partition (e.g. sda1) named in kernel probe order can disappear after a disk reorder and fail 'docker start', and a bus node that appears after create (i2c/cpld/fpga/ipmi/uio/spidev/gpiochip/mtd) is denied and invisible to the container.
How I did it
Pass reorder-invariant whole disks, pre-authorize the hot-plug device classes, and keep the container's /dev in sync at runtime. The change is strictly narrower than --privileged and adds no /dev bind-mount.
files/build_templates/docker_image_ctl.j2
files/image_config/pmon/pmon-dev-bridge.sh (new)
files/image_config/udev/rules.d/99-pmon-dev-bridge.rules (new)
files/build_templates/sonic_debian_extension.j2
How to verify it
All checks are read-only except the dynamic-bridge demonstration, which is container-only
and fully reversible — the host
/devis never modified. Run on a device built from /flashed with this fix. Results: pmon-how-to-verify-it.md.
Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
Description for the changelog
pmon: tolerate /dev reordering and bus hot-plug (fixes #25142)