From fb220ffdcef3180250c8bfdd2f95fe94b14f8638 Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Wed, 28 Jun 2023 18:02:41 +0000 Subject: [PATCH 1/3] fix: Only create users in mysql 8.0 if they don't already exist This issue was breaking provisioning early in the process. The images for mysql57 and mysql80 start off with users already present for some reason. The old provisioning script for mysql 5.7 (provision.sql) uses implicit user creation via the `GRANT` statement, which is no longer supported in mysql 8.0. Therefore, the `CREATE USER` statements in provision-mysql80.sql fail. The fix here is to change to `CREATE USER IF NOT EXISTS`. I've also deleted `drop-mysql-user.sql`. I suspect it was only used during testing to enable repeated tests of provisioning, but it's not referenced anywhere in the PR that adds it (https://github.com/openedx/devstack/pull/1097). --- drop-mysql-user.sql | 11 ----------- provision-mysql80.sql | 21 +++++++++++++-------- 2 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 drop-mysql-user.sql diff --git a/drop-mysql-user.sql b/drop-mysql-user.sql deleted file mode 100644 index 0d5e52ca0f..0000000000 --- a/drop-mysql-user.sql +++ /dev/null @@ -1,11 +0,0 @@ -#docker-compose exec -T mysql80 bash -e -c "mysql -uroot mysql" < drop-mysql-user.sql -#docker exec -it edx.devstack.mysql80 mysql - -drop user 'credentials001'@'%'; -drop user 'discov001'@'%'; -drop user 'ecomm001'@'%'; -drop user 'notes001'@'%'; -drop user 'registrar001'@'%'; -drop user 'xqueue001'@'%'; -drop user 'analytics001'@'%'; -drop user 'edxapp001'@'%'; diff --git a/provision-mysql80.sql b/provision-mysql80.sql index cdcd48920b..6db7d7817b 100644 --- a/provision-mysql80.sql +++ b/provision-mysql80.sql @@ -1,29 +1,34 @@ +-- The use of `CREATE USER IF NOT EXISTS` is necessary due to the +-- mysql80 image already containing most or all of these users. It's +-- not clear why that is, but `IF NOT EXISTS` allows us to provision +-- in any case. + CREATE DATABASE IF NOT EXISTS credentials; -CREATE USER 'credentials001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'credentials001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON credentials.* TO 'credentials001'@'%'; CREATE DATABASE IF NOT EXISTS discovery; -CREATE USER 'discov001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'discov001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON discovery.* TO 'discov001'@'%'; CREATE DATABASE IF NOT EXISTS ecommerce; -CREATE USER 'ecomm001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'ecomm001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON ecommerce.* TO 'ecomm001'@'%'; CREATE DATABASE IF NOT EXISTS notes; -CREATE USER 'notes001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'notes001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON notes.* TO 'notes001'@'%'; CREATE DATABASE IF NOT EXISTS registrar; -CREATE USER 'registrar001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'registrar001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON registrar.* TO 'registrar001'@'%'; CREATE DATABASE IF NOT EXISTS xqueue; -CREATE USER 'xqueue001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'xqueue001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON xqueue.* TO 'xqueue001'@'%'; CREATE DATABASE IF NOT EXISTS `dashboard`; -CREATE USER 'analytics001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'analytics001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON `dashboard`.* TO 'analytics001'@'%'; CREATE DATABASE IF NOT EXISTS `analytics-api`; @@ -37,7 +42,7 @@ GRANT ALL ON `reports_v1`.* TO 'analytics001'@'%'; CREATE DATABASE IF NOT EXISTS edxapp; CREATE DATABASE IF NOT EXISTS edxapp_csmh; -CREATE USER 'edxapp001'@'%' IDENTIFIED BY 'password'; +CREATE USER IF NOT EXISTS 'edxapp001'@'%' IDENTIFIED BY 'password'; GRANT ALL ON edxapp.* TO 'edxapp001'@'%'; GRANT ALL ON edxapp_csmh.* TO 'edxapp001'@'%'; From fe99ec56e31dec46e166ce3a988fa67bdf45cdfd Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Wed, 28 Jun 2023 19:43:14 +0000 Subject: [PATCH 2/3] fixup! More correct comments re: volumes --- Makefile | 2 +- provision-mysql80.sql | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index b2d826ff97..e8ebe4fa35 100644 --- a/Makefile +++ b/Makefile @@ -496,7 +496,7 @@ dev.reset: dev.remove-containers dev.reset-repos dev.prune dev.pull.large-and-sl dev.destroy.coursegraph: dev.remove-containers.coursegraph ## Remove all coursegraph data. docker volume rm ${COMPOSE_PROJECT_NAME}_coursegraph_data -dev.destroy: ## Irreversibly remove all devstack-related containers, networks, and volumes. +dev.destroy: ## Irreversibly remove all devstack-related containers and networks (though not data volumes) $(WINPTY) bash ./destroy.sh ######################################################################################## diff --git a/provision-mysql80.sql b/provision-mysql80.sql index 6db7d7817b..19b32e0ebd 100644 --- a/provision-mysql80.sql +++ b/provision-mysql80.sql @@ -1,7 +1,6 @@ --- The use of `CREATE USER IF NOT EXISTS` is necessary due to the --- mysql80 image already containing most or all of these users. It's --- not clear why that is, but `IF NOT EXISTS` allows us to provision --- in any case. +-- The use of `CREATE USER IF NOT EXISTS` is necessary since the +-- mysql80_data volume may already contain these users due to previous +-- provisioning https://github.com/openedx/devstack/issues/1113 CREATE DATABASE IF NOT EXISTS credentials; CREATE USER IF NOT EXISTS 'credentials001'@'%' IDENTIFIED BY 'password'; From ce6eadc4c0f30b0ff910c5059409f39212d9019c Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Wed, 28 Jun 2023 19:47:17 +0000 Subject: [PATCH 3/3] fixup! Link ticket here as well --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index e8ebe4fa35..ab342031f2 100644 --- a/Makefile +++ b/Makefile @@ -496,6 +496,7 @@ dev.reset: dev.remove-containers dev.reset-repos dev.prune dev.pull.large-and-sl dev.destroy.coursegraph: dev.remove-containers.coursegraph ## Remove all coursegraph data. docker volume rm ${COMPOSE_PROJECT_NAME}_coursegraph_data +# See https://github.com/openedx/devstack/issues/1113 for lack of ability to destroy data volumes dev.destroy: ## Irreversibly remove all devstack-related containers and networks (though not data volumes) $(WINPTY) bash ./destroy.sh