del stras if node not exists

This commit is contained in:
Ulric Qin 2020-10-08 19:46:54 +08:00
parent 3534aa7e69
commit 97acc7d1d0
2 changed files with 7 additions and 0 deletions

View File

@ -230,6 +230,11 @@ func StraDel(id int64) error {
return session.Commit()
}
func StraDelByNid(nid int64) error {
_, err := DB["mon"].Where("nid=?", nid).Delete(new(Stra))
return err
}
func StrasList(name string, priority int, nid int64) ([]*Stra, error) {
session := DB["mon"].NewSession()
defer session.Close()

View File

@ -577,6 +577,8 @@ func GetLeafNidsForMon(nid int64, exclNid []int64) ([]int64, error) {
}
if node == nil {
// 节点已经被删了,相关的告警策略也删除
StraDelByNid(nid)
return []int64{}, nil
}