Bug 53074 - Joinscript of univention-dhcp fails: Subnet address: Not a valid IP address
Joinscript of univention-dhcp fails: Subnet address: Not a valid IP address
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: DHCP
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0
Assigned To: Philipp Hahn
Arvid Requate
:
Depends on: 52259
Blocks:
  Show dependency treegraph
 
Reported: 2021-04-13 22:30 CEST by Arvid Requate
Modified: 2021-05-25 16:03 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Requate univentionstaff 2021-04-13 22:30:33 CEST
During installation of univention-dhcp on a UCS 5.0 Primary Node, the joinscript fails with a python traceback. This is with shell -x output:

=======================================
++ univention-ldapsearch -LLL -b dc=ucs50pt1,dc=dev '(objectClass=univentionDhcpSubnet)' dn
++ grep -c '^dn'
+ count=1
+ log 'Number of existing DHCP (Shared) Sub-Networks: 1'
+ echo '25univention-dhcp.inst: Number of existing DHCP (Shared) Sub-Networks: 1'
25univention-dhcp.inst: Number of existing DHCP (Shared) Sub-Networks: 1
+ '[' 1 -ge 1 ']'
+ return
+ /usr/lib/univention-dhcp/create-subnets --service cn=ucs50pt1.dev,cn=dhcp,dc=ucs50pt1,dc=dev
Insufficient access
Using BINDDN cn=admin,dc=ucs50pt1,dc=dev
Traceback (most recent call last):
  File "/usr/lib/univention-dhcp/create-subnets", line 128, in <module>
    main()
  File "/usr/lib/univention-dhcp/create-subnets", line 60, in main
    create(opt, ucr, iface, lo, mod)
  File "/usr/lib/univention-dhcp/create-subnets", line 116, in create
    obj["subnet"] = network
  File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 446, in __setitem__
    raise univention.admin.uexceptions.valueInvalidSyntax("%s: %s" % (self.descriptions[key].short_description, err), property=key)
univention.admin.uexceptions.valueInvalidSyntax: Subnet address: Not a valid IP address!
+ die
=======================================

I printed the cariable value:
network: 10.200.8.0/24 (<class 'str'>)
Comment 1 Arvid Requate univentionstaff 2021-04-13 23:05:53 CEST
In comparison to my UCS 4.4-7 DC I see that the UCS 5.0 DC doesn't have the network and boradcast addresses set. After setting them manually to

ucr set interfaces/ens3/network=10.200.8.0 interfaces/ens3/broadcast=10.200.8.255

the joinscript runs successfully and the value on network in the python script changed back to: network: 10.200.8.0 (<class 'str'>)
Comment 2 Arvid Requate univentionstaff 2021-04-13 23:26:43 CEST
I guess this would already fail on a UCS 4.4-7 system (or installed with 4.3-0 or later). If I set the interfaces/* variables on my updated 4.4 system like they are in UCS 5.0, then installation of univention-dhcp fails there too.
Comment 3 Philipp Hahn univentionstaff 2021-04-14 08:55:12 CEST
Reproducer
==========
ucr set interfaces/restart/auto=no
ucr --keys-only search --non-empty '^interfaces/[^/]+/(network|broadcast)$' |
  xargs -r ucr unset
LB="$(ucr get ldap/base)"
udm dhcp/service create --set service=test
pdb3 /usr/lib/univention-dhcp/create-subnets \
  --service "cn=test,$LB" \
  --binddn "cn=admin,$LB" \
  --bindpwdfile /etc/ldap.secret

(Pdb) break 110
(Pdb) run
(Pdb) p addr
IPv4Interface('10.200.17.38/24')
(Pdb) p iface.network
None
(Pdb) p iface.broadcast
None
(Pdb) p addr.broadcast
*** AttributeError: 'IPv4Interface' object has no attribute 'broadcast'

References
==========
git:4359208b7a1eca018b1d2b28e39f5bb9131bc23a
patches/netcfg/5.0-0-0-ucs/1.160/0001-Bug-35435-d-i-Write-UCR-net-configuration.patch

Analysis
========
Newer D-I netcfg no longer sets "interfaces/$iface/(network|broadcast)" for a long time: Most setups use the convention "network_address=ALL_ZERO" and "broadcast_address=ALL_ONES" anyway, which most tools do automatically. USS explicitly sets those UCRVs based on that convention when configuring the network manually, but not D-I.
With the conversion to Python 3 the implementation changed to use Python-3-native "ipaddress" instead of Legacy-Python "ipaddr", which uses different names and returns slightly different data.

Fix
===
[5.0-0] a8ae5444ef fix[dhcp]: Fix DHCP network creation
 services/univention-dhcp/debian/changelog                       | 6 ++++++
 services/univention-dhcp/usr/lib/univention-dhcp/create-subnets | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

Package: univention-dhcp
Version: 14.0.3-5A~5.0.0.202104140843

No explicit changelog entry needed as this is a regression from Bug #52259.
Comment 4 Arvid Requate univentionstaff 2021-04-14 10:17:36 CEST
Thanks, works.
Comment 5 Florian Best univentionstaff 2021-05-25 16:03:05 CEST
UCS 5.0 has been released:
 https://docs.software-univention.de/release-notes-5.0-0-en.html
 https://docs.software-univention.de/release-notes-5.0-0-de.html

If this error occurs again, please use "Clone This Bug".