From dd8c1ba023831e8d127ffc9369b73299fad241b4 Mon Sep 17 00:00:00 2001 From: BOOK Date: Sat, 16 Jan 2021 00:15:50 +0800 Subject: [PATCH] feat(controller): optional database migration (#4869) Signed-off-by: book987 --- config/config.go | 1 + docs/workflow-controller-configmap.yaml | 2 ++ workflow/controller/config.go | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index e4ab9b33aabf..d0cec26874ec 100644 --- a/config/config.go +++ b/config/config.go @@ -150,6 +150,7 @@ type PersistConfig struct { ConnectionPool *ConnectionPool `json:"connectionPool,omitempty"` PostgreSQL *PostgreSQLConfig `json:"postgresql,omitempty"` MySQL *MySQLConfig `json:"mysql,omitempty"` + SkipMigration bool `json:"skipMigration,omitempty"` } func (c PersistConfig) GetArchiveLabelSelector() (labels.Selector, error) { diff --git a/docs/workflow-controller-configmap.yaml b/docs/workflow-controller-configmap.yaml index 1a0921e7dafa..d5a190b15faa 100644 --- a/docs/workflow-controller-configmap.yaml +++ b/docs/workflow-controller-configmap.yaml @@ -179,6 +179,8 @@ data: archive: false # the number of days to keep archived workflows (the default is forever) archiveTTL: 180d + # skip database migration if needed. + # skipMigration: true # LabelSelector determines the workflow that matches with the matchlabels or matchrequirements, will be archived. # https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ diff --git a/workflow/controller/config.go b/workflow/controller/config.go index ff341acc5030..c05c08ef4eec 100644 --- a/workflow/controller/config.go +++ b/workflow/controller/config.go @@ -46,9 +46,13 @@ func (wfc *WorkflowController) updateConfig(v interface{}) error { return err } log.Info("Persistence Session created successfully") - err = sqldb.NewMigrate(session, persistence.GetClusterName(), tableName).Exec(context.Background()) - if err != nil { - return err + if !persistence.SkipMigration { + err = sqldb.NewMigrate(session, persistence.GetClusterName(), tableName).Exec(context.Background()) + if err != nil { + return err + } + } else { + log.Info("DB migration is disabled") } wfc.session = session