Missing foreign key constraints for Node.current_testing_script_set and friends

Bug #1996387 reported by Björn Tillenius
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Björn Tillenius

Bug Description

The 'current_commissioning_script_set', 'current_testing_script_set' and 'current_commissioning_script_set' are declared like this in Node:

    current_testing_script_set = ForeignKey(
        "metadataserver.ScriptSet",
        blank=True,
        null=True,
        on_delete=SET_NULL,
        related_name="+",
    )

But if you look in the database, there's no FOREIGN KEY constraint for that column.

Further more, it seems like the 'on_delete=SET_NULL' also doesn't work properly. Node.start() eventually triggers ScriptResult.create_installation_script_set(), which triggers ScriptResult._clean_old(), which deletes all empty script sets. If one of those are the 'current' scriptset for a node, the Node attribute doesn't get set to None. Instead it leaves a dangling reference to a non-existing script set.

See bug 1996074 for an example where this caused a problem.

Changed in maas:
status: New → Triaged
importance: Undecided → High
milestone: none → 3.3.0
assignee: nobody → Björn Tillenius (bjornt)
status: Triaged → In Progress
Revision history for this message
Björn Tillenius (bjornt) wrote :

By the looks of this, this is not trivial to fix. I'll take a stab at it on Tuesday. If I'm not able to do it then, I'll push it to 3.4.

Changed in maas:
milestone: 3.3.0 → 3.4.0
status: In Progress → Triaged
assignee: Björn Tillenius (bjornt) → nobody
Revision history for this message
Björn Tillenius (bjornt) wrote :

I have a fix for this, but will land it after we release 3.3

Changed in maas:
status: Triaged → In Progress
assignee: nobody → Björn Tillenius (bjornt)
summary: - Missing foreign key contstraints for Node.current_testing_script_set and
+ Missing foreign key constraints for Node.current_testing_script_set and
friends
Changed in maas:
status: In Progress → Fix Committed
Alberto Donato (ack)
Changed in maas:
milestone: 3.4.0 → 3.4.0-beta1
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.

Other bug subscribers

Remote bug watches

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