Skip to content

Commit 13cf73b

Browse files
committed
refactor by reviews
1 parent d12e632 commit 13cf73b

File tree

9 files changed

+27
-31
lines changed

9 files changed

+27
-31
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ update:
5959

6060
# Deploy Katib v1beta1 manifests using Kustomize into a k8s cluster.
6161
deploy:
62-
bash scripts/v1beta1/deploy.sh
62+
bash scripts/v1beta1/deploy.sh $(WITH_DATABASE_TYPE)
6363

6464
# Undeploy Katib v1beta1 manifests using Kustomize from a k8s cluster
6565
undeploy:

manifests/v1beta1/components/postgres/postgres.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
spec:
2323
containers:
2424
- name: katib-postgres
25-
image: postgres:14.3-alpine
25+
image: postgres:14.5-alpine
2626
envFrom:
2727
- secretRef:
2828
name: katib-postgres-secrets

manifests/v1beta1/installs/katib-standalone-postgres/kustomization.yaml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,10 @@ images:
3232
- name: docker.io/kubeflowkatib/cert-generator
3333
newName: docker.io/kubeflowkatib/cert-generator
3434
newTag: latest
35-
patches:
36-
- patch: |-
37-
- op: replace
38-
path: /spec/template/spec/containers/0/env
39-
value:
40-
- name: DB_NAME
41-
value: "postgres"
42-
- name: DB_PASSWORD
43-
value: "katib"
44-
target:
35+
patchesJson6902:
36+
- target:
37+
group: apps
38+
version: v1
4539
kind: Deployment
46-
labelSelector: "katib.kubeflow.org/component=db-manager"
40+
name: katib-db-manager
41+
path: ./patches/db-manager.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- op: replace
3+
path: /spec/template/spec/containers/0/env
4+
value:
5+
- name: DB_NAME
6+
value: "postgres"
7+
- name: DB_PASSWORD
8+
value: "katib"

pkg/db/v1beta1/common/connection.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ func OpenSQLConn(driverName string, dataSourceName string, interval time.Duratio
3434
select {
3535
case <-ticker.C:
3636
if db, err := sql.Open(driverName, dataSourceName); err == nil {
37-
// if db, err := sql.Open(driverName, dataSourceName); err == nil {
3837
if err = db.Ping(); err == nil {
3938
return db, nil
4039
}

pkg/db/v1beta1/common/const.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ limitations under the License.
1616

1717
package common
1818

19+
import "time"
20+
1921
const (
22+
ConnectInterval = 5 * time.Second
23+
ConnectTimeout = 60 * time.Second
24+
2025
DBUserEnvName = "DB_USER"
2126
DBNameEnvName = "DB_NAME"
2227
DBPasswordEnvName = "DB_PASSWORD"

pkg/db/v1beta1/mysql/mysql.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ const (
3838
//dbNameTmpl = "root:%s@tcp(%s:%s)/%s?timeout=5s"
3939
dbNameTmpl = "%s:%s@tcp(%s:%s)/%s?timeout=5s"
4040
mysqlTimeFmt = "2006-01-02 15:04:05.999999"
41-
42-
connectInterval = 5 * time.Second
43-
connectTimeout = 60 * time.Second
4441
)
4542

4643
type dbConn struct {
@@ -77,7 +74,7 @@ func NewWithSQLConn(db *sql.DB) (common.KatibDBInterface, error) {
7774
}
7875

7976
func NewDBInterface() (common.KatibDBInterface, error) {
80-
db, err := common.OpenSQLConn(dbDriver, getDbName(), connectInterval, connectTimeout)
77+
db, err := common.OpenSQLConn(dbDriver, getDbName(), common.ConnectInterval, common.ConnectTimeout)
8178
if err != nil {
8279
return nil, fmt.Errorf("DB open failed: %v", err)
8380
}

pkg/db/v1beta1/postgres/postgres.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ import (
3333
"k8s.io/klog"
3434
)
3535

36-
const (
37-
dbDriver = "postgres"
38-
39-
connectInterval = 5 * time.Second
40-
connectTimeout = 60 * time.Second
41-
)
36+
const dbDriver = "postgres"
4237

4338
type dbConn struct {
4439
db *sql.DB
@@ -65,7 +60,7 @@ func getDbName() string {
6560
}
6661

6762
func NewDBInterface() (common.KatibDBInterface, error) {
68-
db, err := common.OpenSQLConn(dbDriver, getDbName(), connectInterval, connectTimeout)
63+
db, err := common.OpenSQLConn(dbDriver, getDbName(), common.ConnectInterval, common.ConnectTimeout)
6964
if err != nil {
7065
return nil, fmt.Errorf("DB open failed: %v", err)
7166
}
@@ -160,7 +155,7 @@ func (d *dbConn) GetObservationLog(trialName string, metricName string, startTim
160155
formattedEndTime := e_time.UTC().Format(time.RFC3339Nano)
161156
qstr += fmt.Sprintf(" AND time <= $%d", index_of_qparam)
162157
qfield = append(qfield, formattedEndTime)
163-
// index_of_qparam += 1
158+
// index_of_qparam += 1 // if any other filters are added, this should be incremented
164159
}
165160

166161
rows, err := d.db.Query(base_stmt+qstr+" ORDER BY time", qfield...)

test/e2e/v1beta1/scripts/gh-actions/setup-katib.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,14 @@ if "$DEPLOY_TRAINING_OPERATOR"; then
6262
fi
6363

6464
echo "Deploying Katib"
65-
cd ../../../../../ && bash scripts/v1beta1/deploy.sh "$WITH_DATABASE_TYPE" && cd -
65+
cd ../../../../../ && WITH_DATABASE_TYPE=$WITH_DATABASE_TYPE make deploy && cd -
6666

6767
# Wait until all Katib pods is running.
6868
TIMEOUT=120s
6969
kubectl wait --for=condition=complete --timeout=${TIMEOUT} -l katib.kubeflow.org/component=cert-generator -n kubeflow job ||
7070
(kubectl get pods -n kubeflow && kubectl describe pods -n kubeflow && exit 1)
7171

72-
kubectl wait --for=condition=ready --timeout=${TIMEOUT} -l "katib.kubeflow.org/component in ($WITH_DATABASE_TYPE)" -n kubeflow pod ||
73-
(kubectl get pods -n kubeflow && kubectl describe pods -n kubeflow && exit 1)
74-
75-
kubectl wait --for=condition=ready --timeout=${TIMEOUT} -l "katib.kubeflow.org/component in (controller,db-manager,ui)" -n kubeflow pod ||
72+
kubectl wait --for=condition=ready --timeout=${TIMEOUT} -l "katib.kubeflow.org/component in ($WITH_DATABASE_TYPE,controller,db-manager,ui)" -n kubeflow pod ||
7673
(kubectl get pods -n kubeflow && kubectl describe pods -n kubeflow && exit 1)
7774

7875
# Wait until all Katib pods is actually ready.

0 commit comments

Comments
 (0)