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

dbaas: database management for mysql, pg #661

Merged

Conversation

tgrondier
Copy link
Member

@tgrondier tgrondier commented Jan 9, 2025

Description

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)

  • Changelog updated (under Unreleased block)
  • Testing

Testing

➜  ~/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                                                                                                                    │
┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼

@tgrondier tgrondier merged commit 52e8505 into master Jan 10, 2025
1 check passed
@tgrondier tgrondier deleted the tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database branch January 10, 2025 13:43
@tgrondier tgrondier restored the tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database branch January 13, 2025 09:14
@tgrondier tgrondier deleted the tgrondier/sc-114061/dbaas-support-for-mysql-posgres-database branch January 13, 2025 09:15
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.

2 participants