feat(region): distinguish between pending delete and delete notification

This commit is contained in:
rainzm
2020-12-18 13:05:24 +08:00
parent f1c2c9773c
commit 81588c92ae
2 changed files with 13 additions and 8 deletions
+6 -5
View File
@@ -41,11 +41,12 @@ type SAction string
var (
Event SEvent
ActionCreate SAction = "create"
ActionUpdate SAction = "update"
ActionDelete SAction = "delete"
ActionRebuildRoot SAction = "rebuild_root"
ActionChangeConfig SAction = "change_config"
ActionCreate SAction = "create"
ActionUpdate SAction = "update"
ActionDelete SAction = "delete"
ActionPendingDelete SAction = "pending_delete"
ActionRebuildRoot SAction = "rebuild_root"
ActionChangeConfig SAction = "change_config"
)
type SEvent struct {
+7 -3
View File
@@ -337,15 +337,19 @@ func (self *GuestDeleteTask) DeleteGuest(ctx context.Context, guest *models.SGue
// guest.RemoveAllMetadata(ctx, self.UserCred)
db.OpsLog.LogEvent(guest, db.ACT_DELOCATE, nil, self.UserCred)
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_DELOCATE, nil, self.UserCred, true)
if !guest.IsSystem && !isPendingDeleted {
self.NotifyServerDeleted(ctx, guest)
if !guest.IsSystem {
if !isPendingDeleted {
self.NotifyServerDeleted(ctx, guest)
} else {
notifyclient.NotifyWebhook(ctx, self.UserCred, guest, notifyclient.ActionDelete)
}
}
models.HostManager.ClearSchedDescCache(guest.HostId)
self.SetStageComplete(ctx, nil)
}
func (self *GuestDeleteTask) NotifyServerDeleted(ctx context.Context, guest *models.SGuest) {
notifyclient.NotifyWebhook(ctx, self.UserCred, guest, notifyclient.ActionDelete)
notifyclient.NotifyWebhook(ctx, self.UserCred, guest, notifyclient.ActionPendingDelete)
guest.NotifyServerEvent(
ctx,
self.UserCred,