harbor icon indicating copy to clipboard operation
harbor copied to clipboard

bypass redis related settings when core is started with "migrate" mode

Open danielzhanghl opened this issue 2 years ago • 2 comments

Hi, currently when core is running in migrate mode, it still needs to connect with redis at the beginning of process init, actually, redis is not needed for this mode, could add some check during the init. to bypass the redis related code? then the configuration for the pre-upgrade job will be simpler. thanks.

====== https://github.com/goharbor/harbor/blob/main/src/core/main.go

redisURL := os.Getenv("_REDIS_URL_CORE")
if len(redisURL) > 0 {
	u, err := url.Parse(redisURL)
	if err != nil {
		panic("bad _REDIS_URL")
	}

	beego.BConfig.WebConfig.Session.SessionProvider = session.HarborProviderName
	beego.BConfig.WebConfig.Session.SessionProviderConfig = redisURL

	log.Info("initializing cache ...")
	if err := cache.Initialize(u.Scheme, redisURL); err != nil {
		log.Fatalf("failed to initialize cache: %v", err)
	}
	// when config/db init function is called, the cache is not ready,
	// enable config cache explicitly when the cache is ready
	dbCfg.EnableConfigCache()
}

.... if strings.EqualFold(*runMode, "migrate") { // Used by Harbor helm preinstall, preupgrade hook container if err = migration.Migrate(database); err != nil { log.Fatalf("failed to migrate the database, error: %v", err) } log.Info("the database migrate success") os.Exit(0) }

danielzhanghl avatar Jul 20 '22 07:07 danielzhanghl

hi, any plan for this enhancement? thanks.

danielzhanghl avatar Jul 28 '22 01:07 danielzhanghl

Yes, Init the redis works after the if else block of run mode

stonezdj avatar Aug 02 '22 04:08 stonezdj

hi, which release will the enhancement be available ? thanks.

danielzhanghl avatar Aug 31 '22 06:08 danielzhanghl

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

github-actions[bot] avatar Oct 30 '22 09:10 github-actions[bot]

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

github-actions[bot] avatar Jan 01 '23 09:01 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. If this issue is still relevant, please re-open a new issue.

github-actions[bot] avatar Jan 31 '23 09:01 github-actions[bot]