From 19a37282c1248f6373c17a6d1b58a7eae43b334a Mon Sep 17 00:00:00 2001 From: wang yan Date: Wed, 28 Aug 2019 14:29:39 +0800 Subject: [PATCH] fix quota sync read only setting Signed-off-by: wang yan --- src/core/api/internal.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/core/api/internal.go b/src/core/api/internal.go index 06e6c45a26..b7c7e3138c 100644 --- a/src/core/api/internal.go +++ b/src/core/api/internal.go @@ -21,15 +21,12 @@ import ( "github.com/goharbor/harbor/src/common/models" common_quota "github.com/goharbor/harbor/src/common/quota" "github.com/goharbor/harbor/src/common/utils/log" - "github.com/goharbor/harbor/src/core/config" "github.com/goharbor/harbor/src/jobservice/logger" "github.com/pkg/errors" "strconv" quota "github.com/goharbor/harbor/src/core/api/quota" - - comcfg "github.com/goharbor/harbor/src/common/config" ) // InternalAPI handles request of harbor admin... @@ -157,16 +154,16 @@ func (ia *InternalAPI) ensureQuota() error { // SyncQuota ... func (ia *InternalAPI) SyncQuota() { cur := config.ReadOnly() - cfgMgr := comcfg.NewDBCfgManager() - if cur != true { + cfgMgr := config.GetCfgManager() + if !cur { cfgMgr.Set(common.ReadOnly, true) + cfgMgr.Save() } // For api call, to avoid the timeout, it should be asynchronous go func() { defer func() { - if cur != true { - cfgMgr.Set(common.ReadOnly, false) - } + cfgMgr.Set(common.ReadOnly, cur) + cfgMgr.Save() }() log.Info("start to sync quota(API), the system will be set to ReadOnly and back it normal once it done.") err := quota.Sync(ia.ProjectMgr, false)