mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-04 19:05:27 +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
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if index < 0 {
|
||||||
if index == -1 {
|
if len(h.Nodes) == 0 {
|
||||||
return fmt.Errorf("node %s, not found in host, %s", n.ID.String(), h.ID.String())
|
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 {
|
if err := deleteNodeByID(n); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.Nodes = RemoveStringSlice(h.Nodes, index)
|
|
||||||
return UpsertHost(h)
|
return UpsertHost(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue