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

panic: unexpected empty query -- when creating MySQLUser #719

Open
Jille opened this issue Aug 23, 2021 · 1 comment · May be fixed by #913
Open

panic: unexpected empty query -- when creating MySQLUser #719

Jille opened this issue Aug 23, 2021 · 1 comment · May be fixed by #913
Labels

Comments

@Jille
Copy link

Jille commented Aug 23, 2021

I'm running v0.5.0-rc.3. Kubernetes v1.22.1.

I0823 17:42:45.308510       1 leaderelection.go:253] successfully acquired lease default/mysql-operator-leader-election
I0823 17:42:45.309807       1 controller.go:165] controller-runtime/manager/controller/mysqlbackup-controller "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"clusterName":""},"status":{}}}
I0823 17:42:45.329396       1 controller.go:165] controller-runtime/manager/controller/mysqlbackupcron-controller "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"secretName":"","podSpec":{"resources":{},"metricsExporterResources":{},"mysqlOperatorSidecarResources":{}},"volumeSpec":{}},"status":{}}}
I0823 17:42:45.329505       1 controller.go:173] controller-runtime/manager/controller/mysqlbackupcron-controller "msg"="Starting Controller"
I0823 17:42:45.331297       1 controller.go:165] controller-runtime/manager/controller/mysql-database "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"clusterRef":{},"database":""},"status":{}}}
I0823 17:42:45.331393       1 controller.go:173] controller-runtime/manager/controller/mysql-database "msg"="Starting Controller"
I0823 17:42:45.333977       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"secretName":"","podSpec":{"resources":{},"metricsExporterResources":{},"mysqlOperatorSidecarResources":{}},"volumeSpec":{}},"status":{}}}
I0823 17:42:45.339183       1 controller.go:165] controller-runtime/manager/controller/mysql-user "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"clusterRef":{},"user":"","password":{"key":""},"allowedHosts":null},"status":{}}}
I0823 17:42:45.349979       1 controller.go:173] controller-runtime/manager/controller/mysql-user "msg"="Starting Controller"
I0823 17:42:45.375800       1 controller.go:165] controller-runtime/manager/controller/controller.orchestrator "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"secretName":"","podSpec":{"resources":{},"metricsExporterResources":{},"mysqlOperatorSidecarResources":{}},"volumeSpec":{}},"status":{}}}
I0823 17:42:45.376635       1 controller.go:165] controller-runtime/manager/controller/controller.orchestrator "msg"="Starting EventSource"  "source"=
I0823 17:42:45.376740       1 controller.go:173] controller-runtime/manager/controller/controller.orchestrator "msg"="Starting Controller"
I0823 17:42:45.382496       1 controller.go:165] controller-runtime/manager/controller/mysqlbackup-controller "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":null}}},"status":{}}}
I0823 17:42:45.385483       1 controller.go:173] controller-runtime/manager/controller/mysqlbackup-controller "msg"="Starting Controller"
I0823 17:42:45.383409       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlNode "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"containers":null},"status":{}}}
I0823 17:42:45.383452       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{"selector":null,"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":null}},"serviceName":"","updateStrategy":{}},"status":{"replicas":0}}}
I0823 17:42:45.387639       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{},"status":{"loadBalancer":{}}}}
I0823 17:42:45.387830       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null}}}
I0823 17:42:45.388159       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null},"spec":{},"status":{"disruptionsAllowed":0,"currentHealthy":0,"desiredHealthy":0,"expectedPods":0}}}
I0823 17:42:45.392633       1 controller.go:165] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting EventSource"  "source"={"Type":{"metadata":{"creationTimestamp":null}}}
I0823 17:42:45.392844       1 controller.go:173] controller-runtime/manager/controller/controller.mysqlcluster "msg"="Starting Controller"
I0823 17:42:45.388389       1 controller.go:173] controller-runtime/manager/controller/controller.mysqlNode "msg"="Starting Controller"
I0823 17:42:45.418877       1 warning_handler.go:65] KubeAPIWarningLogger "msg"="policy/v1beta1 PodDisruptionBudget is deprecated in v1.21+, unavailable in v1.25+; use policy/v1 PodDisruptionBudget"
I0823 17:42:45.488413       1 controller.go:207] controller-runtime/manager/controller/controller.orchestrator "msg"="Starting workers"  "worker count"=10
I0823 17:42:45.488428       1 controller.go:207] controller-runtime/manager/controller/mysqlbackup-controller "msg"="Starting workers"  "worker count"=1
I0823 17:42:45.488483       1 controller.go:207] controller-runtime/manager/controller/mysql-user "msg"="Starting workers"  "worker count"=1
I0823 17:42:45.488789       1 controller.go:207] controller-runtime/manager/controller/controller.mysqlNode "msg"="Starting workers"  "worker count"=1
I0823 17:42:45.488872       1 deleg.go:130] controller.mysql-user "msg"="creating mysql user"  "cluster"={"Namespace":"hosting-vvszaalrooster","Name":"mysql-cluster"} "key"={"Namespace":"hosting-vvszaalrooster","Name":"vvszaalrooster-mysql-user"} "username"="vvszaalrooster"
panic: unexpected empty query

goroutine 475 [running]:
github.com/presslabs/mysql-operator/pkg/internal/mysql.NewQuery(...)
	/go/src/github.com/presslabs/mysql-operator/pkg/internal/mysql/query.go:43
github.com/presslabs/mysql-operator/pkg/internal/mysql.ConcatenateQueries(0xc00062d7a8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/go/src/github.com/presslabs/mysql-operator/pkg/internal/mysql/query.go:72 +0x4ac
github.com/presslabs/mysql-operator/pkg/internal/mysql.permissionsToQuery(0xc0002986c0, 0x1, 0x1, 0xc000417510, 0xe, 0xc0007c93c0, 0x1, 0x1, 0x0, 0x0, ...)
	/go/src/github.com/presslabs/mysql-operator/pkg/internal/mysql/user.go:141 +0xe5
github.com/presslabs/mysql-operator/pkg/internal/mysql.CreateUserIfNotExists(0x1ac3ab8, 0xc00059d770, 0x1ab6460, 0xc000506018, 0xc000417510, 0xe, 0xc0009e6bd0, 0x11, 0xc0007c93c0, 0x1, ...)
	/go/src/github.com/presslabs/mysql-operator/pkg/internal/mysql/user.go:46 +0x3ce
github.com/presslabs/mysql-operator/pkg/controller/mysqluser.(*ReconcileMySQLUser).reconcileUserInDB(0xc000508a40, 0x1ac3ab8, 0xc00059d770, 0xc00062dda8, 0x0, 0x0)
	/go/src/github.com/presslabs/mysql-operator/pkg/controller/mysqluser/mysqluser_controller.go:184 +0x5bb
github.com/presslabs/mysql-operator/pkg/controller/mysqluser.(*ReconcileMySQLUser).reconcileUserInCluster(0xc000508a40, 0x1ac3ab8, 0xc00059d770, 0xc00062dda8, 0x0, 0x0)
	/go/src/github.com/presslabs/mysql-operator/pkg/controller/mysqluser/mysqluser_controller.go:137 +0xaa
github.com/presslabs/mysql-operator/pkg/controller/mysqluser.(*ReconcileMySQLUser).Reconcile(0xc000508a40, 0x1ac3ab8, 0xc00059d770, 0xc00037d4e8, 0x16, 0xc0003e7cc0, 0x19, 0xc00059d770, 0xc000030000, 0x17750e0, ...)
	/go/src/github.com/presslabs/mysql-operator/pkg/controller/mysqluser/mysqluser_controller.go:101 +0x1c5
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc000303360, 0x1ac3a10, 0xc000298580, 0x1739580, 0xc00021e200)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:298 +0x30d
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc000303360, 0x1ac3a10, 0xc000298580, 0x196a900)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:253 +0x205
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2(0xc00055dc10, 0xc000303360, 0x1ac3a10, 0xc000298580)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:214 +0x6b
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:210 +0x425

I just (re)added:

apiVersion: mysql.presslabs.org/v1alpha1
kind: MysqlUser
metadata:
  name: vvszaalrooster-mysql-user
  namespace: hosting-vvszaalrooster
spec:
  allowedHosts: ["10.%"]
  clusterRef:
    name: "mysql-cluster"
    namespace: hosting-vvszaalrooster
  user: "vvszaalrooster"
  password:
    name: "mysql-user-secret"
    key: "password"
  permissions:
    - permissions: ["ALL PRIVILEGES"]
      schema: "vvszaalrooster"
      tables: []
@nick4fake
Copy link

I have the same problem. Looks like you need to put "*" as a table name:
https://github.com/bitpoke/mysql-operator/blob/master/pkg/internal/mysql/user.go#L121

The other question is why operator panics for such trivial problems

@usernameisnull usernameisnull linked a pull request Jan 29, 2024 that will close this issue
1 task
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.

3 participants