Merge ~tiago.pasqualini/maas:lp1807725 into maas:master

Proposed by Tiago Pasqualini da Silva
Status: Superseded
Proposed branch: ~tiago.pasqualini/maas:lp1807725
Merge into: maas:master
Diff against target: 49 lines (+19/-2)
2 files modified
src/maasserver/models/staticipaddress.py (+9/-2)
src/maasserver/utils/dns.py (+10/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Needs Fixing
MAAS Maintainers Pending
Review via email: mp+434000@code.launchpad.net

This proposal has been superseded by a proposal from 2022-12-02.

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b lp1807725 lp:~tiago.pasqualini/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas-tester/1547/consoleText
COMMIT: d5b537062408b0f05dbbe98bc95f21e4d542ca41

review: Needs Fixing

Unmerged commits

a3337f1... by Tiago Pasqualini da Silva

Fix incorrect hostname from interface name

MAAS currently creates a DNS record for each interface in a host
by simply using its interface name. Whenever an interface has the
'_' character, the code uses it anyway, which is currently breaking
bind as this character is not allowed on domain names.
This patch fixes that by verifying it and replacing the incorrect
character.

LP: #1807725

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/maasserver/models/staticipaddress.py b/src/maasserver/models/staticipaddress.py
index b5794a1..81c7a82 100644
--- a/src/maasserver/models/staticipaddress.py
+++ b/src/maasserver/models/staticipaddress.py
@@ -52,7 +52,10 @@ from maasserver.models.domain import Domain
52from maasserver.models.subnet import Subnet52from maasserver.models.subnet import Subnet
53from maasserver.models.timestampedmodel import TimestampedModel53from maasserver.models.timestampedmodel import TimestampedModel
54from maasserver.utils import orm54from maasserver.utils import orm
55from maasserver.utils.dns import get_ip_based_hostname55from maasserver.utils.dns import (
56 get_iface_name_based_hostname,
57 get_ip_based_hostname,
58)
56from provisioningserver.utils.enum import map_enum_reverse59from provisioningserver.utils.enum import map_enum_reverse
5760
58StaticIPAddress = TypeVar("StaticIPAddress")61StaticIPAddress = TypeVar("StaticIPAddress")
@@ -841,7 +844,11 @@ class StaticIPAddressManager(Manager):
841 # node, then consider adding the IP.844 # node, then consider adding the IP.
842 if result.assigned or not assigned_ips[result.fqdn]:845 if result.assigned or not assigned_ips[result.fqdn]:
843 if result.ip not in mapping[result.fqdn].ips:846 if result.ip not in mapping[result.fqdn].ips:
844 entry = mapping[f"{result.iface_name}.{result.fqdn}"]847 fqdn = "{}.{}".format(
848 get_iface_name_based_hostname(result.iface_name),
849 result.fqdn,
850 )
851 entry = mapping[fqdn]
845 entry.node_type = result.node_type852 entry.node_type = result.node_type
846 entry.system_id = result.system_id853 entry.system_id = result.system_id
847 if result.user_id is not None:854 if result.user_id is not None:
diff --git a/src/maasserver/utils/dns.py b/src/maasserver/utils/dns.py
index 0c8cde5..76f553a 100644
--- a/src/maasserver/utils/dns.py
+++ b/src/maasserver/utils/dns.py
@@ -91,6 +91,16 @@ def get_ip_based_hostname(ip):
91 return hostname91 return hostname
9292
9393
94def get_iface_name_based_hostname(iface_name):
95 """Given the specified interface name, creates an automatically generated
96 hostname by converting the '_' characters in it to '-' characters.
97
98 :param iface_name: Input value for the interface name.
99 """
100 hostname = iface_name.replace("_", "-")
101 return hostname
102
103
94def validate_url(url, schemes=("http", "https")):104def validate_url(url, schemes=("http", "https")):
95 """Validator for URLs.105 """Validator for URLs.
96106

Subscribers

People subscribed via source and target branches