canonical / canonical/cloud-init

Distro-specific network rendering

Open
#4,615 0 comments 0 reactions 0 assignees View on GitHub
bug networking
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

@bin456789 originally reported here: https://github.com/canonical/cloud-init/pull/4591#issuecomment-1816551911

###

> I found another bug in sysconfig.py
> This line should be removed.
> https://github.com/canonical/cloud-init/blob/29ed5f5b646eebfd2dafa7e036e813516a8b99bf/cloudinit/net/sysconfig.py#L440C14-L440C14

>> What's the bug?

> ```
> if subnet_type == "dhcp6" or subnet_type == "ipv6_dhcpv6-stateful":
> if flavor == "suse":
> ...
> # only if rhel AND dhcpv6 stateful
> elif flavor == "rhel" and (
> # this line should be subnet_type in ("ipv6_dhcpv6-stateful" or "dhcp6" )
> # but that's redundant so it's good to remove it
> ↓↓↓
> subnet_type == "ipv6_dhcpv6-stateful"
> ):
> iface_cfg["DHCPV6C"] = True
> iface_cfg["IPV6INIT"] = True
> iface_cfg["IPV6_AUTOCONF"] = False
> iface_cfg["IPV6_FAILURE_FATAL"] = True
> # maybe remove follow lines if these's no other flavor else than suse/rhel
> ↓↓↓
> else:
> iface_cfg["IPV6INIT"] = True
> # Configure network settings using DHCPv6
> iface_cfg["DHCPV6C"] = True
> ```

>> can you please file a separate bug and include an example output configuration that is incorrect as a result of these lines with an explanation of why it is wrong? Your initial explanation and reproducer on this PR was an example of a good bug report.

config 1:
dhcp + dhcp6
```
root@ubuntu:/# cat test.cfg
#cloud-config
datasource_list: [NoCloud]
network:
version: 1
config:
- type: physical
name: eth0
mac_address: 56:00:04:a2:c5:f0
subnets:
- type: dhcp
- type: dhcp6
```
```
root@ubuntu:/# cloud-init devel net-convert -p test.cfg -k yaml -d out -O sysconfig -D centos
Read input format 'yaml' from 'test.cfg'.
Wrote output format 'sysconfig' to 'out/'
```
```
root@ubuntu:/# cat out/etc/sysconfig/network-scripts/ifcfg-eth0
# Created by cloud-init automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
DHCPV6C=yes
HWADDR=56:00:04:a2:c5:f0
IPV6INIT=yes
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
```

config 2:
dhcp + ipv6_dhcpv6-stateful
```
root@ubuntu:/# cat test.cfg
#cloud-config
datasource_list: [NoCloud]
network:
version: 1
config:
- type: physical
name: eth0
mac_address: 56:00:04:a2:c5:f0
subnets:
- type: dhcp
- type: ipv6_dhcpv6-stateful
```
```
root@ubuntu:/# cloud-init devel net-convert -p test.cfg -k yaml -d out -O sysconfig -D centos
Read input format 'yaml' from 'test.cfg'.
Wrote output format 'sysconfig' to 'out/'
```
```
root@ubuntu:/# cat out/etc/sysconfig/network-scripts/ifcfg-eth0
# Created by cloud-init automatically, do not edit.
#
BOOTPROTO=dhcp
DEVICE=eth0
DHCPV6C=yes
HWADDR=56:00:04:a2:c5:f0
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_FAILURE_FATAL=yes
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
```

They should produce the same result, but they're not at the moment.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.