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

[MM-61280] disable init data if providing external database #870

Merged
merged 5 commits into from
Dec 16, 2024

Conversation

fmartingr
Copy link
Contributor

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

@fmartingr fmartingr added the 2: Dev Review Requires review by a core committer label Dec 11, 2024
@fmartingr fmartingr self-assigned this Dec 11, 2024
@@ -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 != ""
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Member

@agarciamontoro agarciamontoro Dec 12, 2024

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

Suggested change
initData := config.DBDumpURI == "" || config.ExternalDBSettings.DataSource != ""
initData := config.DBDumpURI == "" && config.ExternalDBSettings.DataSource == ""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks better 👍

Copy link
Contributor

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.

Copy link
Contributor Author

@fmartingr fmartingr Dec 13, 2024

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]>
@fmartingr fmartingr requested a review from streamer45 December 12, 2024 15:57
@fmartingr fmartingr requested a review from streamer45 December 13, 2024 11:05
@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo

Suggested change
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")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3fcdec4

Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fmartingr fmartingr merged commit a20d94b into master Dec 16, 2024
1 check passed
@fmartingr fmartingr deleted the fix/initdb-external branch December 16, 2024 07:00
@fmartingr fmartingr removed the 2: Dev Review Requires review by a core committer label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants