OpenNebula / one-apps

Toolchain to build OpenNebula appliances
Apache License 2.0
12 stars 10 forks source link

Contextualization deletes manually created NetworkManager Connections in EL9 #44

Closed cbr46 closed 4 months ago

cbr46 commented 7 months ago

Description When using Virtual Networks without IP Assignment, i.e. only a MAC Address is provided, the Contextualization deletes manually created NetworkManager Connections in EL9 at every reboot.

To Reproduce

  1. Create a Virtual Network w/o automatic IP Assignment
  2. Create a Virtual Machine with an Interface in that Network
  3. Manually create a NetworkManager Connection for that NIC
  4. Reboot VM

Expected behavior When using a Virtual Network without automatic IP assignment and with manually created NetworkManager Connections, the Contextualization should not delete those Connections upon rebooting.

Cause The Bug is in this if-statement within the network functions: https://github.com/OpenNebula/one-apps/blob/master/context-linux/src/etc/one-context.d/loc-10-network.d/functions#L84

When using a Virtual Network without automatic IP assignment, ETH0_MAC will still be configured within the context: image

Contextualization thus thinks it has to manage the entire interface, which is not the case. The if-statement should also check if ETH0_IP is set:

    for _iface in $_context_interfaces; do
        _mac=$(get_iface_var "${_iface}" "MAC")
        _ip=$(get_iface_var "${_iface}" "IP")
        _dev=$(get_dev "${_iface_mac}" "${_mac}")

[...]

        # nm (on RH systems it was deleted with ifcfg-*)
        for _nm_con in /etc/NetworkManager/system-connections/* ; do
            if [ -e "${_nm_con}" ] && grep -q "^interface-name=${_dev}$" "${_nm_con}" && [ -n "${_ip}" ] ; then
                rm -f "${_nm_con}"
            fi
        done
    done
cbr46 commented 7 months ago

Furthermore there's a syntax error in https://github.com/OpenNebula/one-apps/blob/master/context-linux/src/etc/one-context.d/loc-10-network.d/netcfg-nm#L268 The if-statement has to be in double brackets.

rsmontero commented 7 months ago

Furthermore there's a syntax error in https://github.com/OpenNebula/one-apps/blob/master/context-linux/src/etc/one-context.d/loc-10-network.d/netcfg-nm#L268 The if-statement has to be in double brackets.

In the meantime this has been fixed 61542444c2a74d0e604f17e7a3851d4c1e5f2d79

cbr46 commented 7 months ago

Well, the whole Contextualization seems to not be made for the use without automatic IP Assignment. If you install the package, the install process will always generate this file, which turns the management of DNS (resolv.conf) through NetworkManager off: https://github.com/OpenNebula/one-apps/blob/master/context-linux/src/etc/NetworkManager/conf.d/one-context.conf%23%23linux.one. Thus the DNS servers in the NM Connection will be ignored.

If you were to remove this file (or line in the file), automatic IP assignment probably wouldn't work anymore, as the DNS servers are not managed through NetworkManager when using this feature.

rsmontero commented 4 months ago

We have been working on several aspects related to this issue, now setting the IP_METHOD=skip should bypass the configuration. This setting can be done per vnet, address range or per VM NIC