Merge pull request #665 from gravitl/bugfix_v0.10.0_delete_node

fix delete node, publish message to node to be dleted before updating…
This commit is contained in:
dcarns 2022-02-03 08:33:05 -05:00 committed by GitHub
commit 844028b07c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -589,6 +589,9 @@ func deleteNode(w http.ResponseWriter, r *http.Request) {
returnErrorResponse(w, r, formatError(fmt.Errorf("cannot delete server node"), "badrequest"))
return
}
//send update to node to be deleted before deleting on server otherwise message cannot be sent
node.Action = models.NODE_DELETE
runUpdates(&node, true)
err = logic.DeleteNodeByID(&node, false)
if err != nil {
returnErrorResponse(w, r, formatError(err, "internal"))
@ -599,11 +602,9 @@ func deleteNode(w http.ResponseWriter, r *http.Request) {
returnErrorResponse(w, r, formatError(err, "internal"))
return
}
node.Action = models.NODE_DELETE
logger.Log(1, r.Header.Get("user"), "Deleted node", nodeid, "from network", params["network"])
returnSuccessResponse(w, r, nodeid+" deleted.")
runUpdates(&node, true)
}
func runUpdates(node *models.Node, nodeUpdate bool) error {