Merge pull request #13591 from heww/fix-issue-13387

fix(quota): ignore the fail when getting reference of quota
This commit is contained in:
stonezdj(Daojun Zhang) 2020-11-25 15:09:22 +08:00 committed by GitHub
commit 90c5505430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -5,6 +5,13 @@ Fixes issue https://github.com/goharbor/harbor/issues/13317
UPDATE role SET role_id=4 WHERE name='maintainer' AND role_id!=4;
UPDATE role SET role_id=5 WHERE name='limitedGuest' AND role_id!=5;
/*
Clean the dirty data in quota/quota_usage
Remove quota/quota_usage when the referenced project not exists
*/
DELETE FROM quota WHERE reference='project' AND reference_id::integer NOT IN (SELECT project_id FROM project WHERE deleted=FALSE);
DELETE FROM quota_usage WHERE reference='project' AND reference_id::integer NOT IN (SELECT project_id FROM project WHERE deleted=FALSE);
ALTER TABLE schedule ADD COLUMN IF NOT EXISTS cron_type varchar(64);
ALTER TABLE robot ADD COLUMN IF NOT EXISTS secret varchar(2048);

View File

@ -132,10 +132,11 @@ func (c *controller) assembleQuota(ctx context.Context, q *quota.Quota, opts *Op
ref, err := driver.Load(ctx, q.ReferenceID)
if err != nil {
return nil, err
log.G(ctx).Warningf("failed to load referenced %s object %s for quota %d, error %v",
q.Reference, q.ReferenceID, q.ID, err)
} else {
q.Ref = ref
}
q.Ref = ref
}
return q, nil