Merge pull request #2539 from swordqiu/hotfix/qj-not-release-pending-usage-after-failed-change-config

fix: pending usage not release after failed change config
This commit is contained in:
yunion-ci-robot
2019-08-24 18:40:10 +08:00
committed by GitHub
2 changed files with 8 additions and 12 deletions

View File

@@ -39,12 +39,10 @@ func (self *SDiskBaseTask) SetStageFailed(ctx context.Context, reason string) {
func (self *SDiskBaseTask) finalReleasePendingUsage(ctx context.Context) {
pendingUsage := models.SQuota{}
err := self.GetPendingUsage(&pendingUsage)
if err == nil {
if !pendingUsage.IsEmpty() {
disk := self.getDisk()
quotaPlatform := disk.GetQuotaPlatformID()
models.QuotaManager.CancelPendingUsage(ctx, self.UserCred, rbacutils.ScopeProject, disk.GetOwnerId(), quotaPlatform, &pendingUsage, &pendingUsage)
}
if err == nil && !pendingUsage.IsEmpty() {
disk := self.getDisk()
quotaPlatform := disk.GetQuotaPlatformID()
models.QuotaManager.CancelPendingUsage(ctx, self.UserCred, rbacutils.ScopeProject, disk.GetOwnerId(), quotaPlatform, &pendingUsage, &pendingUsage)
}
}

View File

@@ -39,11 +39,9 @@ func (self *SGuestBaseTask) SetStageFailed(ctx context.Context, reason string) {
func (self *SGuestBaseTask) finalReleasePendingUsage(ctx context.Context) {
pendingUsage := models.SQuota{}
err := self.GetPendingUsage(&pendingUsage)
if err != nil {
if !pendingUsage.IsEmpty() {
guest := self.getGuest()
quotaPlatform := guest.GetQuotaPlatformID()
models.QuotaManager.CancelPendingUsage(ctx, self.UserCred, rbacutils.ScopeProject, guest.GetOwnerId(), quotaPlatform, &pendingUsage, &pendingUsage)
}
if err == nil && !pendingUsage.IsEmpty() {
guest := self.getGuest()
quotaPlatform := guest.GetQuotaPlatformID()
models.QuotaManager.CancelPendingUsage(ctx, self.UserCred, rbacutils.ScopeProject, guest.GetOwnerId(), quotaPlatform, &pendingUsage, &pendingUsage)
}
}