mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-05 18:20:37 +01:00
fix quota sync read only setting
Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
6045a69457
commit
19a37282c1
@ -21,15 +21,12 @@ import (
|
|||||||
"github.com/goharbor/harbor/src/common/models"
|
"github.com/goharbor/harbor/src/common/models"
|
||||||
common_quota "github.com/goharbor/harbor/src/common/quota"
|
common_quota "github.com/goharbor/harbor/src/common/quota"
|
||||||
"github.com/goharbor/harbor/src/common/utils/log"
|
"github.com/goharbor/harbor/src/common/utils/log"
|
||||||
|
|
||||||
"github.com/goharbor/harbor/src/core/config"
|
"github.com/goharbor/harbor/src/core/config"
|
||||||
"github.com/goharbor/harbor/src/jobservice/logger"
|
"github.com/goharbor/harbor/src/jobservice/logger"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
quota "github.com/goharbor/harbor/src/core/api/quota"
|
quota "github.com/goharbor/harbor/src/core/api/quota"
|
||||||
|
|
||||||
comcfg "github.com/goharbor/harbor/src/common/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// InternalAPI handles request of harbor admin...
|
// InternalAPI handles request of harbor admin...
|
||||||
@ -157,16 +154,16 @@ func (ia *InternalAPI) ensureQuota() error {
|
|||||||
// SyncQuota ...
|
// SyncQuota ...
|
||||||
func (ia *InternalAPI) SyncQuota() {
|
func (ia *InternalAPI) SyncQuota() {
|
||||||
cur := config.ReadOnly()
|
cur := config.ReadOnly()
|
||||||
cfgMgr := comcfg.NewDBCfgManager()
|
cfgMgr := config.GetCfgManager()
|
||||||
if cur != true {
|
if !cur {
|
||||||
cfgMgr.Set(common.ReadOnly, true)
|
cfgMgr.Set(common.ReadOnly, true)
|
||||||
|
cfgMgr.Save()
|
||||||
}
|
}
|
||||||
// For api call, to avoid the timeout, it should be asynchronous
|
// For api call, to avoid the timeout, it should be asynchronous
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if cur != true {
|
cfgMgr.Set(common.ReadOnly, cur)
|
||||||
cfgMgr.Set(common.ReadOnly, false)
|
cfgMgr.Save()
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
log.Info("start to sync quota(API), the system will be set to ReadOnly and back it normal once it done.")
|
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)
|
err := quota.Sync(ia.ProjectMgr, false)
|
||||||
|
Loading…
Reference in New Issue
Block a user