From c46d7e856aa700e481142a8238dd7cc8cf331208 Mon Sep 17 00:00:00 2001 From: wang yan Date: Wed, 30 Oct 2019 16:24:17 +0800 Subject: [PATCH] add a switcher for quota sync on core launch As the quota sync is default called by harbor-core on every launch, and it will break the launch process if any failure throwed. 1, The commit is to provide an switcher for the system admin to bypass the quota sync. 2, In case Harbor goes into the restarting cycle. Harbor already provides an internal API to sync quota data, in the failure case, system admin can launch harbor and call the /api/internal/syncquota to sync quota. Signed-off-by: wang yan --- make/photon/prepare/templates/core/env.jinja | 1 + src/core/main.go | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/make/photon/prepare/templates/core/env.jinja b/make/photon/prepare/templates/core/env.jinja index 0c2393605c..19a8e6da67 100644 --- a/make/photon/prepare/templates/core/env.jinja +++ b/make/photon/prepare/templates/core/env.jinja @@ -2,6 +2,7 @@ CONFIG_PATH=/etc/core/app.conf UAA_CA_ROOT=/etc/core/certificates/uaa_ca.pem _REDIS_URL={{redis_host}}:{{redis_port}},100,{{redis_password}} SYNC_REGISTRY=false +SYNC_QUOTA=true CHART_CACHE_DRIVER={{chart_cache_driver}} _REDIS_URL_REG={{redis_url_reg}} diff --git a/src/core/main.go b/src/core/main.go index 2d32c2d57b..82467fcfc4 100755 --- a/src/core/main.go +++ b/src/core/main.go @@ -271,8 +271,18 @@ func main() { log.Fatalf("init proxy error, %v", err) } - if err := quotaSync(); err != nil { - log.Fatalf("quota migration error, %v", err) + syncQuota := os.Getenv("SYNC_QUOTA") + doSyncQuota, err := strconv.ParseBool(syncQuota) + if err != nil { + log.Errorf("Failed to parse SYNC_QUOTA: %v", err) + doSyncQuota = true + } + if doSyncQuota { + if err := quotaSync(); err != nil { + log.Fatalf("quota migration error, %v", err) + } + } else { + log.Infof("Because SYNC_QUOTA set false , no need to sync quota \n") } beego.Run()