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

dbName with slash doesn't work #2152

Closed
lucasfcnunes opened this issue Sep 17, 2024 · 7 comments · Fixed by #2190
Closed

dbName with slash doesn't work #2152

lucasfcnunes opened this issue Sep 17, 2024 · 7 comments · Fixed by #2190
Labels

Comments

@lucasfcnunes
Copy link

lucasfcnunes commented Sep 17, 2024

What happened?

Trying to use as dbName in the DSN:

  • vcluster/dev
# ...
syncer 2024-09-17 22:51:36    INFO    commandwriter/commandwriter.go:126    Starting k3s v1.30.2+k3s1 (aa4794b3)    {"component": "vcluster", "component": "k3s", "time": "2024-09-17T22:51:36Z", "level": "info"}
syncer 2024-09-17 22:51:36    INFO    commandwriter/commandwriter.go:126    starting kubernetes: preparing server: creating storage endpoint: building kine: invalid DSN: did you forget to escape a param value?    {"component": "vcluster", "component": "k3s", "time": "2024-09-17T22:51:36Z", "level": "fatal"}
syncer 2024-09-17 22:51:36    INFO    setup/initialize.go:165    Error running k3s: exit status 1    {"component": "vcluster"}
  • vcluster%2Fdev
# ...
syncer 2024-09-17 23:25:13    INFO    commandwriter/commandwriter.go:126    Starting k3s v1.30.2+k3s1 (aa4794b3)    {"component": "vcluster", "component": "k3s", "time": "2024-09-17T23:25:13Z", "level": "info"}
syncer 2024-09-17 23:25:13    INFO    commandwriter/commandwriter.go:126    failed to check existence of database vcluster%2Fdev, going to attempt create: Error 1049 (HY000): database not found: vcluster%2Fdev    {"component": "vcluster", "component": "k3s", "time": "2024-09-17T23:25:13Z", "level": "warning"}
syncer 2024-09-17 23:25:13    INFO    commandwriter/commandwriter.go:126    starting kubernetes: preparing server: creating storage endpoint: building kine: Error 1105 (HY000): syntax error at position 40 near 'vcluster'    {"component": "vcluster", "component": "k3s", "time": "2024-09-17T23:25:13Z", "level": "fatal"}
syncer 2024-09-17 23:25:13    INFO    setup/initialize.go:165    Error running k3s: exit status 1    {"component": "vcluster"}

What did you expect to happen?

I expected to see Vcluster creating and using the database/schema with a slash in its name.

How can we reproduce it (as minimally and precisely as possible)?

  1. docker run --rm -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:8.0.33
controlPlane:
  distro:
    k3s:
      enabled: true
  backingStore:
    database:
      external:
        enabled: true
        dataSource: mysql://root:root@tcp(localhost:3306)/vcluster/dev
        # OR
        # dataSource: mysql://root:root@tcp(localhost:3306)/vcluster%2Fdev
  1. Get the error

--
PS: MySQL does support the following DDL:

create database `vcluster/dev`;

Anything else we need to know?

Host cluster Kubernetes version

$ kubectl version
Client Version: v1.31.0
Kustomize Version: v5.4.2
Server Version: v1.30.3-gke.1639000

vcluster version

$ vcluster --version
vcluster version 0.20.0

VCluster Config

controlPlane:
  distro:
    k3s:
      enabled: true
  backingStore:
    database:
      external:
        enabled: true
        dataSource: mysql://root:root@tcp(localhost:3306)/vcluster/dev
        # OR
        # dataSource: mysql://root:root@tcp(localhost:3306)/vcluster%2Fdev
@mayooot
Copy link
Contributor

mayooot commented Sep 19, 2024

@lucasfcnunes I spent an afternoon trying to verify this issue, and try to change k3s.go but to no avail.

Finally I noticed that the version of go-sql-driver used by k3s is v1.17, go.mod but theschema/branch mode needs to use v1.8.0.

I tried to submit a pr to k3s to upgrade the go-sql-driver version, after which vcluster should be back to normal.

@lucasfcnunes
Copy link
Author

@mayooot, I noticed that operators in dbName weren't being scaped too so k3s-io/kine#322 seems to be needed too.

Copy link
Contributor

If those get fixed in k3s, let us know what version it's fixed in and then we can get the latest versions of k3s and kine and we can then update it.

Have you tried using the default vanilla k8s version? Or is there a specific reason why you must run k3s?

@FabianKramm
Copy link
Member

@lucasfcnunes seems like we only need to update kine now to make this work. I'll create a PR for this.

@lucasfcnunes
Copy link
Author

@lucasfcnunes
Copy link
Author

Have you tried using the default vanilla k8s version? Or is there a specific reason why you must run k3s?

@deniseschannon
I will take some time try the default one. I'm assuming k3s will be faster and use less resources to bootstrap that's why I'm going for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants