[2.4+] MAAS doesn't correctly validate creating domain names

Bug #1811936 reported by Andres Rodriguez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Invalid
High
Newell Jensen

Bug Description

From: https://discourse.maas.io/t/solved-2-4-having-difficulty-deleting-a-dns-record/282

Essentially I have a domain like: home.{domain}.com being managed by maas.
I mistakenly added an A entry of: ad.home.{domain>}.com which translated to: ad.home..com.home.{domain}.com
When I try to remove it in the GUI no errors, just doesn’t remove it. In journalctl there is this entry that coincides with trying to remove the entry:

Dec 26 14:21:28 aiomaas sh[1187]: 2018-12-26 14:21:28 maasserver.websockets.protocol: [critical] Error on request (13) domain.delete_address_record: {"__all__": ["Invalid dnsresource name: ad.home.{domain}.com."]}
Dec 26 14:21:28 aiomaas sh[1187]: Traceback (most recent call last):
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3.6/threading.py", line 864, in run
Dec 26 14:21:28 aiomaas sh[1187]: self._target(*self._args, **self._kwargs)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 850, in worker
Dec 26 14:21:28 aiomaas sh[1187]: return target()
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
Dec 26 14:21:28 aiomaas sh[1187]: task()
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
Dec 26 14:21:28 aiomaas sh[1187]: task()
Dec 26 14:21:28 aiomaas sh[1187]: --- <exception caught here> ---
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 250, in inContext
Dec 26 14:21:28 aiomaas sh[1187]: result = inContext.theWork()
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
Dec 26 14:21:28 aiomaas sh[1187]: inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
Dec 26 14:21:28 aiomaas sh[1187]: return self.currentContext().callWithContext(ctx, func, *args, **kw)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
Dec 26 14:21:28 aiomaas sh[1187]: return func(*args,**kw)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 883, in callInContext
Dec 26 14:21:28 aiomaas sh[1187]: return func(*args, **kwargs)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 232, in wrapper
Dec 26 14:21:28 aiomaas sh[1187]: result = func(*args, **kwargs)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 756, in call_within_transaction
Dec 26 14:21:28 aiomaas sh[1187]: return func_outside_txn(*args, **kwargs)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 563, in retrier
Dec 26 14:21:28 aiomaas sh[1187]: return func(*args, **kwargs)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3.6/contextlib.py", line 52, in inner
Dec 26 14:21:28 aiomaas sh[1187]: return func(*args, **kwds)
Dec 26 14:21:28 aiomaas sh[1187]: File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/domain.py", line 176, in delete_address_record
Dec 26 14:21:28 aiomaas sh[1187]: raise ValidationError(form.errors)
Dec 26 14:21:28 aiomaas sh[1187]: django.core.exceptions.ValidationError: {'__all__': ['Invalid dnsresource name: ad.home.{domain}.com.']}
Dec 26 14:21:28 aiomaas sh[1187]:

Seems that removing from API works.

Changed in maas:
milestone: none → 2.6.0
status: New → Triaged
Changed in maas:
importance: Undecided → High
tags: added: dns error-surface
Changed in maas:
milestone: 2.6.0 → 2.6.0beta2
Changed in maas:
milestone: 2.6.0beta2 → 2.6.0rc1
Changed in maas:
assignee: nobody → Newell Jensen (newell-jensen)
Changed in maas:
status: Triaged → In Progress
Revision history for this message
Newell Jensen (newell-jensen) wrote :

I have not been able to reproduce this. I am able to add a domain and dnsresource and delete both in the UI and/or API without any issues. This is similar to what I have reported with #1814164

Changed in maas:
status: In Progress → Triaged
Revision history for this message
Newell Jensen (newell-jensen) wrote :
Download full text (3.1 KiB)

The UI doesn't allow a user to add a domain name which is invalid as you will not be able to create it. Additionally in the API if entering invalid names you will get errors. Here is some MAAS cli commands to create a domain and A record that we can then delete without any issues.

# maas admin domains create name=newell_testing
{"name": ["Label contains disallowed characters: 'newell_testing'."]}
# maas admin domains create name=home.{domain}.com
{"name": ["Invalid domain name: home.{domain}.com.", "Label contains disallowed characters: '{domain}'."]}
# maas admin domains create name=home.domain.com
Success.
Machine-readable output follows:
{
    "authoritative": true,
    "ttl": null,
    "is_default": false,
    "id": 17,
    "name": "home.domain.com",
    "resource_record_count": 0,
    "resource_uri": "/MAAS/api/2.0/domains/17/"
}

Added an A record with name ad.domain>.com in the UI and reading this via api we see:

# maas admin dnsresources read
Success.
Machine-readable output follows:
[
    {
        "address_ttl": null,
        "resource_records": [],
        "id": 32,
        "fqdn": "ad.domain>.com.home.domain.com",
        "ip_addresses": [
            {
                "created": "2019-05-14T00:31:25.340",
                "ip": "10.0.0.14",
                "alloc_type": 4,
                "subnet": {
                    "name": "10.0.0.0/24",
                    "vlan": {
                        "vid": 0,
                        "mtu": 1500,
                        "dhcp_on": true,
                        "external_dhcp": null,
                        "relay_vlan": null,
                        "secondary_rack": null,
                        "fabric_id": 1,
                        "name": "untagged",
                        "primary_rack": "tt4est",
                        "id": 5002,
                        "space": "undefined",
                        "fabric": "fabric-1",
                        "resource_uri": "/MAAS/api/2.0/vlans/5002/"
                    },
                    "cidr": "10.0.0.0/24",
                    "rdns_mode": 2,
                    "gateway_ip": "10.0.0.1",
                    "dns_servers": [],
                    "allow_dns": true,
                    "allow_proxy": true,
                    "active_discovery": false,
                    "managed": true,
                    "id": 2,
                    "space": "undefined",
                    "resource_uri": "/MAAS/api/2.0/subnets/2/"
                },
                "interface_set": [],
                "alloc_type_name": "User reserved",
                "owner": {
                    "is_superuser": true,
                    "username": "admin",
                    "email": "<email address hidden>",
                    "is_local": true,
                    "resource_uri": "/MAAS/api/2.0/users/admin/"
                },
                "resource_uri": "/MAAS/api/2.0/ipaddresses/"
            }
        ],
        "resource_uri": "/MAAS/api/2.0/dnsresources/32/"
    }
]

Now we can delete the record and then the domain:

# maas admin dnsresource delete 32
Success.
Machine-readable output follows:

# maas admin domain delete 17
Success.
Machine-readabl...

Read more...

Changed in maas:
status: Triaged → Incomplete
Changed in maas:
milestone: 2.6.0rc1 → 2.6.0rc2
Changed in maas:
milestone: 2.6.0rc2 → 2.7.0alpha1
Changed in maas:
milestone: 2.7.0b1 → 2.7.0b2
no longer affects: maas/2.5
Changed in maas:
status: Incomplete → Invalid
milestone: 2.7.0b2 → none
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.