Skip to content

Commit

Permalink
feat(controller): optional database migration
Browse files Browse the repository at this point in the history
Signed-off-by: book987 <book78987book@gmail.com>
  • Loading branch information
book987 committed Jan 15, 2021
1 parent a8e9348 commit 34498cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions docs/workflow-controller-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
10 changes: 7 additions & 3 deletions workflow/controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34498cd

Please sign in to comment.