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(db-manager): configurable DB name with extra params #1462

Closed
wants to merge 1 commit into from

Conversation

Subreptivus
Copy link

What this PR does / why we need it:

  • Demand non empty DB pass rather then hardcoded mysql DB name
  • No hardcoded mysql DB name
  • DB will be created if it not exists
  • Ability to provide extra params for DB connection, for example: "DB_EXTRA_PARAMS": "{\"tls\": \"true\"}" for secure connection

Special notes for your reviewer:
I may have left EnvVariables names as is, yet now it looks more cleaner, aligned with other names and less confusing

Release note:

Fully configurable external DB with ability to provide extra parameters with EnvVariable 'DB_EXTRA_PARAMS'

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Subreptivus
To complete the pull request process, please assign hougangliu after the PR has been reviewed.
You can assign the PR to them by writing /assign @hougangliu in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@aws-kf-ci-bot
Copy link
Contributor

Hi @Subreptivus. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@andreyvelich
Copy link
Member

Thanks a lot for doing this @Subreptivus!
Let's include your change in the next release after the Katib 0.11 for Kubeflow 1.3 release which should happen in this week.
I am not sure that we have enough time to test it before the Katib 0.11 release.

We are still working on the manifest refactoring for the Katib: #1464.
/ok-to-test

@andreyvelich
Copy link
Member

/hold for the review

@aws-kf-ci-bot
Copy link
Contributor

@Subreptivus: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
kubeflow-katib-presubmit 3e2d6fc link /test kubeflow-katib-presubmit

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Copy link
Member

@andreyvelich andreyvelich left a comment

Choose a reason for hiding this comment

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

@Subreptivus I apologies for waiting so long on this PR.
Since we finish our manifest refactoring, please can you rebase your PR ?

}
return nil, errors.New("Invalid DB Name")
func NewKatibDBInterface() (common.KatibDBInterface, error) {
return mysql.NewDBInterface()
Copy link
Member

Choose a reason for hiding this comment

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

In that logic how we can support other DB interfaces, like Postgres, MongoDB ?

@@ -8,8 +8,6 @@ spec:
containers:
- name: katib-db-manager
env:
- name: DB_NAME
value: mysql
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can introduce another env variable, like DB_TYPE: mysql, to define type of DB?

Comment on lines +76 to +77
dbPasswordEnvName := common.DBPasswordEnvName
dbPassword := os.Getenv(dbPasswordEnvName)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can omit dbPasswordEnvName var ?

Suggested change
dbPasswordEnvName := common.DBPasswordEnvName
dbPassword := os.Getenv(dbPasswordEnvName)
dbPassword := os.Getenv(common.DBPasswordEnvName)

return "", fmt.Errorf("Timeout waiting for DB conn successfully opened")
}
}
} else {
Copy link
Member

@andreyvelich andreyvelich Apr 22, 2021

Choose a reason for hiding this comment

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

Does the script reach this else since you verify an empty password here:

if dbPassword == "" {

case <-ticker.C:
if db, err := sql.Open(dbDriver, mysqlConfig.FormatDSN()); err == nil {
if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", dbName)); err == nil {
mysqlConfig.DBName = dbName
Copy link
Member

Choose a reason for hiding this comment

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

Do you need to set DBName here since you are doing this in the CreateMySQLConfig:

DBName: dbName,
?

@andreyvelich
Copy link
Member

@gaocegege @johnugeorge Please take a look at these changes.

@Subreptivus
Copy link
Author

@andreyvelich I'll answer here to all those comments above, because it falls into single answer.
First of all, I wanted to introduce as little changes as possible, that's why there so many quirks in the whole flow. So in few words, there were hardcoded values all over the places, for mysql type of the DB and for password, etc.
Yet if it has a value in it, I can refactor it to be more flexible and address all risen questions.

@andreyvelich
Copy link
Member

andreyvelich commented Apr 23, 2021

@andreyvelich I'll answer here to all those comments above, because it falls into single answer.
First of all, I wanted to introduce as little changes as possible, that's why there so many quirks in the whole flow. So in few words, there were hardcoded values all over the places, for mysql type of the DB and for password, etc.
Yet if it has a value in it, I can refactor it to be more flexible and address all risen questions.

I think the main problem is that DB_NAME env variable points to the DB Type currently.
And KATIB_MYSQL_DB_DATABASE env points to the Database name.
You can check the env variables definition here: https://www.kubeflow.org/docs/components/katib/env-variables/.
I agree that these naming is not clear.

As I point here: #1462 (comment), we probably should rename DB_NAME to DB_TYPE.

In any case, we should design Katib DB Manager to be able to support multiply DB backend, not only MySQL.

What do you think @gaocegege @johnugeorge ?

@stale
Copy link

stale bot commented Jul 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale
Copy link

stale bot commented Aug 21, 2021

This issue has been automatically closed because it has not had recent activity. Please comment "/reopen" to reopen it.

@stale stale bot closed this Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants