Skip to content

feat(datasource/aliyun): add IPv6 metaserver and DHCP strategy based on NIC metadata#6893

Open
challvy wants to merge 1 commit into
canonical:mainfrom
challvy:challvy/aliyun-ipv6
Open

feat(datasource/aliyun): add IPv6 metaserver and DHCP strategy based on NIC metadata#6893
challvy wants to merge 1 commit into
canonical:mainfrom
challvy:challvy/aliyun-ipv6

Conversation

@challvy
Copy link
Copy Markdown

@challvy challvy commented May 26, 2026

Proposed Commit Message

Fixes #6892

feat(aliyun): support IPv6 metaserver and IPv6-only NIC config

Alibaba Cloud ECS now exposes the metadata service over both IPv4
(100.100.100.200) and IPv6 (fd00:100::100:200), and supports attaching
IPv6-only ENIs that have no IPv4 address. The current AliYun datasource
only configures the IPv4 endpoint and unconditionally emits dhcp4: true
for every NIC, which prevents IPv6-only instances from reaching IMDS
and causes long boot delays on IPv6-only ENIs.

This change:

- Adds the IPv6 metadata endpoint to DataSourceAliYun.metadata_urls so
  wait_for_url tries both endpoints. IPv4 instances are unaffected.
- Makes DHCP rendering metadata-driven in
  convert_ecs_metadata_network_config():
    * dhcp6 is enabled when 'ipv6s' is present on a NIC (existing).
    * dhcp4 is disabled and dhcp4-overrides is dropped when
      'private-ipv4s' is absent on a NIC, so DHCPv4 is not attempted
      on IPv6-only NICs.
- Adds unit tests covering IPv4-only, dual-stack, and IPv6-only NIC
  scenarios under tests/unittests/sources/test_aliyun.py.

Additional Context

The IPv6 metadata endpoint and IPv6-only ENIs are documented features
of Alibaba Cloud ECS. With these changes, cloud-init can correctly
fetch metadata and render network configuration on:

NIC metadata dhcp4 dhcp6
private-ipv4s only true false
private-ipv4s + ipv6s (dual-stack) true true
ipv6s only (IPv6-only ENI) false true

Backwards compatibility:

  • Existing IPv4-only instances are unaffected — their NIC metadata
    always contains private-ipv4s, so dhcp4 stays true.
  • Adding a second URL to metadata_urls does not change behaviour
    when the IPv4 IMDS endpoint responds successfully.

Test Steps

  1. Unit tests (covers all three NIC scenarios):

    tox -e py3 -- tests/unittests/sources/test_aliyun.py
    

    Expected: all tests pass, including the new
    test_dhcp4_disabled_when_no_private_ipv4s,
    test_dhcp6_enabled_when_ipv6s_present, and
    test_ipv6_only_nic_config.

  2. Live verification on an Alibaba Cloud ECS instance:

    a. Launch a dual-stack ECS instance with both IPv4 and IPv6
    addresses, boot with this cloud-init build, and confirm:

    • /run/cloud-init/instance-data.json contains metadata fetched
      from IMDS.
    • The rendered netplan contains dhcp4: true and dhcp6: true
      for the dual-stack NIC.

    b. Attach an IPv6-only secondary ENI (no private-ipv4s in
    metadata), reboot, and confirm:

    • Boot is not delayed by DHCPv4 timeouts on the IPv6-only NIC.
    • The rendered netplan for that NIC contains dhcp4: false and
      dhcp6: true.

    c. (Optional) Disable IPv4 IMDS on a test instance and confirm
    cloud-init still reaches metadata via
    http://[fd00:100::100:200].

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 NIC metadata

- Add IPv6 metadata server address (http://[fd00:100::100:200]) as
  fallback endpoint in metadata_urls
- Disable DHCPv4 when NIC metadata lacks 'private-ipv4s' field,
  indicating no IPv4 address is assigned to the interface
- Enable DHCPv6 when 'ipv6s' field is present in NIC metadata
- Remove dhcp4-overrides when DHCPv4 is disabled for the interface
- Update unit tests to cover IPv6-only NIC, dual-stack NIC, and
  mixed multi-NIC scenarios

Signed-off-by: Cang Yu <zhengcongwei.zcw@alibaba-inc.com>
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.

[enhancement]: Support IPv6 metaserver and IPv6-only NIC for AliYun datasource

1 participant