mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: pending usage not release after failed change config
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user