-
Notifications
You must be signed in to change notification settings - Fork 42
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
[MM-61280] disable init data if providing external database #870
Conversation
cmd/ltctl/main.go
Outdated
@@ -34,7 +34,7 @@ func RunCreateCmdF(cmd *cobra.Command, args []string) error { | |||
return fmt.Errorf("failed to create SSH agent: %w", err) | |||
} | |||
|
|||
initData := config.DBDumpURI == "" | |||
initData := config.DBDumpURI == "" || config.ExternalDBSettings.DataSource != "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if this should be an invalid case at the config level. Does having both defined make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because it will try to upload the dump to the database using the TerraformDBSettings
credentials and getting the database URL from terraform's output DBWriter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this either. With this change, if both DBDumpURI
and DataSource
are non-empty, initData
is true, right? Shouldn't this be
initData := config.DBDumpURI == "" || config.ExternalDBSettings.DataSource != "" | |
initData := config.DBDumpURI == "" && config.ExternalDBSettings.DataSource == "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still welcome an addition to func (c *Config) IsValid()
if having both set is a clear invalid case to avoid unexpected side effects. Not blocking though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather do it now than forget later: 9aa44f4
Co-authored-by: Alejandro García Montoro <[email protected]>
…t-load-test-ng into fix/initdb-external
deployment/config.go
Outdated
@@ -398,6 +398,10 @@ func (c *Config) IsValid() error { | |||
return fmt.Errorf("load-test download url is not in correct format: %q", c.LoadTestDownloadURL) | |||
} | |||
|
|||
if c.ExternalDBSettings.DataSource != "" && c.DBDumpURI != "" { | |||
return errors.New("both ExternalDBSettings.DataSource and DbdumpURI are set, only one can be set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typo
return errors.New("both ExternalDBSettings.DataSource and DbdumpURI are set, only one can be set") | |
return errors.New("both ExternalDBSettings.DataSource and DBDumpURI are set, only one can be set") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3fcdec4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary
Avoid running the database initialization commands if providing an external database since the
IngestDump
only works for terraform created databases. External databases are usually already populated and ready to use as they come from backups.Ticket Link
https://mattermost.atlassian.net/browse/MM-61280