Can't clear model fields

Bug #1259872 reported by Jeroen T. Vermeulen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Won't Fix
High
Unassigned

Bug Description

In the database schema, a node's zone is a foreign key to the Zone table. It's not the Zone's surrogate key though, but its name. Or it may be null, of course.

We have no obvious way to clear a node's zone. In the API, the empty string is accepted as a zone, but it doesn't actually update the field. The UI offers a default “---------” choice, but it doesn't affect the field either. And passing None in the API results in an "invalid choice" error.

Related branches

Revision history for this message
Raphaël Badin (rvb) wrote :

The trick is that we need to get the form to be able to distinguish between: None as in "set the zone to None" and None as in "this value was not provided". I have the feeling we need to use the sentinel pattern here but it's not clear at which level (form validation, model persistence, etc) it should be done.

description: updated
description: updated
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

I just confirmed with Node.agent_name: we can't clear other string fields through the API either.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

I just went through the models to see what other fields might be affected by this. Assuming that it only affects text fields, thankfully the list looks limited so far: Node.agent_name, Node.zone, and Zone.description.

Gavin Panella (allenap)
Changed in maas:
status: Confirmed → Triaged
status: Triaged → In Progress
assignee: nobody → Gavin Panella (allenap)
Revision history for this message
Gavin Panella (allenap) wrote :

The linked branch - lp:~allenap/maas/clear-field-via-api--bug-1259872 - doesn't actually fix the bug, it just cleans up some things. I hoped it would help me get towards a solution, but it hasn't helped. I've spent several hours on this and getting nowhere. I'm not actually able to write code to directly solve the problem; I have to somehow unravel the "helpful" features of Django and the code in MAAS that its style encourages. It's depressing and frustrating and a waste of what time I have left on this earth.

Gavin Panella (allenap)
Changed in maas:
status: In Progress → Triaged
assignee: Gavin Panella (allenap) → nobody
Revision history for this message
Gavin Panella (allenap) wrote :

Fwiw, in downgrading this to High from Critical, I'm saying that we shouldn't block the feature on the basis of this bug. It's also a bug that affects the whole MAAS API, not just zones.

Changed in maas:
importance: Critical → High
summary: - Can't clear a node's availabillity zone
+ Can't clear model fields
Changed in maas:
status: Triaged → Won't Fix
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.