-
Notifications
You must be signed in to change notification settings - Fork 458
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
Add environment variable option to set postgres ssl mode #2266
Conversation
9648254
to
3160836
Compare
@andreyvelich @anencore94 @johnugeorge Please help to review it if you are available, thanks a lot. |
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.
@ckcd Thank you for this contribution!
Generally lgtm
@kubeflow/wg-automl-leads Could you approve CI?
3160836
to
44783b1
Compare
@tenzen-y Thanks for your reply! I made some changes according to your comments. |
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.
Implementations are lgtm
dbName = "host=katib-postgres port=5432 user=katib password= dbname=katib sslmode=require" | ||
if getDbName() != dbName { | ||
t.Errorf("getDbName returns wrong value %v", getDbName()) | ||
} |
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.
cases := map[string]struct{
updateEnvs map[string]string
wantName string
}{
"All parameters are default": {
...
},
"Set KATIB_POSTGRESQL_SSL_MODE": {
...
}
}
for name, tc := range cases {
t.Run(name, func(t *testsing.T) {
// TEST
})
}
Please could you refine these tests?
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.
@tenzen-y Oh I got your point. I made the change based on your suggestion. And add more test cases for each env. Please help to review it. Thanks.
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.
@ckcd Thanks for your great refining! I'd be appreciated for your effort!
Also, this guide would be helpful for first time contributor: https://github.com/kubeflow/katib/blob/master/docs/developer-guide.md#go-development |
44783b1
to
47eadeb
Compare
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.
A few nits.
Otherwise lgtm
wantName string | ||
}{ | ||
"All parameters are default": { | ||
updateEnvs: map[string]string{}, |
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.
updateEnvs: map[string]string{}, |
I think this initialization isn't needed.
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.
Done, remove the initialization.
dbName = "host=katib-postgres port=5432 user=katib password= dbname=katib sslmode=require" | ||
if getDbName() != dbName { | ||
t.Errorf("getDbName returns wrong value %v", getDbName()) | ||
} |
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.
@ckcd Thanks for your great refining! I'd be appreciated for your effort!
if got := getDbName(); got != tc.wantName { | ||
t.Errorf("getDbName() = %v, want %v", got, tc.wantName) | ||
} |
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.
if got := getDbName(); got != tc.wantName { | |
t.Errorf("getDbName() = %v, want %v", got, tc.wantName) | |
} | |
gotName := getDbName() | |
if diff := cmp.Diff(tc.wantName, gotName); len(diff) != 0 { | |
t.Errorf("Unexpected DBName (-want,+got):\n%s", diff) | |
} | |
To improve visibility, we should use the cmp.Diff
.
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.
Sure, update to cmp.Diff
.
47eadeb
to
7fa4b3b
Compare
@tenzen-y thanks for your great suggestions! I rebase the code and made the changes. Please take a look, thanks. |
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 left a comment for a nit.
@@ -18,6 +18,7 @@ package postgres | |||
|
|||
import ( | |||
"fmt" | |||
"github.com/google/go-cmp/cmp" |
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.
"github.com/google/go-cmp/cmp" |
Could you move it to the third group? You can verify import orders to perform make lint on your local.
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.
Sure, update based on the lint.
@kubeflow/wg-automl-leads Could you approve CI? |
Signed-off-by: Kun Chang <[email protected]>
7fa4b3b
to
b04f811
Compare
@tenzen-y thanks, update based on the lint. |
@kubeflow/wg-automl-leads Could you approve CI? |
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.
Thank you!
/lgtm
/approve
/hold
to wait for approved CI from @kubeflow/wg-automl-leads
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ckcd, tenzen-y The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Thank you for making this improvement @ckcd!
Please can you submit PR to add this parameter to the Katib docs ?
https://www.kubeflow.org/docs/components/katib/env-variables/#katib-db-manager
/hold cancel |
@tenzen-y @andreyvelich thanks a lot for your great help! I will submit PR for the docs. |
What this PR does / why we need it:
In postgres,
sslmode
may has different value such asdisable
,prefer
andrequire
. But for now in postgres.go#L52 it only allowsdisable
. So we should add an environment variable option to allow users to specify the value ofsslmode
.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2244
Checklist:
(Need to update list of Environment Variables for Katib Components on Katib DB Manager. I will create additional pull request to address the change on website.)