mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #9483 from rainzm/webhook/pending_delete
Webhook better describe the life cycle of the guest
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user