Skip to content

fix: datasource initialization order in stages#6700

Merged
blackboxsw merged 1 commit intocanonical:mainfrom
holmanb:holmanb/fix-stages
Jan 31, 2026
Merged

fix: datasource initialization order in stages#6700
blackboxsw merged 1 commit intocanonical:mainfrom
holmanb:holmanb/fix-stages

Conversation

@holmanb
Copy link
Member

@holmanb holmanb commented Jan 30, 2026

Add a unit test to cover this case.

Add a unit test to cover this case.
Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

Good fix Brett. This code between stages.py and cloudinit.cmd.main is really challenging to follow and catch all cases. This fix will solve both the snap core26 issue #6699 and the MAAS-specific #6695 which both fall through the condition where no datasources were detected in init-local timeframe and cloud-init tries to reference that self.ds attribute before we've setup a discovered datasource in init-network timeframe. +1.


if hasattr(self.ds, "network_config"):
available_cfgs[NetworkConfigSource.DS] = self.ds.network_config
if self.datasource:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check will solve the source of the symptoms filed in issues #6695 and #6699 when no datasource is detected during init-local timeframe and cloud-init still calls init.apply_network_config(...) to write any networking config seen by kernel cmdline or initramfs prior to cloud-init's init-network stage running.

if hasattr(self.ds, "network_config"):
available_cfgs[NetworkConfigSource.DS] = self.ds.network_config
else:
order = sources.DataSource.network_config_sources
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good default back to common parent when no DS detected yet.

@blackboxsw
Copy link
Collaborator

While I believe this will resolve #6699 issue as well. I want to leave that one open so we can get resolution from core folks on why and what provides that config setup.

@blackboxsw blackboxsw merged commit 26c7d38 into canonical:main Jan 31, 2026
22 checks passed
drzee99 pushed a commit to drzee99/cloud-init that referenced this pull request Feb 2, 2026
holmanb added a commit that referenced this pull request Feb 5, 2026
Add a unit test to cover this case.

Fixes GH-6695
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