Merge pull request #9483 from rainzm/webhook/pending_delete

Webhook better describe the life cycle of the guest
This commit is contained in:
Zexi Li
2020-12-18 20:37:43 +08:00
committed by GitHub
3 changed files with 14 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 {
+1
View File
@@ -2659,6 +2659,7 @@ func (self *SGuest) DoCancelPendingDelete(ctx context.Context, userCred mcclient
if err != nil {
return err
}
notifyclient.NotifyWebhook(ctx, userCred, self, notifyclient.ActionCreate)
return nil
}
+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,