Skip to content

feat(azure): report failure if missing customdata#6779

Open
cadejacobson wants to merge 15 commits intocanonical:mainfrom
cadejacobson:azure-missing-customdata
Open

feat(azure): report failure if missing customdata#6779
cadejacobson wants to merge 15 commits intocanonical:mainfrom
cadejacobson:azure-missing-customdata

Conversation

@cadejacobson
Copy link
Copy Markdown
Contributor

@cadejacobson cadejacobson commented Mar 2, 2026

Proposed Commit Message

feat(azure): report failure if missing customdata

Add experimental Azure datasource config key
experimental_fail_on_missing_customdata with a default of
false and use it to control reporting when OVF custom data is
missing despite IMDS indicating that hasCustomData=true.

Additional Context

Test Steps

Merge type

  • Squash merge using "Proposed Commit Message"

When ovf-env.xml is present but does not contain custom data, yet IMDS
indicates that custom data was provided to the VM (via hasCustomData),
report a provisioning failure. This helps surface cases where custom
data is silently lost during provisioning.

The behavior is gated behind a new feature flag,
EXPERIMENTAL_FAIL_ON_MISSING_CUSTOMDATA, which is disabled by default
while undergoing scale testing. Once validated, it will be renamed and
enabled for new distro releases.

Changes:
- Add EXPERIMENTAL_FAIL_ON_MISSING_CUSTOMDATA feature flag
- Add _hascustomdata_from_imds() helper to query IMDS metadata
- Report ReportableErrorImdsInvalidMetadata when custom data is
  expected but missing from OVF provisioning media
@cadejacobson cadejacobson changed the title Azure missing customdata feat(azure): report failure if missing customdata Mar 2, 2026
@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 blackboxsw, 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 blackboxsw to reopen it.)

@github-actions github-actions bot added the stale-pr Pull request is stale; will be auto-closed soon label Mar 17, 2026
@github-actions github-actions bot removed the stale-pr Pull request is stale; will be auto-closed soon label Mar 18, 2026
"apply_network_config": True, # Use IMDS published network configuration
"apply_network_config_for_secondary_ips": True, # Configure secondary ips
"experimental_skip_ready_report": False, # Skip final ready report
"experimental_fail_on_missing_customdata": False,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

try to keep in alphabetical order

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to move it above the other experimental key.

# only use userdata from imds if OVF did not provide custom data
# userdata provided by IMDS is always base64 encoded
if not userdata_raw:
# first, check to see if the OVF was supposed to provide custom
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit, I know it's inconsistent throughout, but use punctuation for multi-sentence/line comments, it just looks incomplete without that final period (and initial caps).

just my opinion anyhow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to use proper sentence structure and punctuation.

and _hascustomdata_from_imds(imds_md)
):
report_diagnostic_event(
"IMDS did not return userdata as expected",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

custom data != user data. custom data only comes from provisioning media in ovf-env.xml (or reprovisiondata endpoint for PPS re-use)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, that's my mistake. I saw the userdata_raw and included that into the log. Updated to show custom data.

assert ret
assert dsrc.userdata_raw == userdataOVF.encode("utf-8")

def test_missing_customdata_no_report_when_feature_flag_disabled(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

combine these two tests into single test with pytest.parametrize() so the differences are obvious on what happens whether flag is enabled, or not

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Combined these into one list.

class TestHasCustomDataFromImds:
"""Unit tests for the _hascustomdata_from_imds helper."""

def test_returns_true_when_present(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

all these tests can be combined into one parametrized list

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated these to be a single list.

ovf_env_xml_found: bool,
) -> None:
super().__init__(
"failed finding customData but extended.compute.hasCustomData=true"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for consistency with other errors:

Suggested change
"failed finding customData but extended.compute.hasCustomData=true"
"failure to read customData while hasCustomData=true"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@cadejacobson cadejacobson marked this pull request as ready for review March 30, 2026 22:39
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