Merge pull request #2577 from swordqiu/hotfix/qj-fix-quota-list-delete-projects

fix: quota-list fail if deleted projects found
This commit is contained in:
yunion-ci-robot
2019-08-27 10:08:13 +08:00
committed by GitHub
+9
View File
@@ -474,6 +474,10 @@ func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, targetDomainId
// fetch without cache expiration check
project, err := db.TenantCacheManager.FetchTenantByIdWithoutExpireCheck(ctx, projectId)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
continue
}
log.Errorf("fail to query project %s", projectId)
return nil, err
}
quota.Set("tenant", jsonutils.NewString(project.Name))
@@ -483,6 +487,10 @@ func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, targetDomainId
// fetch without cache expiration check
domain, err := db.TenantCacheManager.FetchDomainByIdWithoutExpireCheck(ctx, domainId)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
continue
}
log.Errorf("fail to query domain %s", domainId)
return nil, err
}
quota.Set("project_domain", jsonutils.NewString(domain.Name))
@@ -508,6 +516,7 @@ func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, targetDomainId
// fetch without cache expiration check
domain, err := db.TenantCacheManager.FetchDomainByIdWithoutExpireCheck(ctx, targetDomainId)
if err != nil {
log.Errorf("fail to query target domain %s", targetDomainId)
return nil, err
}
quota.Set("project_domain", jsonutils.NewString(domain.Name))