mirror of https://github.com/goharbor/harbor.git
fix: increase beego max memory and upload size (#19578)
1. Increase the default beego max memory and upload size from 32GB to 128GB. 2. Support customize the two beego configs from env. Signed-off-by: chlins <chenyuzh@vmware.com> Co-authored-by: Wang Yan <wangyan@vmware.com>
This commit is contained in:
parent
996e57b511
commit
553c85eed0
|
@ -231,4 +231,14 @@ const (
|
||||||
QuotaUpdateProvider = "quota_update_provider"
|
QuotaUpdateProvider = "quota_update_provider"
|
||||||
// IllegalCharsInUsername is the illegal chars in username
|
// IllegalCharsInUsername is the illegal chars in username
|
||||||
IllegalCharsInUsername = `,"~#%$`
|
IllegalCharsInUsername = `,"~#%$`
|
||||||
|
|
||||||
|
// Beego web config
|
||||||
|
// BeegoMaxMemoryBytes is the max memory(bytes) of the beego web config
|
||||||
|
BeegoMaxMemoryBytes = "beego_max_memory_bytes"
|
||||||
|
// DefaultBeegoMaxMemoryBytes sets default max memory to 128GB
|
||||||
|
DefaultBeegoMaxMemoryBytes = 1 << 37
|
||||||
|
// BeegoMaxUploadSizeBytes is the max upload size(bytes) of the beego web config
|
||||||
|
BeegoMaxUploadSizeBytes = "beego_max_upload_size_bytes"
|
||||||
|
// DefaultBeegoMaxUploadSizeBytes sets default max upload size to 128GB
|
||||||
|
DefaultBeegoMaxUploadSizeBytes = 1 << 37
|
||||||
)
|
)
|
||||||
|
|
|
@ -127,8 +127,6 @@ func main() {
|
||||||
|
|
||||||
web.BConfig.WebConfig.Session.SessionOn = true
|
web.BConfig.WebConfig.Session.SessionOn = true
|
||||||
web.BConfig.WebConfig.Session.SessionName = config.SessionCookieName
|
web.BConfig.WebConfig.Session.SessionName = config.SessionCookieName
|
||||||
web.BConfig.MaxMemory = 1 << 35 // (32GB)
|
|
||||||
web.BConfig.MaxUploadSize = 1 << 35 // (32GB)
|
|
||||||
// the core db used for beego session
|
// the core db used for beego session
|
||||||
redisCoreURL := os.Getenv("_REDIS_URL_CORE")
|
redisCoreURL := os.Getenv("_REDIS_URL_CORE")
|
||||||
if len(redisCoreURL) > 0 {
|
if len(redisCoreURL) > 0 {
|
||||||
|
@ -163,6 +161,12 @@ func main() {
|
||||||
log.Info("initializing configurations...")
|
log.Info("initializing configurations...")
|
||||||
config.Init()
|
config.Init()
|
||||||
log.Info("configurations initialization completed")
|
log.Info("configurations initialization completed")
|
||||||
|
|
||||||
|
// default beego max memory and max upload size is 128GB, consider from some AI related image would be large,
|
||||||
|
// also support customize it from the environment variables if the default value cannot satisfy some scenarios.
|
||||||
|
web.BConfig.MaxMemory = config.GetBeegoMaxMemoryBytes()
|
||||||
|
web.BConfig.MaxUploadSize = config.GetBeegoMaxUploadSizeBytes()
|
||||||
|
|
||||||
metricCfg := config.Metric()
|
metricCfg := config.Metric()
|
||||||
if metricCfg.Enabled {
|
if metricCfg.Enabled {
|
||||||
metric.RegisterCollectors()
|
metric.RegisterCollectors()
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
|
|
||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import "github.com/goharbor/harbor/src/common"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/goharbor/harbor/src/common"
|
||||||
|
)
|
||||||
|
|
||||||
// Item - Configure item include default value, type, env name
|
// Item - Configure item include default value, type, env name
|
||||||
type Item struct {
|
type Item struct {
|
||||||
|
@ -193,5 +197,8 @@ var (
|
||||||
|
|
||||||
{Name: common.BannerMessage, Scope: UserScope, Group: BasicGroup, EnvKey: "BANNER_MESSAGE", DefaultValue: "", ItemType: &StringType{}, Editable: true, Description: `The customized banner message for the UI`},
|
{Name: common.BannerMessage, Scope: UserScope, Group: BasicGroup, EnvKey: "BANNER_MESSAGE", DefaultValue: "", ItemType: &StringType{}, Editable: true, Description: `The customized banner message for the UI`},
|
||||||
{Name: common.QuotaUpdateProvider, Scope: SystemScope, Group: BasicGroup, EnvKey: "QUOTA_UPDATE_PROVIDER", DefaultValue: "db", ItemType: &StringType{}, Editable: false, Description: `The provider for updating quota, 'db' or 'redis' is supported`},
|
{Name: common.QuotaUpdateProvider, Scope: SystemScope, Group: BasicGroup, EnvKey: "QUOTA_UPDATE_PROVIDER", DefaultValue: "db", ItemType: &StringType{}, Editable: false, Description: `The provider for updating quota, 'db' or 'redis' is supported`},
|
||||||
|
|
||||||
|
{Name: common.BeegoMaxMemoryBytes, Scope: SystemScope, Group: BasicGroup, EnvKey: "BEEGO_MAX_MEMORY_BYTES", DefaultValue: fmt.Sprintf("%d", common.DefaultBeegoMaxMemoryBytes), ItemType: &Int64Type{}, Editable: false, Description: `The bytes for limiting the beego max memory, default is 128GB`},
|
||||||
|
{Name: common.BeegoMaxUploadSizeBytes, Scope: SystemScope, Group: BasicGroup, EnvKey: "BEEGO_MAX_UPLOAD_SIZE_BYTES", DefaultValue: fmt.Sprintf("%d", common.DefaultBeegoMaxUploadSizeBytes), ItemType: &Int64Type{}, Editable: false, Description: `The bytes for limiting the beego max upload size, default it 128GB`},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -132,6 +132,16 @@ func GetQuotaUpdateProvider() string {
|
||||||
return DefaultMgr().Get(backgroundCtx, common.QuotaUpdateProvider).GetString()
|
return DefaultMgr().Get(backgroundCtx, common.QuotaUpdateProvider).GetString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBeegoMaxMemoryBytes returns the max memory bytes of beego config
|
||||||
|
func GetBeegoMaxMemoryBytes() int64 {
|
||||||
|
return DefaultMgr().Get(backgroundCtx, common.BeegoMaxMemoryBytes).GetInt64()
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBeegoMaxUploadSizeBytes returns the max upload size bytes of beego config
|
||||||
|
func GetBeegoMaxUploadSizeBytes() int64 {
|
||||||
|
return DefaultMgr().Get(backgroundCtx, common.BeegoMaxUploadSizeBytes).GetInt64()
|
||||||
|
}
|
||||||
|
|
||||||
// WithTrivy returns a bool value to indicate if Harbor's deployed with Trivy.
|
// WithTrivy returns a bool value to indicate if Harbor's deployed with Trivy.
|
||||||
func WithTrivy() bool {
|
func WithTrivy() bool {
|
||||||
return DefaultMgr().Get(backgroundCtx, common.WithTrivy).GetBool()
|
return DefaultMgr().Get(backgroundCtx, common.WithTrivy).GetBool()
|
||||||
|
|
Loading…
Reference in New Issue