mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix(notify): add server_panic topic (#15826)
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
{{- $d := .resource_details -}}
|
||||
您在{{ $d.project }}项目的虚拟机{{ $d.name }}崩溃了
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
{{- $d := .resource_details -}}
|
||||
The server {{ $d.name }} in project {{ $d.project }} panicked.
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
{{- $d := .resource_details -}}
|
||||
您在{{ $d.project }}项目的虚拟机{{ $d.name }}崩溃了
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
{{- $d := .resource_details -}}
|
||||
The server {{ $d.name }} in project {{ $d.project }}panicked.
|
||||
@@ -59,6 +59,7 @@ var (
|
||||
ActionNetOutOfSync SAction = "net_out_of_sync"
|
||||
ActionMysqlOutOfSync SAction = "mysql_out_of_sync"
|
||||
ActionServiceAbnormal SAction = "service_abnormal"
|
||||
ActionServerPanicked SAction = "server_panicked"
|
||||
|
||||
ResultFailed SResult = "failed"
|
||||
ResultSucceed SResult = "succeed"
|
||||
|
||||
@@ -59,6 +59,7 @@ var (
|
||||
ActionNetOutOfSync = api.ActionNetOutOfSync
|
||||
ActionMysqlOutOfSync = api.ActionMysqlOutOfSync
|
||||
ActionServiceAbnormal = api.ActionServiceAbnormal
|
||||
ActionServerPanicked = api.ActionServerPanicked
|
||||
|
||||
ActionPendingDelete = api.ActionPendingDelete
|
||||
|
||||
|
||||
@@ -140,13 +140,11 @@ func (self *SGuest) PerformEvent(ctx context.Context, userCred mcclient.TokenCre
|
||||
|
||||
db.OpsLog.LogEvent(self, db.ACT_GUEST_PANICKED, data.String(), userCred)
|
||||
logclient.AddSimpleActionLog(self, logclient.ACT_GUEST_PANICKED, data.String(), userCred, true)
|
||||
self.NotifyServerEvent(
|
||||
ctx,
|
||||
userCred,
|
||||
notifyclient.SERVER_PANICKED,
|
||||
notify.NotifyPriorityNormal,
|
||||
false, kwargs, true,
|
||||
)
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
Obj: self,
|
||||
Action: notifyclient.ActionServerPanicked,
|
||||
IsFail: true,
|
||||
})
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -650,7 +650,7 @@ func dataCleaning(tableName string) error {
|
||||
now := time.Now()
|
||||
monthsDaysAgo := now.AddDate(0, -1, 0).Format("2006-01-02 15:04:05")
|
||||
sqlStr := fmt.Sprintf(
|
||||
"update %s set deleted = 1 where deleted = 0 and created_at < '%s'",
|
||||
"delete from %s where created_at < '%s'",
|
||||
tableName,
|
||||
monthsDaysAgo,
|
||||
)
|
||||
|
||||
@@ -85,7 +85,6 @@ func (rm *SRobotManager) InitializeData() error {
|
||||
}
|
||||
rq := RobotManager.Query()
|
||||
rq = rq.Filter(sqlchemy.OR(sqlchemy.IsEmpty(rq.Field("tenant_id")), sqlchemy.Equals(rq.Field("tenant_id"), "system")))
|
||||
rq.DebugQuery()
|
||||
npRobots := make([]SRobot, 0)
|
||||
err = db.FetchModelObjects(RobotManager, rq, &npRobots)
|
||||
if err != nil {
|
||||
|
||||
@@ -101,6 +101,7 @@ const (
|
||||
DefaultNetOutOfSync = "net out of sync"
|
||||
DefaultMysqlOutOfSync = "mysql out of sync"
|
||||
DefaultServiceAbnormal = "service abnormal"
|
||||
DefaultServerPanicked = "server panicked"
|
||||
)
|
||||
|
||||
func (sm *STopicManager) InitializeData() error {
|
||||
@@ -126,6 +127,7 @@ func (sm *STopicManager) InitializeData() error {
|
||||
DefaultNetOutOfSync,
|
||||
DefaultMysqlOutOfSync,
|
||||
DefaultServiceAbnormal,
|
||||
DefaultServerPanicked,
|
||||
)
|
||||
q := sm.Query()
|
||||
topics := make([]STopic, 0, initSNames.Len())
|
||||
@@ -411,6 +413,15 @@ func (sm *STopicManager) InitializeData() error {
|
||||
)
|
||||
t.Results = tristate.True
|
||||
t.Type = notify.TOPIC_TYPE_AUTOMATED_PROCESS
|
||||
case DefaultServerPanicked:
|
||||
t.addResources(
|
||||
notify.TOPIC_RESOURCE_SERVER,
|
||||
)
|
||||
t.addAction(
|
||||
notify.ActionServerPanicked,
|
||||
)
|
||||
t.Results = tristate.False
|
||||
t.Type = notify.TOPIC_TYPE_RESOURCE
|
||||
}
|
||||
if topic == nil {
|
||||
err := sm.TableSpec().Insert(ctx, t)
|
||||
@@ -676,6 +687,7 @@ func init() {
|
||||
notify.ActionNetOutOfSync: 26,
|
||||
notify.ActionMysqlOutOfSync: 27,
|
||||
notify.ActionServiceAbnormal: 28,
|
||||
notify.ActionServerPanicked: 29,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user