From 595ab4bdecd57844120f401af4797d4be09698ca Mon Sep 17 00:00:00 2001 From: Cheng Wang Date: Thu, 7 Sep 2023 01:37:30 +0800 Subject: [PATCH] chore: Update workflow controller initDB func (#11760) Signed-off-by: astraw99 --- workflow/controller/config.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/workflow/controller/config.go b/workflow/controller/config.go index 01713877eb72..61529a70dffd 100644 --- a/workflow/controller/config.go +++ b/workflow/controller/config.go @@ -41,7 +41,6 @@ func (wfc *WorkflowController) updateConfig() error { return err } log.Info("Persistence Session created successfully") - wfc.session = session } sqldb.ConfigureDBSession(wfc.session, persistence.ConnectionPool) @@ -85,22 +84,16 @@ func (wfc *WorkflowController) updateConfig() error { // initDB inits argo DB tables func (wfc *WorkflowController) initDB() error { persistence := wfc.Config.Persistence - if persistence != nil { - tableName, err := sqldb.GetTableName(persistence) - if err != nil { - return err - } - if !persistence.SkipMigration { - err = sqldb.NewMigrate(wfc.session, persistence.GetClusterName(), tableName).Exec(context.Background()) - if err != nil { - return err - } - } else { - log.Info("DB migration is disabled") - } + if persistence == nil || persistence.SkipMigration { + log.Info("DB migration is disabled") + return nil + } + tableName, err := sqldb.GetTableName(persistence) + if err != nil { + return err } - return nil + return sqldb.NewMigrate(wfc.session, persistence.GetClusterName(), tableName).Exec(context.Background()) } func (wfc *WorkflowController) newRateLimiter() *rate.Limiter {