Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysconfig renders vlan with TYPE=Ethernet #3225

Closed
ubuntu-server-builder opened this issue May 11, 2023 · 5 comments
Closed

sysconfig renders vlan with TYPE=Ethernet #3225

ubuntu-server-builder opened this issue May 11, 2023 · 5 comments
Labels
launchpad Migrated from Launchpad

Comments

@ubuntu-server-builder
Copy link
Collaborator

This bug was originally filed in Launchpad as LP: #1788915

Launchpad details
affected_projects = []
assignee = otubo
assignee_name = Eduardo Otubo
date_closed = 2020-11-24T17:58:36.607536+00:00
date_created = 2018-08-24T18:30:02.195683+00:00
date_fix_committed = 2020-11-05T14:14:25.931837+00:00
date_fix_released = 2020-11-24T17:58:36.607536+00:00
id = 1788915
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1788915
milestone = None
owner = dncripe
owner_name = Dan Cripe
private = False
status = fix_released
submitter = dncripe
submitter_name = Dan Cripe
tags = []
duplicates = []

Launchpad user Dan Cripe(dncripe) wrote on 2018-08-24T18:30:02.195683+00:00

Distribution: Fedora 28
Cloud provider: None
Network content of /etc/cloud/cloud.cfg.d/99_datasource.cfg (omitting users, etc.):
network:
version: 1
config:
- type: physical
name: lan1
mac_address: 0c:c4:7a:db:dc:b0
- type: vlan
name: lan1.100
vlan_link: lan1
vlan_id: 100
subnets:
- type: static
address: 192.168.0.2/24
gateway: 192.168.0.1
dns_nameservers:
- 8.8.8.8
- 8.8.4.4
- type: vlan
name: lan1.3900
vlan_link: lan1
vlan_id: 3900
subnets:
- type: static
address: 10.1.0.2/16
gateway:

I am unable to attach logs (no network connection).

$ cloud-init --version
/usr/bin/cloud-init 17.1

The sysconfig renderer leaves the configured "kind" set to the default (ethernet), which results in a config file with "TYPE=Ethernet", which is incorrect and results in the VLAN interface not being created.

$ cat ifcfg-lan1.100

Created by cloud-init on instance boot automatically, do not edit.

BOOTPROTO=none
DEFROUTE=yes
DEVICE=lan1.100
GATEWAY=192.168.0.1
IPADDR=192.168.0.2
NETMASK=255.255.255.0
ONBOOT=yes
PHYSDEV=lan1
TYPE=Ethernet
USERCTL=no
VLAN=yes

$ ifup lan1.100
Error: Connection activation failed: No suitable device found for this connection.

Removing the offending "TYPE=Ethernet" line from the config file resolves the problem (as does changing it to "TYPE=Vlan").

I altered my configuration to use version 2 of the network configuration data with identical results (problem is in renderer).

@ubuntu-server-builder ubuntu-server-builder added the launchpad Migrated from Launchpad label May 11, 2023
@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Christian Roessner(christian-roessner-net) wrote on 2020-08-26T12:42:35.622248+00:00

I also hit this bug. We have late 2020 and I wonder, why this bug still is open?

In current master branch of cloud-init in file:

net/sysconfig.py:

...
687 @classmethod
688 def _render_vlan_interfaces(cls, network_state, iface_contents, flavor):
689 vlan_filter = renderer.filter_by_type('vlan')
690 for iface in network_state.iter_interfaces(vlan_filter):
691 iface_name = iface['name']
692 iface_cfg = iface_contents[iface_name]
693 if flavor == 'suse':
694 vlan_id = iface.get('vlan_id')
695 if vlan_id:
696 iface_cfg['VLAN_ID'] = vlan_id
697 iface_cfg['ETHERDEVICE'] = iface_name[:iface_name.rfind('.')]
698 else:
699 iface_cfg['VLAN'] = True
700 iface_cfg['PHYSDEV'] = iface_name[:iface_name.rfind('.')]

701 iface_cfg.drop('TYPE')

I think, line 701 should be a fix, right?

Tested it and it works for me:

net.json:

network:
version: 1

config:
- type: physical
name: eth0
subnets:
- type: static
address: "109.230.254.227/28"
gateway: "109.230.254.225"
dns_nameservers:
- "109.230.254.226"
- type: static
address: "2a05:bec0:28:1:109:230:254:227/64"
gateway: "fe80::222:8300:b40e:7c0"
dns_nameservers: []

- type: vlan
  name: eth0.100
  vlan_link: eth0
  vlan_id: 100
  subnets:
    - type: static
      address: "192.168.0.9/24"
      dns_nameservers: []

python3 ./net_convert.py --network-data /root/vm-setup/gitlab.roessner-net.de-network.cfg --kind yaml --output-kind sysconfig -D centos -d target

cat target/etc/sysconfig/network-scripts/ifcfg-eth0.100

Created by cloud-init on instance boot automatically, do not edit.

BOOTPROTO=none
DEVICE=eth0.100
IPADDR=192.168.0.9
NETMASK=255.255.255.0
NM_CONTROLLED=no
ONBOOT=yes
PHYSDEV=eth0
USERCTL=no
VLAN=yes

This way, TYPE is removed and all works as expected.

Kind regards

Christian

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Quique Llorente(quiquell) wrote on 2020-11-05T08:38:08.543383+00:00

Same here

with version: 2

networkData
networkData: |
ethernets:
eth0:
addresses:
- fd10:0:2::2/120
dhcp4: true
gateway6: fd10:0:2::1
nameservers:
addresses:
- 10.96.0.10
search:
- default.svc.cluster.local
- svc.cluster.local
- cluster.local
version: 2
vlans:
eth0.1:
addresses:
- 1.0.0.10/24
- fe80::ce3d:82ff:fe52:24c0/64
id: 1
link: eth0
eth0.2:
addresses:
- 1.0.0.11/24
- fe80::ce3d:82ff:fe52:24c1/64
id: 2
link: eth0

ifcfg
BOOTPROTO=none
DEVICE=eth0.1
IPADDR=1.0.0.10
IPADDR6=fe80::ce3d:82ff:fe52:24c0/64
IPV6ADDR=fe80::ce3d:82ff:fe52:24c0/64
IPV6INIT=yes
NETMASK=255.255.255.0
ONBOOT=yes
PHYSDEV=eth0
STARTMODE=auto
TYPE=Ethernet
USERCTL=no
VLAN=yes

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Quique Llorente(quiquell) wrote on 2020-11-05T08:56:37.039417+00:00

I think this is fixed 8439b19

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Scott Moser(smoser) wrote on 2020-11-05T14:14:25.382205+00:00

This just missed 20.3, but is included in upstream/master and will be included in 20.4.

Fixed in PR #541 #541

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Chad Smith(chad.smith) wrote on 2020-11-24T17:58:37.973737+00:00

This bug is believed to be fixed in cloud-init in version 20.4. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
launchpad Migrated from Launchpad
Projects
None yet
Development

No branches or pull requests

1 participant