mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: refresh quota usage may timeout
This commit is contained in:
@@ -124,7 +124,9 @@ func (manager *SQuotaBaseManager) queryQuota(ctx context.Context, quota IQuota,
|
||||
|
||||
ret.Update(jsonutils.Marshal(keys))
|
||||
ret.Update(quota.ToJSON(""))
|
||||
ret.Update(usage.ToJSON("usage"))
|
||||
if usage != nil {
|
||||
ret.Update(usage.ToJSON("usage"))
|
||||
}
|
||||
if len(pendings) > 0 {
|
||||
pendingArray := jsonutils.NewArray()
|
||||
for _, q := range pendings {
|
||||
|
||||
@@ -74,15 +74,23 @@ func (manager *SQuotaBaseManager) PostUsageJob(keys IQuotaKeys, usageChan chan I
|
||||
worker.Run(func() {
|
||||
ctx := context.Background()
|
||||
|
||||
usage := manager.newQuota()
|
||||
|
||||
if !isDirty(key) {
|
||||
if usageChan != nil {
|
||||
manager.usageStore.GetQuota(ctx, keys, usage)
|
||||
usageChan <- usage
|
||||
}
|
||||
return
|
||||
}
|
||||
clearDirty(key)
|
||||
|
||||
usage := manager.newQuota()
|
||||
usage.SetKeys(keys)
|
||||
err := usage.FetchUsage(ctx)
|
||||
if err != nil {
|
||||
log.Debugf("usage.FetchUsage fail %s", err)
|
||||
if usageChan != nil {
|
||||
usageChan <- nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user