Skip to content

fix(ec2): ignore all-zero /sys/hypervisor/uuid - #6953

Open
Sanjays2402 wants to merge 1 commit into
canonical:mainfrom
Sanjays2402:fix/ec2-null-hypervisor-uuid
Open

fix(ec2): ignore all-zero /sys/hypervisor/uuid#6953
Sanjays2402 wants to merge 1 commit into
canonical:mainfrom
Sanjays2402:fix/ec2-null-hypervisor-uuid

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented Jul 26, 2026

Copy link
Copy Markdown

Proposed Commit Message

fix(ec2): ignore all-zero /sys/hypervisor/uuid

On a Xen dom0 /sys/hypervisor/uuid reads all zeros.
_collect_platform_data() prefers that file over DMI and an all-zero
uuid is truthy, so the DMI fallback never ran and AWS was not
identified. No IMDSv2 token was then requested, and with
HttpTokens=required the tokenless IMDSv1 requests failed for the full
240 second wait before the datasource gave up.

Treat the null uuid as absent so the DMI system-uuid is used.

Fixes GH-6937

Additional Context

Fixes #6937

Reported in #6937 with logs from an Ubuntu 24.04 EC2 instance booted as a Xen dom0.

Test Steps

tests/unittests/sources/test_ec2.py::TestIdentifyPlatform::test_identify_aws_null_hypervisor_uuid mocks the null /sys/hypervisor/uuid and an ec2... DMI system-uuid; it fails on the current code (unknown) and passes with this change (aws). The rest of tests/unittests/sources/test_ec2.py is unchanged and green (67 passed).

On a live system: boot an EC2 instance with --metadata-options HttpTokens=required as a Xen dom0, then check that cloud-init identifies the AWS datasource instead of waiting out the 240 second IMDSv1 timeout and falling back to DataSourceNone.

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>)

On a Xen dom0 /sys/hypervisor/uuid reads all zeros.
_collect_platform_data() prefers that file over DMI and an all-zero
uuid is truthy, so the DMI fallback never ran and AWS was not
identified. No IMDSv2 token was then requested, and with
HttpTokens=required the tokenless IMDSv1 requests failed for the full
240 second wait before the datasource gave up.

Treat the null uuid as absent so the DMI system-uuid is used.

Fixes canonicalGH-6937
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.

DataSourceEc2: all-zero /sys/hypervisor/uuid on Xen dom0 breaks AWS detection and IMDSv2

1 participant