KeyError: 'NETMASK2'

Bug #1958506 reported by Oleg Neumyvakin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
High
Unassigned

Bug Description

cat /etc/os-release
NAME="AlmaLinux"
VERSION="8.5 (Arctic Sphynx)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.5"
PLATFORM_ID="platform:el8"
PRETTY_NAME="AlmaLinux 8.5 (Arctic Sphynx)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-8"
ALMALINUX_MANTISBT_PROJECT_VERSION="8.5"

rpm -qa | grep cloud-init
cloud-init-21.1-7.el8_5.3.alma.noarch

cloud-init status -w

status: error

2022-01-20 08:12:51,021 - subp.py[DEBUG]: Running command ['ip', '-6', 'addr', 'show', 'permanent', 'scope', 'global'] with allowed return codes [0] (shell=False, capture=True)
2022-01-20 08:12:51,039 - subp.py[DEBUG]: Running command ['ip', '-4', 'addr', 'show'] with allowed return codes [0] (shell=False, capture=True)
2022-01-20 08:12:51,052 - __init__.py[DEBUG]: achieving renaming of [['52:54:00:27:b0:7a', 'eth0', None, None]] with ops [('rename', '52:54:00:27:b0:7a', 'eth0', ('ens3', 'eth0'))]
2022-01-20 08:12:51,052 - subp.py[DEBUG]: Running command ['ip', 'link', 'set', 'ens3', 'name', 'eth0'] with allowed return codes [0] (shell=False, capture=True)
2022-01-20 08:12:51,068 - stages.py[INFO]: Applying network configuration from ds bringup=False: {'version': 2, 'ethernets': {'eth0': {'set-name': 'eth0', 'mtu': 1400, 'match': {'macaddress': '52:54:00:27:b0:7a'
}, 'addresses': ['10.54.2.35/21', '2a00:1730:fff9:100::5e/128'], 'gateway4': '10.54.0.1', 'gateway6': '2a00:1730:fff9:100::1', 'routes': [{'to': '10.54.0.1/32', 'via': '0.0.0.0', 'scope': 'link'}, {'to': '0.0.0.
0/0', 'via': '10.54.0.1', 'scope': 'link'}, {'to': '2a00:1730:fff9:100::1/128', 'via': '::0', 'scope': 'link'}, {'to': '::0/0', 'via': '2a00:1730:fff9:100::1', 'scope': 'link'}], 'nameservers': {'addresses': ['1
0.52.1.1', '10.52.1.71', '2001:4860:4860::8888', '2001:4860:4860::8844']}}}}
2022-01-20 08:12:51,069 - __init__.py[DEBUG]: Selected renderer 'sysconfig' from priority list: None
2022-01-20 08:12:51,069 - network_state.py[DEBUG]: v2(ethernets) -> v1(physical):
{'type': 'physical', 'name': 'eth0', 'mac_address': '52:54:00:27:b0:7a', 'mtu': 1400, 'match': {'macaddress': '52:54:00:27:b0:7a'}, 'subnets': [{'type': 'static', 'address': '10.54.2.35/21', 'gateway': '10.54.0.
1', 'dns_nameservers': ['10.52.1.1', '10.52.1.71', '2001:4860:4860::8888', '2001:4860:4860::8844'], 'routes': [{'gateway': '0.0.0.0', 'network': '10.54.0.1', 'prefix': 32, 'netmask': '255.255.255.255'}, {'gatewa
y': '10.54.0.1', 'network': '0.0.0.0', 'prefix': 0, 'netmask': '0.0.0.0'}, {'gateway': '::0', 'network': '2a00:1730:fff9:100::1', 'prefix': 128}, {'gateway': '2a00:1730:fff9:100::1', 'network': '::0', 'prefix':
0}]}, {'type': 'static', 'address': '2a00:1730:fff9:100::5e/128', 'gateway': '2a00:1730:fff9:100::1'}]}
2022-01-20 08:12:51,084 - network_state.py[DEBUG]: v2_common: handling config:
{'eth0': {'set-name': 'eth0', 'mtu': 1400, 'match': {'macaddress': '52:54:00:27:b0:7a'}, 'addresses': ['10.54.2.35/21', '2a00:1730:fff9:100::5e/128'], 'gateway4': '10.54.0.1', 'gateway6': '2a00:1730:fff9:100::1'
, 'routes': [{'to': '10.54.0.1/32', 'via': '0.0.0.0', 'scope': 'link'}, {'to': '0.0.0.0/0', 'via': '10.54.0.1', 'scope': 'link'}, {'to': '2a00:1730:fff9:100::1/128', 'via': '::0', 'scope': 'link'}, {'to': '::0/0
', 'via': '2a00:1730:fff9:100::1', 'scope': 'link'}], 'nameservers': {'addresses': ['10.52.1.1', '10.52.1.71', '2001:4860:4860::8888', '2001:4860:4860::8844']}}}
2022-01-20 08:12:51,085 - sysconfig.py[DEBUG]: eth0 has 4 entries in dns_nameservers. Only 3 are used.
2022-01-20 08:12:51,095 - util.py[WARNING]: failed stage init-local
2022-01-20 08:12:51,100 - util.py[DEBUG]: failed stage init-local
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 652, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 361, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python3.6/site-packages/cloudinit/stages.py", line 735, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/__init__.py", line 206, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/rhel.py", line 66, in _write_network_config
    return self._supported_write_network_config(netconfig)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/__init__.py", line 121, in _supported_write_network_config
    renderer.render_network_config(network_config)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/renderer.py", line 56, in render_network_config
    templates=templates, target=target)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 902, in render_network_state
    templates=templates).items():
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 892, in _render_sysconfig
    contents[cpath] = iface_cfg.routes.to_string(proto)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 200, in to_string
    netmask_value = str(self._conf['NETMASK' + index])
KeyError: 'NETMASK2'

Cloud-init v. 21.1-7.el8_5.3.alma running 'init-local' at Thu, 20 Jan 2022 08:12:50 +0000. Up 7.59 seconds.
2022-01-20 08:12:51,095 - util.py[WARNING]: failed stage init-local
failed run of stage init-local
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 652, in status_wrapper
    ret = functor(name, args)
  File "/usr/lib/python3.6/site-packages/cloudinit/cmd/main.py", line 361, in main_init
    init.apply_network_config(bring_up=bool(mode != sources.DSMODE_LOCAL))
  File "/usr/lib/python3.6/site-packages/cloudinit/stages.py", line 735, in apply_network_config
    return self.distro.apply_network_config(netcfg, bring_up=bring_up)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/__init__.py", line 206, in apply_network_config
    dev_names = self._write_network_config(netconfig)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/rhel.py", line 66, in _write_network_config
    return self._supported_write_network_config(netconfig)
  File "/usr/lib/python3.6/site-packages/cloudinit/distros/__init__.py", line 121, in _supported_write_network_config
    renderer.render_network_config(network_config)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/renderer.py", line 56, in render_network_config
    templates=templates, target=target)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 902, in render_network_state
    templates=templates).items():
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 892, in _render_sysconfig
    contents[cpath] = iface_cfg.routes.to_string(proto)
  File "/usr/lib/python3.6/site-packages/cloudinit/net/sysconfig.py", line 200, in to_string
    netmask_value = str(self._conf['NETMASK' + index])
KeyError: 'NETMASK2'
------------------------------------------------------------
Cloud-init v. 21.1-7.el8_5.3.alma running 'init' at Thu, 20 Jan 2022 08:13:51 +0000. Up 69.37 seconds.
ci-info: ++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++
ci-info: +--------+------+------------------------------+-----------+-------+-------------------+
ci-info: | Device | Up | Address | Mask | Scope | Hw-Address |
ci-info: +--------+------+------------------------------+-----------+-------+-------------------+
ci-info: | eth0 | True | fe80::1e54:d6ef:c452:144a/64 | . | link | 52:54:00:27:b0:7a |
ci-info: | lo | True | 127.0.0.1 | 255.0.0.0 | host | . |
ci-info: | lo | True | ::1/128 | . | host | . |
ci-info: +--------+------+------------------------------+-----------+-------+-------------------+
ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: | Route | Destination | Gateway | Interface | Flags |
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: | 1 | fe80::/64 | :: | eth0 | U |
ci-info: | 3 | local | :: | eth0 | U |
ci-info: | 4 | multicast | :: | eth0 | U |
ci-info: +-------+-------------+---------+-----------+-------+

The same error in RockyLinux

# grep NETMASK2 /var/log/cloud-init-output.log
KeyError: 'NETMASK2'
[root@pablo-qtfsts ~]# cat /etc/os-release | grep PRETTY_NAME
PRETTY_NAME="Rocky Linux 8.4 (Green Obsidian)"

description: updated
description: updated
Revision history for this message
James Falcon (falcojr) wrote :

Thank you for the detailed bug report. In order to help debug, please also run "cloud-init collect-logs" on an affected instance and attach the tarball here. Additionally, please attach/pastebin any network configuration that was provided to the instance.

Once you've attached these items, feel free to change the status back to "New".

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
Oleg Neumyvakin (oneumyvakin) wrote (last edit ):

Here are logs and network configs.

cat cloud-init-logs-2022-01-27/network-config
version: 2
ethernets:
  eth0:
    set-name: eth0
    mtu: 1400
    match:
      macaddress: "52:54:00:3f:fc:f7"
    addresses:
      - 10.54.2.19/21
      - 2a00:1730:fff9:100::52/128
    gateway4: 10.54.0.1
    gateway6: 2a00:1730:fff9:100::1
    routes:
      - to: 10.54.0.1/32
        via: 0.0.0.0
        scope: link
      - to: 0.0.0.0/0
        via: 10.54.0.1
        scope: link
      - to: 2a00:1730:fff9:100::1/128
        via: ::0
        scope: link
      - to: ::0/0
        via: 2a00:1730:fff9:100::1
        scope: link
    nameservers:
      addresses:
        - 10.52.1.1
        - 10.52.1.71
        - 2001:4860:4860::8888
        - 2001:4860:4860::8844

Link to image https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-20220126.0.x86_64.qcow2

Changed in cloud-init:
status: Incomplete → New
Revision history for this message
James Falcon (falcojr) wrote :

Thanks for the additional info. I am able to reproduce the bug

Changed in cloud-init:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Oleg Neumyvakin (oneumyvakin) wrote :

Could you please share if there is any workaround we can apply? :-)

Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Triaged → Fix Committed
Revision history for this message
Brett Holman (holmanb) wrote : Fixed in cloud-init version 22.2.

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

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.