mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #18 in YUNIONIO/onecloud from ~QUXUAN/onecloud:bugfix/qx-resize-check-quota to release/2.1.0
* commit '92f89fd575103d367fa10363b70114c5a309f0fe': bufix: 修复disk-resize quota检查问题
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/yunionio/pkg/utils"
|
||||
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"github.com/yunionio/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"github.com/yunionio/onecloud/pkg/cloudprovider"
|
||||
"github.com/yunionio/onecloud/pkg/compute/options"
|
||||
@@ -336,7 +337,11 @@ func (self *SDisk) PerformResize(ctx context.Context, userCred mcclient.TokenCre
|
||||
if addDisk > storage.GetFreeCapacity() {
|
||||
return nil, httperrors.NewOutOfResourceError("Not enough free space")
|
||||
}
|
||||
return nil, self.StartDiskResizeTask(ctx, userCred, int64(size))
|
||||
pendingUsage := SQuota{Storage: int(addDisk)}
|
||||
if err := QuotaManager.CheckSetPendingQuota(ctx, userCred, userCred.GetProjectId(), &pendingUsage); err != nil {
|
||||
return nil, httperrors.NewOutOfQuotaError(err.Error())
|
||||
}
|
||||
return nil, self.StartDiskResizeTask(ctx, userCred, int64(size), "", &pendingUsage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,15 +724,10 @@ func (self *SDisk) CustomizeDelete(ctx context.Context, userCred mcclient.TokenC
|
||||
return self.StartDiskDeleteTask(ctx, userCred, "", false)
|
||||
}
|
||||
|
||||
func (self *SDisk) StartDiskResizeTask(ctx context.Context, userCred mcclient.TokenCredential, size int64) error {
|
||||
func (self *SDisk) StartDiskResizeTask(ctx context.Context, userCred mcclient.TokenCredential, size int64, parentTaskId string, pendingUsage quotas.IQuota) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewInt(size), "size")
|
||||
pendingUsage := SQuota{Storage: int(size)}
|
||||
if err := QuotaManager.CheckSetPendingQuota(ctx, userCred, userCred.GetProjectId(), &pendingUsage); err != nil {
|
||||
return httperrors.NewOutOfQuotaError(err.Error())
|
||||
}
|
||||
if task, err := taskman.TaskManager.NewTask(ctx, "DiskResizeTask", self, userCred, params, "", "", &pendingUsage); err != nil {
|
||||
log.Errorf("%s", err)
|
||||
if task, err := taskman.TaskManager.NewTask(ctx, "DiskResizeTask", self, userCred, params, parentTaskId, "", pendingUsage); err != nil {
|
||||
return err
|
||||
} else {
|
||||
task.ScheduleRun(nil)
|
||||
|
||||
Reference in New Issue
Block a user