Skip to content

Commit 273cc63

Browse files
authored
fix: prevent dsn format bugs when adding tls mode in mysql (kubeflow#1265)
Signed-off-by: Alessio Pragliola <[email protected]>
1 parent 4e4447a commit 273cc63

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/datastore/embedmd/mysql/connect.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"time"
66

77
"github.com/go-sql-driver/mysql"
8-
_tls "github.com/kubeflow/model-registry/internal/tls"
98
"github.com/golang/glog"
9+
_tls "github.com/kubeflow/model-registry/internal/tls"
1010
gorm_mysql "gorm.io/driver/mysql"
1111
"gorm.io/gorm"
1212
"gorm.io/gorm/logger"
@@ -42,7 +42,14 @@ func (c *MySQLDBConnector) Connect() (*gorm.DB, error) {
4242
return nil, err
4343
}
4444

45-
c.DSN += "&tls=custom"
45+
cfg, err := mysql.ParseDSN(c.DSN)
46+
if err != nil {
47+
return nil, fmt.Errorf("failed to parse DSN: %w", err)
48+
}
49+
50+
cfg.TLSConfig = "custom"
51+
52+
c.DSN = cfg.FormatDSN()
4653
}
4754

4855
for i := range mysqlMaxRetries {

0 commit comments

Comments
 (0)