mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-29 13:57:33 +02:00
Merge pull request #9364 from wy65701436/fix-migration-rerun
fix quota migration still execute on launch even data sync success
This commit is contained in:
commit
64f7e3bc65
@ -85,17 +85,22 @@ func updateInitPassword(userID int, password string) error {
|
||||
|
||||
// Quota migration
|
||||
func quotaSync() error {
|
||||
usages, err := dao.ListQuotaUsages()
|
||||
if err != nil {
|
||||
log.Errorf("list quota usage error, %v", err)
|
||||
return err
|
||||
}
|
||||
projects, err := dao.GetProjects(nil)
|
||||
if err != nil {
|
||||
log.Errorf("list project error, %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
var pids []string
|
||||
for _, project := range projects {
|
||||
pids = append(pids, strconv.FormatInt(project.ProjectID, 10))
|
||||
}
|
||||
usages, err := dao.ListQuotaUsages(&models.QuotaUsageQuery{Reference: "project", ReferenceIDs: pids})
|
||||
if err != nil {
|
||||
log.Errorf("list quota usage error, %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// The condition handles these two cases:
|
||||
// 1, len(project) > 1 && len(usages) == 1. existing projects without usage, as we do always has 'library' usage in DB.
|
||||
// 2, migration fails at the phase of inserting usage into DB, and parts of them are inserted successfully.
|
||||
|
Loading…
Reference in New Issue
Block a user