From e65e38f50cc89133dbc8b9cd0dd8343a4fee9a37 Mon Sep 17 00:00:00 2001 From: rainzm Date: Fri, 14 May 2021 17:06:00 +0800 Subject: [PATCH] fix(region): send webhook when the creation task is completely completed --- pkg/compute/tasks/dbinstance_create_task.go | 3 ++- pkg/compute/tasks/loadbalancer_create_task.go | 2 +- pkg/compute/tasks/loadbalancer_listener_create_task.go | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/compute/tasks/dbinstance_create_task.go b/pkg/compute/tasks/dbinstance_create_task.go index 9eb6ff426d..a0c2ccb477 100644 --- a/pkg/compute/tasks/dbinstance_create_task.go +++ b/pkg/compute/tasks/dbinstance_create_task.go @@ -66,7 +66,6 @@ func (self *DBInstanceCreateTask) CreateDBInstance(ctx context.Context, rds *mod func (self *DBInstanceCreateTask) OnCreateDBInstanceComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) { dbinstance := obj.(*models.SDBInstance) logclient.AddActionLogWithStartable(self, dbinstance, logclient.ACT_CREATE, nil, self.UserCred, true) - notifyclient.NotifyWebhook(ctx, self.UserCred, dbinstance, notifyclient.ActionCreate) self.SetStage("OnSyncDBInstanceStatusComplete", nil) models.StartResourceSyncStatusTask(ctx, self.UserCred, dbinstance, "DBInstanceSyncStatusTask", self.GetTaskId()) } @@ -77,6 +76,8 @@ func (self *DBInstanceCreateTask) OnCreateDBInstanceCompleteFailed(ctx context.C } func (self *DBInstanceCreateTask) OnSyncDBInstanceStatusComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) { + dbinstance := obj.(*models.SDBInstance) + notifyclient.NotifyWebhook(ctx, self.UserCred, dbinstance, notifyclient.ActionCreate) self.SetStageComplete(ctx, nil) } diff --git a/pkg/compute/tasks/loadbalancer_create_task.go b/pkg/compute/tasks/loadbalancer_create_task.go index 03d4220790..62f03ca143 100644 --- a/pkg/compute/tasks/loadbalancer_create_task.go +++ b/pkg/compute/tasks/loadbalancer_create_task.go @@ -61,7 +61,6 @@ func (self *LoadbalancerCreateTask) OnLoadbalancerCreateComplete(ctx context.Con lb.SetStatus(self.GetUserCred(), api.LB_STATUS_ENABLED, "") db.OpsLog.LogEvent(lb, db.ACT_ALLOCATE, lb.GetShortDesc(ctx), self.UserCred) logclient.AddActionLogWithStartable(self, lb, logclient.ACT_CREATE, nil, self.UserCred, true) - notifyclient.NotifyWebhook(ctx, self.UserCred, lb, notifyclient.ActionCreate) self.SetStage("OnLoadbalancerStartComplete", nil) lb.StartLoadBalancerStartTask(ctx, self.GetUserCred(), self.GetTaskId()) } @@ -72,6 +71,7 @@ func (self *LoadbalancerCreateTask) OnLoadbalancerCreateCompleteFailed(ctx conte func (self *LoadbalancerCreateTask) OnLoadbalancerStartComplete(ctx context.Context, lb *models.SLoadbalancer, data jsonutils.JSONObject) { lb.SetStatus(self.GetUserCred(), api.LB_STATUS_ENABLED, "") + notifyclient.NotifyWebhook(ctx, self.UserCred, lb, notifyclient.ActionCreate) self.SetStageComplete(ctx, nil) } diff --git a/pkg/compute/tasks/loadbalancer_listener_create_task.go b/pkg/compute/tasks/loadbalancer_listener_create_task.go index 13e7cdcc11..156a2e8c29 100644 --- a/pkg/compute/tasks/loadbalancer_listener_create_task.go +++ b/pkg/compute/tasks/loadbalancer_listener_create_task.go @@ -180,7 +180,6 @@ func (self *LoadbalancerListenerCreateTask) OnPrepareLoadbalancerBackendgroup(ct lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_ENABLED, "") db.OpsLog.LogEvent(lblis, db.ACT_ALLOCATE, lblis.GetShortDesc(ctx), self.UserCred) logclient.AddActionLogWithStartable(self, lblis, logclient.ACT_CREATE, nil, self.UserCred, true) - notifyclient.NotifyWebhook(ctx, self.UserCred, lblis, notifyclient.ActionCreate) self.SetStage("OnLoadbalancerListenerStartComplete", nil) lblis.StartLoadBalancerListenerStartTask(ctx, self.GetUserCred(), self.GetTaskId()) } @@ -201,6 +200,7 @@ func (self *LoadbalancerListenerCreateTask) OnLoadbalancerListenerCreateComplete func (self *LoadbalancerListenerCreateTask) OnLoadbalancerListenerStartComplete(ctx context.Context, lblis *models.SLoadbalancerListener, data jsonutils.JSONObject) { lblis.SetStatus(self.GetUserCred(), api.LB_STATUS_ENABLED, "") + notifyclient.NotifyWebhook(ctx, self.UserCred, lblis, notifyclient.ActionCreate) self.SetStageComplete(ctx, nil) }