k3s-io / kine

Run Kubernetes on MySQL, Postgres, sqlite, dqlite, not etcd.
Apache License 2.0
1.67k stars 240 forks source link

cockroachdb: database is never created #150

Open dakraus opened 1 year ago

dakraus commented 1 year ago

In case CockroachDB is used as backend and KIND_ENDPOINT points at a non-existing database, the PostgreSQL driver does not create the corresponding database.

Steps to reproduce:

Reason: It seems that (at least in my local setup), the following code is causing this behavior:

https://github.com/k3s-io/kine/blob/aade54563c866c34e2cf6b8a58cf90e847f00d70/pkg/drivers/pgsql/pgsql.go#L133-L137

db.Ping() in this case returns nil instead of an error and therefore the following type assertion fails and nil is returned to the caller.

brandond commented 1 year ago

Hmm, so CockroachDB allows pinging a nonexistent DB. That seems like a problem, but I'm not quite sure how to handle it since we're just using the generic postgres driver, which cockroachdb claims to be compliant with.