fix(monitor): 告警历史问题修复

1.https://bug.yunion.io/zentao/bug-view-7933.html
This commit is contained in:
zhaoxiangchun
2021-11-12 16:21:32 +08:00
parent 72f4ce4a5e
commit 979da5107b
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -1346,6 +1346,11 @@ jointLoop:
continue jointLoop
}
}
// 排除近期有报警状态的情况:system.uptime
if joint.AlertState == monitor.MONITOR_RESOURCE_ALERT_STATUS_ALERTING && time.Now().Sub(joint.TriggerTime).
Minutes() < 30 {
continue
}
deleteJointIds = append(deleteJointIds, joint.RowId)
}
if len(resourceIds) == 0 {
+8 -1
View File
@@ -299,7 +299,7 @@ func (self *SMonitorResource) RealDelete(ctx context.Context, userCred mcclient.
if err != nil {
return err
}
return self.SVirtualResourceBase.Delete(ctx, userCred)
return self.SVirtualResourceBase.Delete(ctx, nil)
}
func (self *SMonitorResource) DetachJoint(ctx context.Context, userCred mcclient.TokenCredential) error {
@@ -433,6 +433,13 @@ func (self *SMonitorResource) UpdateAttachJoint(alertRecord *SAlertRecord, match
return errors.Wrapf(err, "SMonitorResource:%s UpdateAttachJoint err", self.Name)
}
errs := make([]error, 0)
// 报警时发现没有进行关联,增加attach
if len(joints) == 0 {
self.AttachAlert(context.Background(), nil, alertRecord.AlertId)
joints, _ = MonitorResourceAlertManager.GetJoinsByListInput(monitor.
MonitorResourceJointListInput{MonitorResourceId: self.
ResId, AlertId: alertRecord.AlertId})
}
for _, joint := range joints {
err := joint.UpdateAlertRecordData(alertRecord, &match)
if err != nil {