Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(controller): optional database migration #4869

Merged
merged 1 commit into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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