mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-30 17:04:24 +08:00
fix node removal from host
This commit is contained in:
parent
749452af53
commit
d5446fb302
1 changed files with 7 additions and 5 deletions
|
@ -235,15 +235,17 @@ func DissasociateNodeFromHost(n *models.Node, h *models.Host) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
if index == -1 {
|
||||
return fmt.Errorf("node %s, not found in host, %s", n.ID.String(), h.ID.String())
|
||||
if index < 0 {
|
||||
if len(h.Nodes) == 0 {
|
||||
return fmt.Errorf("node %s, not found in host, %s", n.ID.String(), h.ID.String())
|
||||
}
|
||||
} else {
|
||||
h.Nodes = RemoveStringSlice(h.Nodes, index)
|
||||
}
|
||||
|
||||
if err := deleteNodeByID(n); err != nil {
|
||||
return err
|
||||
}
|
||||
h.Nodes = RemoveStringSlice(h.Nodes, index)
|
||||
|
||||
return UpsertHost(h)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue