Cannot delete some instances of model 'Domain' because they are referenced through a protected foreign key

Bug #1774529 reported by james beedy
40
This bug affects 8 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Huw Wilkins
maas-ui
Fix Released
Unknown

Bug Description

Domain will not delete even when no records exist.

Tags: ui
Revision history for this message
james beedy (jamesbeedy) wrote :
Changed in maas:
status: New → Incomplete
status: Incomplete → New
Revision history for this message
Andres Rodriguez (andreserl) wrote : Re: [2.4] Cannot delete some instances of model 'Domain' because they are referenced through a protected foreign key

Hi James,

Do you have any rack controller interfaces in this domain? (e.g. a rack controller with the domain in 'example.com').

Changed in maas:
status: New → Incomplete
summary: - Cannot delete some instances of model 'Domain' because they are
+ [2.4] Cannot delete some instances of model 'Domain' because they are
referenced through a protected foreign key
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for MAAS because there has been no activity for 60 days.]

Changed in maas:
status: Incomplete → Expired
zw.paper (zw-paper)
Changed in maas:
status: Expired → Confirmed
Revision history for this message
zw.paper (zw-paper) wrote :

Hi Andres,

I met this error in my env too.

I do not create any rack controller because this is a domain for testing or some internal using.

Here is what I did:
1. Install a MAAS.
2. Create a domain: test.com
3. Create an A record: host.test.com -> 10.10.10.10
4. Delete the A record

Then I can not delete the domain test.com
the same error msg as James.

What I found:
When deleting the record:
1. MAAS deleted the record from maasserver_dnsresource_ip_addresses in PG.
2. There is one more record in maasserver_dnsresource in PG

When I was trying to delete the domain
1. the record in maasserver_dnsresource has the foreign key pointing to maasserver_domain.

Revision history for this message
zw.paper (zw-paper) wrote :

by the way, this also happened in MAAS 2.5.0

Revision history for this message
Björn Tillenius (bjornt) wrote :

I'm not able to reproduce this as per the step in comment #4 with MAAS 2.7.0. Can you confirm that this is still and issue with 2.7.0 and attach the logs?

Changed in maas:
status: Confirmed → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for MAAS because there has been no activity for 60 days.]

Changed in maas:
status: Incomplete → Expired
Revision history for this message
Vladimir Grevtsev (vlgrevtsev) wrote :

Reproduced on latest 2.8.2 (8577-g.a3e674063-0ubuntu1~18.04.1) but only via UI - domains/records created with CLI are deleted ok:

<CLI>

ubuntu@OrangeBox84:~$ maas admin domains create name=mydomain
Success.
Machine-readable output follows:
{
    "authoritative": true,
    "ttl": null,
    "name": "mydomain",
    "is_default": false,
    "resource_record_count": 0,
    "id": 4,
    "resource_uri": "/MAAS/api/2.0/domains/4/"
}
ubuntu@OrangeBox84:~$ maas admin dnsresource-records create fqdn=devci.mydomain rrtype=NS rrdata=ns1-devci.maas
Success.
Machine-readable output follows:
{
    "ttl": null,
    "rrtype": "NS",
    "rrdata": "ns1-devci.maas",
    "id": 5,
    "fqdn": "devci.mydomain",
    "resource_uri": "/MAAS/api/2.0/dnsresourcerecords/5/"
}

ubuntu@OrangeBox84:~$ maas admin dnsresource-record delete 5
Success.
Machine-readable output follows:

ubuntu@OrangeBox84:~$ maas admin domain delete 4
Success.
Machine-readable output follows:

ubuntu@OrangeBox84:~$

Changed in maas:
status: Expired → New
Revision history for this message
Vladimir Grevtsev (vlgrevtsev) wrote :

The same, but via UI raises an error (see attachment).

summary: - [2.4] Cannot delete some instances of model 'Domain' because they are
+ Cannot delete some instances of model 'Domain' because they are
referenced through a protected foreign key
tags: added: ui
Changed in maas-ui:
importance: Undecided → Unknown
Revision history for this message
Jochen Wezel (jwezel) wrote :

I can confirm the issue still exists at v2.7.3
Same behaviour as Vladimir Grevtsev (vlgrevtsev) wrote on 2020-09-18

I also created these domains using the web UI, created the test entries for a host, removed the host entries and at the end I would like to remove the DNS domain again.

I do not work / test with the maas console.

Requested bug fixes:
1. Fix of this issue so that new new domains can be removed again as in .mov from vlgrevtsev
2. Fix of existing domains that already have this issue of dead foreign key refererences (database repair or whatever it takes to accomplish this task)

Changed in maas:
milestone: none → 2.10-beta1
status: New → In Progress
importance: Undecided → Critical
importance: Critical → High
status: In Progress → Triaged
Changed in maas:
milestone: 3.0-beta1 → 3.0-beta2
Changed in maas:
milestone: 3.0-beta2 → 3.0-beta3
Changed in maas:
milestone: 3.0.0-beta3 → 3.0.0-beta4
Changed in maas:
milestone: 3.0.0-beta4 → 3.0.0-beta5
Changed in maas:
milestone: 3.0.0-beta5 → 3.0.0-rc1
Changed in maas:
milestone: 3.0.0-rc1 → 3.0.1
Huw Wilkins (huwshimi)
Changed in maas:
assignee: nobody → Huw Wilkins (huwshimi)
status: Triaged → In Progress
Huw Wilkins (huwshimi)
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: 3.0.1 → 3.0.0-rc1
Changed in maas-ui:
status: New → Fix Released
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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