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

resolve the delete issue of mysqluser and psqluser #1151

Merged
merged 4 commits into from
Jun 10, 2020

Conversation

buhongw7583c
Copy link
Contributor

Closes #1142

What this PR does / why we need it:
If the username is empty in the spec of mysqluser.yaml and postgresqluser.yaml file, the user could not be successfully deleted from database.

Special notes for your reviewer:

  1. Issue with mysqluser:
    Before the change, apply the below yaml file, that an entry with user name 'mysqluser-sample-hong1' will be created .
apiVersion: azure.microsoft.com/v1alpha1
kind: MySQLUser
metadata:
  name: mysqluser-sample-hong1
spec:
  server: mysqlserver-sample3
  dbName: mysqldatabase-sample
  resourceGroup: resourcegroup-azure-operators
  roles: 
  #now only supports to grant privileges to a new user, the privileges could be one or more of the below
  #SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, 
  #CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, 
  #CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
  # This adds the privileges to the specified database
    - SELECT
  # Specify a specific username for the user
  # username: mysqluser-sample
  # Specify adminSecret and adminSecretKeyVault if you want to 
  # read the MYSQL server admin creds from a specific keyvault secret
  # adminSecret: mysqlserver-sample
  # adminSecretKeyVault: asokeyvault

image

Use kubectl delete mysqluser, the user instance was deleted from cli but still in the database.
After the change, delete the mysqluser will be successful from both cli and database.

  1. Issue with postgresqluser:

Before the change, apply the yaml file without specify the username.

apiVersion: azure.microsoft.com/v1alpha1
kind: PostgreSQLUser
metadata:
  name: psqluser-sample
spec:
  server: postgresqlserver-hongsample1
  dbName: postgresqldatabase-sample
  resourceGroup: resourcegroup-azure-operators
  # The Azure Database for PostgreSQL server is created with the 3 default roles defined.
  # azure_pg_admin
  # azure_superuser
  # your server admin user
  roles:
    - "azure_pg_admin"
   # Specify a specific username for the user
  # username: psqluser-sample
  # Specify adminSecret and adminSecretKeyVault if you want to 
  # read the PSQL server admin creds from a specific keyvault secret
  # adminSecret: postgresqlserver-sample
  # adminSecretKeyVault: asokeyvault

Delete the user instance from cli, but the user still in the database.

image

After the change, delete operation will delete the user both from cli and database.

How does this PR make you feel:
gif

If applicable:

  • this PR contains documentation
  • this PR contains tests

@buhongw7583c
Copy link
Contributor Author

Have tested the code change on AKS cluster using helm chart deployment. The MySQLuser and PostgresqlUser could be added/deleted without issue or error throw out.

Copy link
Contributor

@jananivMS jananivMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. tested the changes and worked well.

@buhongw7583c buhongw7583c merged commit 4a66dfd into Azure:master Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Operator should successfully delete MySqlUser if KeyVault is not attached
3 participants