From 04c1554854b27141e3e4b94b31e0d30291802e2d Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Mon, 2 Oct 2023 11:38:29 +0200 Subject: [PATCH] Use database helpers from mariadb-operator/api The lib-common/modules/database is moved to mariadb-operator/api to remove a circular dependency. --- controllers/nova_controller.go | 29 ++++++++++++++--------------- go.mod | 3 ++- go.sum | 6 ++---- pkg/nova/common.go | 4 ++-- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/controllers/nova_controller.go b/controllers/nova_controller.go index 022cd3afb..6a55bac94 100644 --- a/controllers/nova_controller.go +++ b/controllers/nova_controller.go @@ -44,7 +44,6 @@ import ( common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" util "github.com/openstack-k8s-operators/lib-common/modules/common/util" - database "github.com/openstack-k8s-operators/lib-common/modules/database" novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1" "github.com/openstack-k8s-operators/nova-operator/pkg/nova" @@ -637,7 +636,7 @@ func (r *NovaReconciler) ensureDB( ctx context.Context, h *helper.Helper, instance *novav1.Nova, - db *database.Database, + db *mariadbv1.Database, databaseServiceName string, targetCondition condition.Type, ) (nova.DatabaseStatus, error) { @@ -669,8 +668,8 @@ func (r *NovaReconciler) ensureAPIDB( ctx context.Context, h *helper.Helper, instance *novav1.Nova, -) (*database.Database, nova.DatabaseStatus, error) { - apiDB := database.NewDatabaseWithNamespace( +) (*mariadbv1.Database, nova.DatabaseStatus, error) { + apiDB := mariadbv1.NewDatabaseWithNamespace( nova.NovaAPIDatabaseName, instance.Spec.APIDatabaseUser, instance.Spec.Secret, @@ -697,8 +696,8 @@ func (r *NovaReconciler) ensureCellDB( instance *novav1.Nova, cellName string, cellTemplate novav1.NovaCellTemplate, -) (*database.Database, nova.DatabaseStatus, error) { - cellDB := database.NewDatabaseWithNamespace( +) (*mariadbv1.Database, nova.DatabaseStatus, error) { + cellDB := mariadbv1.NewDatabaseWithNamespace( "nova_"+cellName, cellTemplate.CellDatabaseUser, instance.Spec.Secret, @@ -725,8 +724,8 @@ func (r *NovaReconciler) ensureCell( instance *novav1.Nova, cellName string, cellTemplate novav1.NovaCellTemplate, - cellDB *database.Database, - apiDB *database.Database, + cellDB *mariadbv1.Database, + apiDB *mariadbv1.Database, cellTransportURL string, keystoneAuthURL string, secret corev1.Secret, @@ -814,8 +813,8 @@ func (r *NovaReconciler) ensureAPI( h *helper.Helper, instance *novav1.Nova, cell0Template novav1.NovaCellTemplate, - cell0DB *database.Database, - apiDB *database.Database, + cell0DB *mariadbv1.Database, + apiDB *mariadbv1.Database, keystoneAuthURL string, secretName string, ) (ctrl.Result, error) { @@ -893,8 +892,8 @@ func (r *NovaReconciler) ensureScheduler( h *helper.Helper, instance *novav1.Nova, cell0Template novav1.NovaCellTemplate, - cell0DB *database.Database, - apiDB *database.Database, + cell0DB *mariadbv1.Database, + apiDB *mariadbv1.Database, keystoneAuthURL string, secretName string, ) (ctrl.Result, error) { @@ -1017,7 +1016,7 @@ func (r *NovaReconciler) ensureDBDeletion( } // iterate over novaDbs and remove finalizers for _, dbName := range novaDbs { - db, err := database.GetDatabaseByName(ctx, h, dbName) + db, err := mariadbv1.GetDatabaseByName(ctx, h, dbName) if err != nil && !k8s_errors.IsNotFound(err) { return err } @@ -1189,8 +1188,8 @@ func (r *NovaReconciler) ensureMetadata( h *helper.Helper, instance *novav1.Nova, cell0Template novav1.NovaCellTemplate, - cell0DB *database.Database, - apiDB *database.Database, + cell0DB *mariadbv1.Database, + apiDB *mariadbv1.Database, keystoneAuthURL string, secretName string, ) (ctrl.Result, error) { diff --git a/go.mod b/go.mod index 11b936bf0..8f38fe969 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ require ( github.com/openstack-k8s-operators/infra-operator/apis v0.1.1-0.20231001103054-f74a88ed4971 github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20231001084639-804f0f7cc39a github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166 - github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20231001084618-12369665b166 github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20231001084618-12369665b166 github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928152002-65395552e015 github.com/openstack-k8s-operators/nova-operator/api v0.0.0-20221209164002-f9e6b9363961 @@ -95,3 +94,5 @@ replace github.com/openshift/api => github.com/openshift/api v0.0.0-202304141430 // needed to to cert-manager v1.11.4 see https://github.com/cert-manager/cert-manager/blob/v1.11.4/go.mod#L263C1-L264C104 // remove this once we bump to cert-manager v1.12.x replace github.com/Venafi/vcert/v4 => github.com/jetstack/vcert/v4 v4.9.6-0.20230519122548-219f317ae107 //allow-merging + +replace github.com/openstack-k8s-operators/mariadb-operator/api => github.com/gibizer/mariadb-operator/api v0.0.0-20230929123006-6644f4172777 diff --git a/go.sum b/go.sum index 010c23d91..66cb457fc 100644 --- a/go.sum +++ b/go.sum @@ -82,6 +82,8 @@ github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gibizer/mariadb-operator/api v0.0.0-20230929123006-6644f4172777 h1:cfpxaGDO86bSB3IvuVXjgv2zYmC2wGTjZuYrz/RMQlM= +github.com/gibizer/mariadb-operator/api v0.0.0-20230929123006-6644f4172777/go.mod h1:xhiz5wFdKWwVM7BF/VYon4TT3NuUPXp/Pyn2hWcp0CE= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -242,14 +244,10 @@ github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20231001084639 github.com/openstack-k8s-operators/keystone-operator/api v0.1.1-0.20231001084639-804f0f7cc39a/go.mod h1:eE+xBfmNourpsLpJHVCWE/BaEExFFYCKXgZqnSpTxXo= github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166 h1:pZPl9njjTchHSFf2OSuzyRxrRW8LLb1OscPxVNoATrk= github.com/openstack-k8s-operators/lib-common/modules/common v0.1.1-0.20231001084618-12369665b166/go.mod h1:Ozg6SxfwOtMkiH553c0XQBWuygZQq4jDQCpR4hZqlxM= -github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20231001084618-12369665b166 h1:63I4+qBYwm0Q2txAZRfJ2TRo5HyBJwHxDYSpOr+jOOo= -github.com/openstack-k8s-operators/lib-common/modules/database v0.1.1-0.20231001084618-12369665b166/go.mod h1:RroLfB6Wstc+z7JVJY9o+6YPu+wBIzTAAfMpwhv7pDI= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20231001084618-12369665b166 h1:zOnRGMdgq2XvOCCtF1lY4tFhKx3jXrcrtOiZZ1PR6M8= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.1.1-0.20231001084618-12369665b166/go.mod h1:LOXXvTQCwhOBNd+0FTlgllpa3wqlkI6Vf3Q5QVRVPlw= github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20231001084618-12369665b166 h1:lh3WHM+3DcPlXK4I3QWHmvV+cPCy+dmiMdfImHF/Nqc= github.com/openstack-k8s-operators/lib-common/modules/test v0.1.2-0.20231001084618-12369665b166/go.mod h1:z/Plc5ef+C/lFZMTHGdOdoo04mimjXyqS9DZKxCzlXk= -github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928152002-65395552e015 h1:1G37nuB9C8QPp7tScEpwbR7eQj+2e6l089MNzj5cChk= -github.com/openstack-k8s-operators/mariadb-operator/api v0.1.1-0.20230928152002-65395552e015/go.mod h1:xhiz5wFdKWwVM7BF/VYon4TT3NuUPXp/Pyn2hWcp0CE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/pkg/nova/common.go b/pkg/nova/common.go index 17f283c4b..0b0ad6362 100644 --- a/pkg/nova/common.go +++ b/pkg/nova/common.go @@ -19,7 +19,7 @@ package nova import ( "fmt" - "github.com/openstack-k8s-operators/lib-common/modules/database" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) const ( @@ -94,7 +94,7 @@ const ( // Database - type Database struct { - Database *database.Database + Database *mariadbv1.Database Status DatabaseStatus }