You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating or updating a grant sql provider always try to grant it for <selected-username>@%, instead of <selected-username>@<selected-host>. Which results in an Error 1410: You are not allowed to create a user with GRANT, as <selected-username>@% does not exists
2023-02-06T17:43:35.445964Z 24753 Connect root@minimal-cluster-haproxy-0.minimal-cluster-haproxy.mysql.svc.cluster.local on using SSL/TLS
2023-02-06T17:43:35.446276Z 24753 Query SHOW GRANTS FOR 'user-sample'@'localhost'
2023-02-06T17:43:35.446645Z 24753 Quit
2023-02-06T17:43:35.450194Z 24754 Connect root@minimal-cluster-haproxy-0.minimal-cluster-haproxy.mysql.svc.cluster.local on using SSL/TLS
2023-02-06T17:43:35.450413Z 24754 Query REVOKE ALL ON *.* FROM 'user-sample'@'localhost'
2023-02-06T17:43:35.459298Z 24754 Quit
2023-02-06T17:43:35.461147Z 24755 Connect root@minimal-cluster-haproxy-0.minimal-cluster-haproxy.mysql.svc.cluster.local on using SSL/TLS
2023-02-06T17:43:35.461270Z 24755 Query GRANT SELECT ON *.* TO 'user-sample'@'%'
username:=*cr.Spec.ForProvider.Userdbname:=defaultIdentifier(cr.Spec.ForProvider.Database)
table:=defaultIdentifier(cr.Spec.ForProvider.Table)
privileges:=strings.Join(cr.Spec.ForProvider.Privileges.ToStringSlice(), ", ")
username, host:=mysql.SplitUserHost(username) // username is now missing the host partquery:=fmt.Sprintf("REVOKE ALL ON %s.%s FROM %s@%s",
dbname,
table,
mysql.QuoteValue(username),
mysql.QuoteValue(host),
)
iferr:=c.db.Exec(ctx, xsql.Query{String: query}); err!=nil {
return managed.ExternalUpdate{}, errors.Wrap(err, errRevokeGrant)
}
query=createGrantQuery(privileges, dbname, username, table)
iferr:=c.db.Exec(ctx, xsql.Query{String: query}); err!=nil {
return managed.ExternalUpdate{}, err
}
Then in createGrantQuery function
funccreateGrantQuery(privileges, dbname, usernamestring, tablestring) string {
username, host:=mysql.SplitUserHost(username) // so here it will be defaulted to '%' instead of the requested hostresult:=fmt.Sprintf("GRANT %s ON %s.%s TO %s@%s",
privileges,
dbname,
table,
mysql.QuoteValue(username),
mysql.QuoteValue(host),
)
returnresult
}
How can we reproduce it?
Create a user with host: localhost (mind the annotation crossplane.io/external-name: user-sample@localhost)
alereca
changed the title
Grant
(Grant Error) update failed: Error 1410: You are not allowed to create a user with GRANT
Feb 6, 2023
alereca
changed the title
(Grant Error) update failed: Error 1410: You are not allowed to create a user with GRANT
(Grant Error) update failed: Error 1410: You are not allowed to create a user with GRANT; sqlprovider changes requested host to '%'
Feb 6, 2023
alereca
changed the title
(Grant Error) update failed: Error 1410: You are not allowed to create a user with GRANT; sqlprovider changes requested host to '%'
(Grant Error) update failed: Error 1410: You are not allowed to create a user with GRANT
Feb 6, 2023
What happened?
When creating or updating a grant sql provider always try to grant it for
<selected-username>
@%
, instead of<selected-username>
@<selected-host>
. Which results in anError 1410: You are not allowed to create a user with GRANT
, as<selected-username>
@%
does not existsThis bug seems to be caused by a variable resignation (username) in https://github.com/crossplane-contrib/provider-sql/blob/master/pkg/controller/mysql/grant/reconciler.go#L272,
Update
methodThen in
createGrantQuery
functionHow can we reproduce it?
Create a user with host: localhost (mind the annotation
crossplane.io/external-name: user-sample@localhost
)Then create a grant for that user
What environment did it happen in?
crossplane-1.9.1
crossplane/provider-sql:v0.6.0
I would like to work in a pr
The text was updated successfully, but these errors were encountered: