fix: quota-list fail if deleted projects found

This commit is contained in:
Qiu Jian
2019-08-26 18:12:53 +08:00
parent 17d3a38c73
commit 264be68045
+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))