Closed naved001 closed 5 years ago
Solution 1. https://github.com/CCI-MOC/hil/blob/79d724e1efb6a3e31666f73153ab20c10838741a/hil/model.py#L557
We change that to this:
backref=db.backref('current_action', uselist=False, cascade="all,delete"))
http://docs.sqlalchemy.org/en/rel_0_9/orm/cascades.html
Comes with a migration script.
Solution 2.
In the nic_delete call, manually check and delete for any entries in the networking_action table and then delete the nic. For instance we require the nic to be deleted (by a user) before a node can be deleted, rather than doing a cascade delete on node.
@zenhack thoughts?
We should be refusing to delete a nic that has pending operations on it. But it shouldn't be throwing 500s, we should be detecting the issue and reporting it to the user cleanly.
It's not just pending operations anymore. We keep the networking actions in the table and mark them DONE
(or 'ERROR`) so that users can query the status later on.
And we keep a networking action for that nic until a new action on that nic replaces it.
Aha, then yeah, we should automatically delete the 'DONE' actions when the nic is removed. I'd prefer to do this via an explicit query, rather than a cascade, since that way we can filter on the status and it will still barf at us if there are pending actions and we somehow screw up and try to delete the nic.
I can't seem to delete a nic on a node.
Curl returns a 500 error. Before running this.
I then repeated this in my development environment. All you have to do is, register a nic, run a networking operation on it (connect to a network, or run revert port). And then try to delete it.
Probably because we create an entry in the neworking_action table for querying later so we can't just delete the nic because the networking_action table refers to that nic_id.
It was easily fixed by clearing my networking_action table.