Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbaas: database management for mysql, pg (#661)
# Description <!-- * Prefix: the title with the component name being changed. Add a short and self describing sentence to ease the review * Please add a few lines providing context and describing the change * Please self comment changes whenever applicable to help with the review process * Please keep the checklist as part of the PR. Tick what applies to this change. --> Allows users to use the CLI to directly automate database creation for selected services Also includes a few check before creating users for DBAAS service to verify if the service is ready to accept user creation ## Checklist (For exoscale contributors) * [x] Changelog updated (under *Unreleased* block) * [x] Testing ## Testing <!-- Describe the tests you did --> ``` ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas create pg hobbyist-2 test-pg 25-01-09 12:18 ✔ Creating Database Service "test-pg"... 0s ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ DATABASE SERVICE │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ Zone │ de-muc-1 │ │ Name │ test-pg │ │ Type │ pg │ │ Plan │ hobbyist-2 │ │ Disk Size │ 8.0 GiB │ │ State │ rebuilding │ │ Creation Date │ 2025-01-09 11:18:44 +0000 UTC │ │ Update Date │ 2025-01-09 11:18:44 +0000 UTC │ │ Nodes │ 1 │ │ Node CPUs │ 2 │ │ Node Memory │ 2.0 GiB │ │ Termination Protected │ true │ │ Maintenance │ saturday (02:51:27) │ │ Version │ 16 │ │ Backup Schedule │ 10:51 │ │ URI │ postgres://avnadmin:xxxxx@test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699/defaultdb?sslmode=require │ │ IP Filter │ │ │ Components │ │ │ │ pgbouncer test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21700 route:dynamic usage:primary │ │ │ pg test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699 route:dynamic usage:primary │ │ │ │ │ Users │ n/a │ │ Databases │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas create mysql hobbyist-2 test 25-01-09 12:18 ✔ Creating Database Service "test"... 1s ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ DATABASE SERVICE │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ Zone │ de-muc-1 │ │ Name │ test │ │ Type │ mysql │ │ Plan │ hobbyist-2 │ │ Disk Size │ 8.0 GiB │ │ State │ rebuilding │ │ Creation Date │ 2025-01-09 11:18:51 +0000 UTC │ │ Update Date │ 2025-01-09 11:18:51 +0000 UTC │ │ Nodes │ 1 │ │ Node CPUs │ 2 │ │ Node Memory │ 2.0 GiB │ │ Termination Protected │ true │ │ Maintenance │ sunday (02:45:14) │ │ Version │ 8 │ │ Backup Schedule │ 15:17 │ │ URI │ mysql://avnadmin:xxxxx@test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699/defaultdb?ssl-mode=REQUIRED │ │ IP Filter │ │ │ Components │ │ │ │ mysqlx test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21703 route:dynamic usage:primary │ │ │ mysql test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699 route:dynamic usage:primary │ │ │ │ │ Users │ n/a │ │ Databases │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) exo dbaas delete test -f 25-01-09 12:18 ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database create test-pg blz 25-01-09 12:18 error: service "test-pg" is not ready for database creation exit status 1 ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database create test blz 25-01-09 12:19 error: service "test" is not ready for database creation exit status 1 ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database create test-pg blz 25-01-09 12:19 ✔ Creating DBaaS database "blz" 0s ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ DATABASE SERVICE │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ Zone │ de-muc-1 │ │ Name │ test-pg │ │ Type │ pg │ │ Plan │ hobbyist-2 │ │ Disk Size │ 8.0 GiB │ │ State │ running │ │ Creation Date │ 2025-01-09 11:18:44 +0000 UTC │ │ Update Date │ 2025-01-09 11:21:03 +0000 UTC │ │ Nodes │ 1 │ │ Node CPUs │ 2 │ │ Node Memory │ 2.0 GiB │ │ Termination Protected │ true │ │ Maintenance │ saturday (02:51:27) │ │ Version │ 16.6 │ │ Backup Schedule │ 10:51 │ │ URI │ postgres://avnadmin:xxxxx@test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699/defaultdb?sslmode=require │ │ IP Filter │ │ │ Components │ │ │ │ pgbouncer test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21700 route:dynamic usage:primary │ │ │ pg test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699 route:dynamic usage:primary │ │ │ │ │ Users │ avnadmin (primary) │ │ Databases │ blz │ │ │ defaultdb │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database create test-pg blz 25-01-09 12:21 error: CreateDBAASPGDatabase: http response: Conflict: Service database 'blz' already exists exit status 1 ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database delete test-pg blz 25-01-09 12:21 [+] Are you sure you want to delete database "blz" [yN]: y ✔ Deleting DBaaS database "blz" 0s ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ DATABASE SERVICE │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ Zone │ de-muc-1 │ │ Name │ test-pg │ │ Type │ pg │ │ Plan │ hobbyist-2 │ │ Disk Size │ 8.0 GiB │ │ State │ running │ │ Creation Date │ 2025-01-09 11:18:44 +0000 UTC │ │ Update Date │ 2025-01-09 11:21:17 +0000 UTC │ │ Nodes │ 1 │ │ Node CPUs │ 2 │ │ Node Memory │ 2.0 GiB │ │ Termination Protected │ true │ │ Maintenance │ saturday (02:51:27) │ │ Version │ 16.6 │ │ Backup Schedule │ 10:51 │ │ URI │ postgres://avnadmin:xxxxx@test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699/defaultdb?sslmode=require │ │ IP Filter │ │ │ Components │ │ │ │ pgbouncer test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21700 route:dynamic usage:primary │ │ │ pg test-pg-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699 route:dynamic usage:primary │ │ │ │ │ Users │ avnadmin (primary) │ │ Databases │ defaultdb │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database create test blz 25-01-09 12:21 ✔ Creating DBaaS database "blz" 0s ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ DATABASE SERVICE │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ Zone │ de-muc-1 │ │ Name │ test │ │ Type │ mysql │ │ Plan │ hobbyist-2 │ │ Disk Size │ 8.0 GiB │ │ State │ running │ │ Creation Date │ 2025-01-09 11:18:51 +0000 UTC │ │ Update Date │ 2025-01-09 11:21:22 +0000 UTC │ │ Nodes │ 1 │ │ Node CPUs │ 2 │ │ Node Memory │ 2.0 GiB │ │ Termination Protected │ true │ │ Maintenance │ sunday (02:45:14) │ │ Version │ 8.0.30 │ │ Backup Schedule │ 15:17 │ │ URI │ mysql://avnadmin:xxxxx@test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699/defaultdb?ssl-mode=REQUIRED │ │ IP Filter │ │ │ Components │ │ │ │ mysqlx test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21703 route:dynamic usage:primary │ │ │ mysql test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699 route:dynamic usage:primary │ │ │ │ │ Users │ avnadmin (primary) │ │ Databases │ blz │ │ │ defaultdb │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database delete test-pg blz -f 25-01-09 12:21 error: database "blz" not found for service "test-pg" exit status 1 ➜ ~/exo/cli git:(tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database) go run . dbaas database delete test blz -f 25-01-09 12:21 ✔ Deleting DBaaS database "blz" 0s ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ DATABASE SERVICE │ │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ │ Zone │ de-muc-1 │ │ Name │ test │ │ Type │ mysql │ │ Plan │ hobbyist-2 │ │ Disk Size │ 8.0 GiB │ │ State │ running │ │ Creation Date │ 2025-01-09 11:18:51 +0000 UTC │ │ Update Date │ 2025-01-09 11:21:32 +0000 UTC │ │ Nodes │ 1 │ │ Node CPUs │ 2 │ │ Node Memory │ 2.0 GiB │ │ Termination Protected │ true │ │ Maintenance │ sunday (02:45:14) │ │ Version │ 8.0.30 │ │ Backup Schedule │ 15:17 │ │ URI │ mysql://avnadmin:xxxxx@test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699/defaultdb?ssl-mode=REQUIRED │ │ IP Filter │ │ │ Components │ │ │ │ mysqlx test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21703 route:dynamic usage:primary │ │ │ mysql test-exoscale-6b703a50-10bb-400c-bd87-2cd1ad11d7f9.h.aivencloud.com:21699 route:dynamic usage:primary │ │ │ │ │ Users │ avnadmin (primary) │ │ Databases │ defaultdb │ ┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼ ```
- Loading branch information