canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
3.01k stars 887 forks source link

'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac'] #5769

Open jorhett opened 1 month ago

jorhett commented 1 month ago

Bug report

Cloud-init is failing to parse a network.v1 definition created by curtin:

2024-10-02 02:20:45,354 - schema.py[WARNING]: Invalid network-config provided:
config.1.subnets.0.type: 'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac']
config.2.subnets.0.type: 'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac']
config.3.subnets.0.type: 'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac']

@TheRealFalcon requested that I separate this issue out from #2880

Steps to reproduce the problem

This is being generated by maas, so recreation steps are overlong, but the generated config for unconfigured/unused interfaces looks like this:

- id: enp129s0f1
    mac_address: 34:80:0d:2c:a4:99
    mtu: 1500
    name: enp129s0f1
    subnets:
    - type: manual
    type: physical
  - id: enp129s0f2
    mac_address: 34:80:0d:2c:a4:9a
    mtu: 1500
    name: enp129s0f2
    subnets:
    - type: manual
    type: physical
  - id: enp129s0f3
    mac_address: 34:80:0d:2c:a4:9b
    mtu: 1500
    name: enp129s0f3
    subnets:
    - type: manual
    type: physical

This is causing the entire network configuration to fail, such that it is not applied to the interface which is configured.

As I look at this configuration, it does appear that perhaps this is a mistake by curtin? Should it perhaps be this?

    subnets:
    - type: static
      control: manual

If my judgement of this is correct, then it should perhaps be considered a documentation error for the network config v1 format as there's actually no description of the type field here: https://cloudinit.readthedocs.io/en/latest/reference/network-config-format-v1.html#subnet-ip

Environment details

#cloud-config
datasource:
  MAAS:
    metadata_url: http://maas.example.com:5248/MAAS/metadata/

cloud-init logs

cloud-init.tar.gz

aciba90 commented 1 month ago

Thanks, @jorhett, for reporting this and making cloud-init better.

I can reproduce this with cloud-init 24.4~3+really24.3.1-0ubuntu4 with:

# cat v1.yaml 
network:
  version: 1
  config:
  - id: enp129s0f1
    mac_address: 34:80:0d:2c:a4:99
    mtu: 1500
    name: enp129s0f1
    subnets:
    - type: manual
    type: physical
  - id: enp129s0f2
    mac_address: 34:80:0d:2c:a4:9a
    mtu: 1500
    name: enp129s0f2
    subnets:
    - type: manual
    type: physical
  - id: enp129s0f3
    mac_address: 34:80:0d:2c:a4:9b
    mtu: 1500
    name: enp129s0f3
    subnets:
    - type: manual
    type: physical

# cloud-init schema -t network-config -c ./v1.yaml
Invalid network-config ./v1.yaml
Error: Cloud config schema errors: network.config.0.subnets.0.type: 'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac'], network.config.1.subnets.0.type: 'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac'], network.config.2.subnets.0.type: 'manual' is not one of ['dhcp4', 'dhcp', 'dhcp6', 'static', 'static6', 'ipv6_dhcpv6-stateful', 'ipv6_dhcpv6-stateless', 'ipv6_slaac']

Error: Invalid schema: network-config

It looks like the network-config-v1 is missing this value and the docs too.

jorhett commented 1 month ago

@aciba90 fwiw I have submitted a proposed patch to MAAS that would make its output align with the documented v1 config https://bugs.launchpad.net/maas/+bug/2083540

mathmarchand commented 2 weeks ago

Hi @aciba90, I can work on this as part of my onboarding, if that's ok?

aciba90 commented 2 weeks ago

@aciba90 fwiw I have submitted a proposed patch to MAAS that would make its output align with the documented v1 config https://bugs.launchpad.net/maas/+bug/2083540

@jorhett, thanks for tackling that!

Hi @aciba90, I can work on this as part of my onboarding, if that's ok?

Please do so, thanks!

mathmarchand commented 1 week ago

@aciba90 I have posted https://github.com/canonical/cloud-init/pull/5875 to address this, let me know what you think of it.