mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #3879 from swordqiu/hotfix/qj-keystone-project-resource-count-not-set
fix: keystone project resource count not set set to zero
This commit is contained in:
@@ -52,9 +52,7 @@ func getAllProjectResourceCounts() (map[string][]SProjectResourceCount, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getProjectResourceCount")
|
||||
}
|
||||
if len(resCnt) > 0 {
|
||||
ret[virtman.KeywordPlural()] = resCnt
|
||||
}
|
||||
ret[virtman.KeywordPlural()] = resCnt
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
|
||||
@@ -139,15 +139,18 @@ func syncProjectResourceCount(regionId string, serviceId string, projResCnt map[
|
||||
}
|
||||
|
||||
q := models.ProjectResourceManager.Query()
|
||||
q = q.NotIn("project_id", projList)
|
||||
if len(projList) > 0 {
|
||||
q = q.NotIn("project_id", projList)
|
||||
}
|
||||
q = q.Equals("region_id", regionId)
|
||||
q = q.Equals("service_id", serviceId)
|
||||
q = q.Equals("resource", res)
|
||||
q = q.NotEquals("count", 0)
|
||||
|
||||
emptySets := make([]models.SProjectResource, 0)
|
||||
err := db.FetchModelObjects(models.ProjectResourceManager, q, &emptySets)
|
||||
if err != nil {
|
||||
log.Errorf("db.FetchModelObjects")
|
||||
log.Errorf("db.FetchModelObjects %s", err)
|
||||
}
|
||||
|
||||
for i := range emptySets {
|
||||
@@ -156,7 +159,7 @@ func syncProjectResourceCount(regionId string, serviceId string, projResCnt map[
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("db.Update")
|
||||
log.Errorf("db.Update %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user