Skip to content

feat: support loading cdrom modules before reading blkid info#6364

Closed
smoser wants to merge 1 commit into
canonical:mainfrom
smoser:fix/load-cdrom-modules-before-blkid
Closed

feat: support loading cdrom modules before reading blkid info#6364
smoser wants to merge 1 commit into
canonical:mainfrom
smoser:fix/load-cdrom-modules-before-blkid

Conversation

@smoser
Copy link
Copy Markdown
Collaborator

@smoser smoser commented Aug 7, 2025

If scsi cdrom module is not built in, then cdrom device might not be present before blkid is run. The result would be that cdrom based datasources (ConfigDrive, NoCloud, OVF) may not be found.

Add support for local setting of modification of PROBE_CDROM_MODULES varible. Each module in this list will be modprobed and then udevadm will be settled afterwards.

Other things here:

  1. fix for probe_floppy path that would fail with unset variable.
  2. add debugts function for debug with timestamp.

--

  • I have signed the CLA: https://ubuntu.com/legal/contributors
  • I have included a comprehensive commit message using the guide below
  • I have added unit tests to cover the new behavior under tests/unittests/
    • Test files should map to source files i.e. a source file cloudinit/example.py should be tested by tests/unittests/test_example.py
    • Run unit tests with tox -e py3
  • I have kept the change small, avoiding unnecessary whitespace or non-functional changes.
  • I have added a reference to issues that this PR relates to in the PR message (Refs integration: do not LXD bind mount /etc/cloud/cloud.cfg.d #1234, Fixes integration: do not LXD bind mount /etc/cloud/cloud.cfg.d #1234)
  • I have updated the documentation with the changed behavior.
    • If the change doesn't change the user interface and is trivial, this step may be skipped.
    • Cloud-config documentation is generated from the jsonschema.
    • Generate docs with tox -e docs.

Proposed Commit Message

feat: support loading cdrom modules before reading blkid info

If scsi cdrom module is not built in, then cdrom device might
not be present before blkid is run.  The result would be that
cdrom based datasources (ConfigDrive, NoCloud, OVF) may not
be found.

Add support for local setting of modification of PROBE_CDROM_MODULES
varible.  Each module in this list will be modprobed
and then udevadm will be settled afterwards.

Other things here:
1. fix for probe_floppy path that would fail with unset variable.
2. add debugts function for debug with timestamp.

Additional Context

Test Steps

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@smoser smoser requested a review from blackboxsw August 7, 2025 19:53
If scsi cdrom module is not built in, then cdrom device might
not be present before blkid is run.  The result would be that
cdrom based datasources (ConfigDrive, NoCloud, OVF) may not
be found.

Add support for local setting of modification of PROBE_CDROM_MODULES
varible.  Each module in this list will be modprobed
and then udevadm will be settled afterwards.

Other things here:
1. fix for probe_floppy path that would fail with unset variable.
2. add debugts function for debug with timestamp.

Upstream PR canonical#6364
@smoser smoser force-pushed the fix/load-cdrom-modules-before-blkid branch 2 times, most recently from 5070e1e to aa9cca4 Compare August 7, 2025 20:19
Comment thread tools/ds-identify
STATE_FLOPPY_PROBED=""

# PROBE_CDROM_MODULES - modules will be modprobed if /dev/cdrom does not exist.
PROBE_CDROM_MODULES=""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you plan to set this environment variable?

Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious: why isn't a more standard approach such as initrd / initramfs or a kernel command line argument preferred? The proposed changes do not fit the expectations of systemd generators (see comments).

If scsi cdrom module is not built in, then cdrom device might not be present before blkid is run.

Which distro is this seen this on?

Comment thread tools/ds-identify
debugts 1 "attempting modprobe of ${PROBE_CDROM_MODULES}"
local m="" modfails=""
for m in ${PROBE_CDROM_MODULES}; do
modprobe -b "$m" >/dev/null 2>&1 || modfails="${modfails:+$modfails }$m:$?"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Systemd generators shouldn't require modifying system state.

Comment thread tools/ds-identify
# Some Linux distros/non-Linux OSes may not have udev
if command -v udevadm >/dev/null 2>&1; then
debugts 1 "udev settling for $fpath"
if ! udevadm settle "--exit-if-exists=$fpath"; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution looks incorrect. To my knowledge the kernel makes no guarantees that loading a module will cause an associated uevent to be queued before the driver is done loading. This might work sometimes, but I don't think that there are any guarantees that it will always work. Am I missing something?

Also, generators are supposed to be fast and this operation is functionally a wait.

@github-actions
Copy link
Copy Markdown

Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close.

If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon.

(If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.)

@github-actions github-actions Bot added the stale-pr Pull request is stale; will be auto-closed soon label Aug 27, 2025
@github-actions github-actions Bot closed this Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale-pr Pull request is stale; will be auto-closed soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants