From e0f576e3cbc31ea41d13ed1e4b38bae620cff6c0 Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Mon, 26 Feb 2024 15:11:40 +0100 Subject: [PATCH] [tlse] TLS database connection The my.cnf file gets added to the secret holding the service configs. The content of my.cnf is centrally managed in the mariadb-operator and retrieved calling db.GetDatabaseClientConfig(tlsCfg) Depends-On: https://github.com/openstack-k8s-operators/mariadb-operator/pull/190 Depends-On: https://github.com/openstack-k8s-operators/mariadb-operator/pull/191 Jira: OSPRH-4547 --- controllers/manila_controller.go | 154 +++++++++++------- controllers/manilaapi_controller.go | 15 +- controllers/manilascheduler_controller.go | 15 +- controllers/manilashare_controller.go | 15 +- go.mod | 2 +- go.sum | 4 +- pkg/manila/volumes.go | 9 +- test/functional/manila_controller_test.go | 31 +++- test/functional/manila_test_data.go | 6 + test/functional/manilaapi_controller_test.go | 12 +- .../manilascheduler_controller_test.go | 12 +- .../functional/manilashare_controller_test.go | 12 +- 12 files changed, 210 insertions(+), 77 deletions(-) diff --git a/controllers/manila_controller.go b/controllers/manila_controller.go index 95fd8a49..1c39cb9b 100644 --- a/controllers/manila_controller.go +++ b/controllers/manila_controller.go @@ -38,6 +38,7 @@ import ( common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" "github.com/openstack-k8s-operators/lib-common/modules/common/secret" "github.com/openstack-k8s-operators/lib-common/modules/common/service" + "github.com/openstack-k8s-operators/lib-common/modules/common/tls" "github.com/openstack-k8s-operators/lib-common/modules/common/util" manilav1beta1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" "github.com/openstack-k8s-operators/manila-operator/pkg/manila" @@ -335,7 +336,7 @@ func (r *ManilaReconciler) reconcileDelete(ctx context.Context, instance *manila r.Log.Info(fmt.Sprintf("Reconciling Service '%s' delete", instance.Name)) // remove db finalizer first - db, err := mariadbv1.GetDatabaseByName(ctx, helper, instance.Name) + db, err := mariadbv1.GetDatabaseByName(ctx, helper, manila.DatabaseName) if err != nil && !k8s_errors.IsNotFound(err) { return ctrl.Result{}, err } @@ -362,65 +363,9 @@ func (r *ManilaReconciler) reconcileInit( ) (ctrl.Result, error) { r.Log.Info(fmt.Sprintf("Reconciling Service '%s' init", instance.Name)) - // - // create service DB instance - // - db := mariadbv1.NewDatabase( - instance.Name, - instance.Spec.DatabaseUser, - instance.Spec.Secret, - map[string]string{ - "dbName": instance.Spec.DatabaseInstance, - }, - ) - // create or patch the DB - ctrlResult, err := db.CreateOrPatchDB( - ctx, - helper, - ) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.DBReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - if (ctrlResult != ctrl.Result{}) { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DBReadyRunningMessage)) - return ctrlResult, nil - } - // wait for the DB to be setup - ctrlResult, err = db.WaitForDBCreated(ctx, helper) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.DBReadyErrorMessage, - err.Error())) - return ctrlResult, err - } - if (ctrlResult != ctrl.Result{}) { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DBReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DBReadyRunningMessage)) - return ctrlResult, nil - } - // update Status.DatabaseHostname, used to config the service - instance.Status.DatabaseHostname = db.GetDatabaseHostname() - instance.Status.Conditions.MarkTrue(condition.DBReadyCondition, condition.DBReadyMessage) - + // TODO: why here? // when job passed, mark NetworkAttachmentsReadyCondition ready instance.Status.Conditions.MarkTrue(condition.NetworkAttachmentsReadyCondition, condition.NetworkAttachmentsReadyMessage) - // create service DB - end // // run manila db sync @@ -434,7 +379,7 @@ func (r *ManilaReconciler) reconcileInit( time.Duration(5)*time.Second, dbSyncHash, ) - ctrlResult, err = dbSyncjob.DoJob( + ctrlResult, err := dbSyncjob.DoJob( ctx, helper, ) @@ -590,6 +535,17 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage) // run check OpenStack secret - end + // + // create service DB instance + // + db, result, err := r.ensureDB(ctx, helper, instance) + if err != nil { + return ctrl.Result{}, err + } else if (result != ctrl.Result{}) { + return result, nil + } + // create service DB - end + // // Create ConfigMaps and Secrets required as input for the Service and calculate an overall hash of hashes // @@ -602,7 +558,7 @@ func (r *ManilaReconciler) reconcileNormal(ctx context.Context, instance *manila // - %-config configmap holding minimal manila config required to get the service up, user can add additional files to be added to the service // - parameters which has passwords gets added from the OpenStack secret via the init container // - err = r.generateServiceConfig(ctx, helper, instance, &configVars, serviceLabels, memcached) + err = r.generateServiceConfig(ctx, helper, instance, &configVars, serviceLabels, memcached, db) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( condition.ServiceConfigReadyCondition, @@ -843,6 +799,7 @@ func (r *ManilaReconciler) generateServiceConfig( envVars *map[string]env.Setter, serviceLabels map[string]string, memcached *memcachedv1.Memcached, + db *mariadbv1.Database, ) error { // // create Secret required for manila input @@ -853,10 +810,18 @@ func (r *ManilaReconciler) generateServiceConfig( labels := labels.GetLabels(instance, labels.GetGroupLabel(manila.ServiceName), serviceLabels) + var tlsCfg *tls.Service + if instance.Spec.ManilaAPI.TLS.Ca.CaBundleSecretName != "" { + tlsCfg = &tls.Service{} + } + // customData hold any customization for the service. // custom.conf is going to /etc//.conf.d // all other files get placed into /etc/ to allow overwrite of e.g. policy.json - customData := map[string]string{manila.CustomConfigFileName: instance.Spec.CustomServiceConfig} + customData := map[string]string{ + manila.CustomConfigFileName: instance.Spec.CustomServiceConfig, + "my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf + } keystoneAPI, err := keystonev1.GetKeystoneAPI(ctx, h, instance.Namespace, map[string]string{}) if err != nil { @@ -1105,3 +1070,70 @@ func (r *ManilaReconciler) getManilaMemcached( } return memcached, err } + +func (r *ManilaReconciler) ensureDB( + ctx context.Context, + h *helper.Helper, + instance *manilav1beta1.Manila, +) (*mariadbv1.Database, ctrl.Result, error) { + // + // create service DB instance + // + db := mariadbv1.NewDatabase( + manila.DatabaseName, + instance.Spec.DatabaseUser, + instance.Spec.Secret, + map[string]string{ + "dbName": instance.Spec.DatabaseInstance, + }, + ) + + // create or patch the DB + ctrlResult, err := db.CreateOrPatchDBByName( + ctx, + h, + instance.Spec.DatabaseInstance, + ) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.DBReadyErrorMessage, + err.Error())) + return db, ctrl.Result{}, err + } + if (ctrlResult != ctrl.Result{}) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.DBReadyRunningMessage)) + return db, ctrlResult, nil + } + // wait for the DB to be setup + // (ksambor) should we use WaitForDBCreatedWithTimeout instead? + ctrlResult, err = db.WaitForDBCreated(ctx, h) + if err != nil { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.ErrorReason, + condition.SeverityWarning, + condition.DBReadyErrorMessage, + err.Error())) + return db, ctrlResult, err + } + if (ctrlResult != ctrl.Result{}) { + instance.Status.Conditions.Set(condition.FalseCondition( + condition.DBReadyCondition, + condition.RequestedReason, + condition.SeverityInfo, + condition.DBReadyRunningMessage)) + return db, ctrlResult, nil + } + + // update Status.DatabaseHostname, used to config the service + instance.Status.DatabaseHostname = db.GetDatabaseHostname() + instance.Status.Conditions.MarkTrue(condition.DBReadyCondition, condition.DBReadyMessage) + return db, ctrlResult, nil +} diff --git a/controllers/manilaapi_controller.go b/controllers/manilaapi_controller.go index 97eab858..93d2edcb 100644 --- a/controllers/manilaapi_controller.go +++ b/controllers/manilaapi_controller.go @@ -50,6 +50,7 @@ import ( manilav1beta1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" "github.com/openstack-k8s-operators/manila-operator/pkg/manila" manilaapi "github.com/openstack-k8s-operators/manila-operator/pkg/manilaapi" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" k8s_errors "k8s.io/apimachinery/pkg/api/errors" @@ -940,8 +941,20 @@ func (r *ManilaAPIReconciler) generateServiceConfig( labels := labels.GetLabels(instance, labels.GetGroupLabel(manila.ServiceName), serviceLabels) + db, err := mariadbv1.GetDatabaseByName(ctx, h, manila.DatabaseName) + if err != nil { + return err + } + var tlsCfg *tls.Service + if instance.Spec.TLS.CaBundleSecretName != "" { + tlsCfg = &tls.Service{} + } + // customData hold any customization for the service. - customData := map[string]string{manila.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig} + customData := map[string]string{ + manila.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig, + "my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf + } customData[manila.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig diff --git a/controllers/manilascheduler_controller.go b/controllers/manilascheduler_controller.go index 3028d09b..79b0a781 100644 --- a/controllers/manilascheduler_controller.go +++ b/controllers/manilascheduler_controller.go @@ -51,6 +51,7 @@ import ( manilav1beta1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" "github.com/openstack-k8s-operators/manila-operator/pkg/manila" manilascheduler "github.com/openstack-k8s-operators/manila-operator/pkg/manilascheduler" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -646,7 +647,19 @@ func (r *ManilaSchedulerReconciler) generateServiceConfig( labels := labels.GetLabels(instance, labels.GetGroupLabel(manila.ServiceName), serviceLabels) - customData := map[string]string{manila.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig} + db, err := mariadbv1.GetDatabaseByName(ctx, h, manila.DatabaseName) + if err != nil { + return err + } + var tlsCfg *tls.Service + if instance.Spec.TLS.CaBundleSecretName != "" { + tlsCfg = &tls.Service{} + } + + customData := map[string]string{ + manila.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig, + "my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf + } customData[manila.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig diff --git a/controllers/manilashare_controller.go b/controllers/manilashare_controller.go index 011eedf2..1006ebb8 100644 --- a/controllers/manilashare_controller.go +++ b/controllers/manilashare_controller.go @@ -51,6 +51,7 @@ import ( manilav1beta1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" "github.com/openstack-k8s-operators/manila-operator/pkg/manila" "github.com/openstack-k8s-operators/manila-operator/pkg/manilashare" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" ) // GetClient - @@ -643,7 +644,19 @@ func (r *ManilaShareReconciler) generateServiceConfig( labels := labels.GetLabels(instance, labels.GetGroupLabel(manila.ServiceName), serviceLabels) - customData := map[string]string{manila.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig} + db, err := mariadbv1.GetDatabaseByName(ctx, h, manila.DatabaseName) + if err != nil { + return err + } + var tlsCfg *tls.Service + if instance.Spec.TLS.CaBundleSecretName != "" { + tlsCfg = &tls.Service{} + } + + customData := map[string]string{ + manila.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig, + "my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf + } customData[manila.CustomServiceConfigFileName] = instance.Spec.CustomServiceConfig diff --git a/go.mod b/go.mod index 072def32..53f229d0 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240224182407-3b6c02b195f6 github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240224182407-3b6c02b195f6 github.com/openstack-k8s-operators/manila-operator/api v0.0.0-00010101000000-000000000000 - github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240222094307-76fef735f093 + github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240220132409-f96d4d040f4e k8s.io/api v0.28.7 k8s.io/apimachinery v0.28.7 k8s.io/client-go v0.28.7 diff --git a/go.sum b/go.sum index 6c12049c..854b50f7 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.202402241 github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240224182407-3b6c02b195f6/go.mod h1:Qg6DbOUHCzMCGhRikhN0XTWSOBOX9uB9z74jTbjyOUk= github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240224182407-3b6c02b195f6 h1:8SbXBGb7qgvYTXF9WiaNg1esn2J7mVXkqcAC0pIZJe4= github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240224182407-3b6c02b195f6/go.mod h1:82nzS+DbBe1tzaMvNHH8FctmZzQ14ZAJysFGsMJiivo= -github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240222094307-76fef735f093 h1:gmm2o5bVYIeuAVHp7WsDIpQc8vh+/9tUUYY4Wfyus/o= -github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240222094307-76fef735f093/go.mod h1:f9IIyWeoskWoeWaDFF3qmAJ2Kqyovfi0Ar/QUfk3qag= +github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240220132409-f96d4d040f4e h1:6vqp5HZwcGvPH0MII/23iCd97T3/1HJZlONKW6LyNio= +github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240220132409-f96d4d040f4e/go.mod h1:PDqfLbP4ZWqQHAu1OtbjfpOGQUKSzLqRJChvE/9pcyQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/pkg/manila/volumes.go b/pkg/manila/volumes.go index d766a64b..0bc5cb04 100644 --- a/pkg/manila/volumes.go +++ b/pkg/manila/volumes.go @@ -1,10 +1,11 @@ package manila import ( + "strconv" + "github.com/openstack-k8s-operators/lib-common/modules/storage" manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" - "strconv" ) // GetVolumes - @@ -86,6 +87,12 @@ func GetVolumeMounts(extraVol []manilav1.ManilaExtraVolMounts, svc []storage.Pro MountPath: "/usr/local/bin/container-scripts", ReadOnly: true, }, + { + Name: "config-data", + MountPath: "/etc/my.cnf", + SubPath: "my.cnf", + ReadOnly: true, + }, /*{ Name: "config-data-merged", MountPath: "/var/lib/config-data/merged", diff --git a/test/functional/manila_controller_test.go b/test/functional/manila_controller_test.go index 48f6a7f1..611f4486 100644 --- a/test/functional/manila_controller_test.go +++ b/test/functional/manila_controller_test.go @@ -216,13 +216,18 @@ var _ = Describe("Manila controller", func() { infra.SimulateTransportURLReady(manilaTest.ManilaTransportURL) DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, "memcached", memcachedSpec)) infra.SimulateMemcachedReady(manilaTest.ManilaMemcached) + mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance) + mariadb.SimulateMariaDBAccountCompleted(manilaTest.Instance) }) It("should create config-data and scripts ConfigMaps", func() { keystoneAPI := keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace) DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPI) - Eventually(func() corev1.Secret { - return th.GetSecret(manilaTest.ManilaConfigSecret) - }, timeout, interval).ShouldNot(BeNil()) + + secretDataMap := th.GetSecret(manilaTest.ManilaConfigSecret) + Expect(secretDataMap).ShouldNot(BeNil()) + myCnf := string(secretDataMap.Data["my.cnf"]) + Expect(myCnf).To( + ContainSubstring("[client]\nssl=0")) Eventually(func() corev1.Secret { return th.GetSecret(manilaTest.ManilaConfigScripts) }, timeout, interval).ShouldNot(BeNil()) @@ -466,7 +471,7 @@ var _ = Describe("Manila controller", func() { DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, manilaTest.MemcachedInstance, memcachedSpec)) infra.SimulateMemcachedReady(manilaTest.ManilaMemcached) DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace)) - mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance) + mariadb.SimulateMariaDBTLSDatabaseCompleted(manilaTest.Instance) mariadb.SimulateMariaDBAccountCompleted(manilaTest.Instance) th.SimulateJobSuccess(manilaTest.ManilaDBSync) }) @@ -516,16 +521,30 @@ var _ = Describe("Manila controller", func() { ) }) + It("should create config-data and scripts ConfigMaps", func() { + keystoneAPI := keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace) + DeferCleanup(keystone.DeleteKeystoneAPI, keystoneAPI) + + secretDataMap := th.GetSecret(manilaTest.ManilaConfigSecret) + Expect(secretDataMap).ShouldNot(BeNil()) + myCnf := string(secretDataMap.Data["my.cnf"]) + Expect(myCnf).To( + ContainSubstring("[client]\nssl-ca=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem\nssl=1")) + Eventually(func() corev1.Secret { + return th.GetSecret(manilaTest.ManilaConfigScripts) + }, timeout, interval).ShouldNot(BeNil()) + }) + It("Creates ManilaAPI", func() { DeferCleanup(k8sClient.Delete, ctx, th.CreateCABundleSecret(manilaTest.CABundleSecret)) DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(manilaTest.InternalCertSecret)) DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(manilaTest.PublicCertSecret)) keystone.SimulateKeystoneEndpointReady(manilaTest.ManilaKeystoneEndpoint) - ManilaAPIExists(manilaTest.Instance) + ManilaAPIExists(manilaTest.ManilaAPI) d := th.GetStatefulSet(manilaTest.ManilaAPI) - // Check the resulting deployment fields + // Check the resulting deployment fieldsq Expect(int(*d.Spec.Replicas)).To(Equal(1)) Expect(d.Spec.Template.Spec.Volumes).To(HaveLen(9)) diff --git a/test/functional/manila_test_data.go b/test/functional/manila_test_data.go index 479d7db6..30f36c87 100644 --- a/test/functional/manila_test_data.go +++ b/test/functional/manila_test_data.go @@ -20,6 +20,7 @@ package functional import ( "fmt" + "github.com/openstack-k8s-operators/manila-operator/pkg/manila" "k8s.io/apimachinery/pkg/types" ) @@ -47,6 +48,7 @@ type ManilaTestData struct { ManilaRoleBinding types.NamespacedName ManilaTransportURL types.NamespacedName ManilaMemcached types.NamespacedName + ManilaDatabaseName types.NamespacedName ManilaSA types.NamespacedName ManilaDBSync types.NamespacedName ManilaKeystoneEndpoint types.NamespacedName @@ -81,6 +83,10 @@ func GetManilaTestData(manilaName types.NamespacedName) ManilaTestData { Namespace: manilaName.Namespace, Name: manilaName.Name, }, + ManilaDatabaseName: types.NamespacedName{ + Namespace: manilaName.Namespace, + Name: manila.DatabaseName, + }, ManilaDBSync: types.NamespacedName{ Namespace: manilaName.Namespace, Name: fmt.Sprintf("%s-db-sync", manilaName.Name), diff --git a/test/functional/manilaapi_controller_test.go b/test/functional/manilaapi_controller_test.go index 022055b6..4e0617d9 100644 --- a/test/functional/manilaapi_controller_test.go +++ b/test/functional/manilaapi_controller_test.go @@ -24,6 +24,7 @@ import ( memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" "k8s.io/utils/ptr" ) @@ -50,6 +51,10 @@ var _ = Describe("ManilaAPI controller", func() { }, ), ) + mariadb.CreateMariaDBDatabase(manilaTest.Instance.Namespace, manilaTest.Instance.Name, mariadbv1.MariaDBDatabaseSpec{}) + mariadb.CreateMariaDBAccount(manilaTest.Instance.Namespace, manilaTest.Instance.Name, mariadbv1.MariaDBAccountSpec{}) + mariadb.SimulateMariaDBAccountCompleted(manilaTest.Instance) + mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance) }) When("ManilaAPI CR is created", func() { @@ -109,6 +114,11 @@ var _ = Describe("ManilaAPI controller", func() { //Double check customServiceConfig has been applied configData := string(secretDataMap.Data["03-config.conf"]) Expect(configData).Should(ContainSubstring("foo=bar")) + + Expect(secretDataMap.Data).Should(HaveKey("my.cnf")) + configData = string(secretDataMap.Data["my.cnf"]) + Expect(configData).To( + ContainSubstring("[client]\nssl=0")) }) When("manila-api-config is ready", func() { @@ -129,7 +139,7 @@ var _ = Describe("ManilaAPI controller", func() { Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2)) container := ss.Spec.Template.Spec.Containers[1] - Expect(container.VolumeMounts).To(HaveLen(7)) + Expect(container.VolumeMounts).To(HaveLen(8)) Expect(container.Image).To(Equal(manilaTest.ContainerImage)) Expect(container.LivenessProbe.HTTPGet.Port.IntVal).To(Equal(int32(8786))) Expect(container.ReadinessProbe.HTTPGet.Port.IntVal).To(Equal(int32(8786))) diff --git a/test/functional/manilascheduler_controller_test.go b/test/functional/manilascheduler_controller_test.go index 739d3461..6ad38823 100644 --- a/test/functional/manilascheduler_controller_test.go +++ b/test/functional/manilascheduler_controller_test.go @@ -19,6 +19,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -50,6 +51,10 @@ var _ = Describe("ManilaScheduler controller", func() { }, ), ) + mariadb.CreateMariaDBDatabase(manilaTest.Instance.Namespace, manilaTest.Instance.Name, mariadbv1.MariaDBDatabaseSpec{}) + mariadb.CreateMariaDBAccount(manilaTest.Instance.Namespace, manilaTest.Instance.Name, mariadbv1.MariaDBAccountSpec{}) + mariadb.SimulateMariaDBAccountCompleted(manilaTest.Instance) + mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance) }) When("ManilaScheduler CR is created", func() { @@ -109,6 +114,11 @@ var _ = Describe("ManilaScheduler controller", func() { //Double check customServiceConfig has been applied configData := string(secretDataMap.Data["03-config.conf"]) Expect(configData).Should(ContainSubstring("foo=bar")) + + Expect(secretDataMap.Data).Should(HaveKey("my.cnf")) + configData = string(secretDataMap.Data["my.cnf"]) + Expect(configData).To( + ContainSubstring("[client]\nssl=0")) }) When("manila-scheduler-config is ready", func() { @@ -129,7 +139,7 @@ var _ = Describe("ManilaScheduler controller", func() { Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2)) container := ss.Spec.Template.Spec.Containers[1] - Expect(container.VolumeMounts).To(HaveLen(6)) + Expect(container.VolumeMounts).To(HaveLen(7)) Expect(container.Image).To(Equal(manilaTest.ContainerImage)) }) It("stored the input hash in the Status", func() { diff --git a/test/functional/manilashare_controller_test.go b/test/functional/manilashare_controller_test.go index dfc897c7..cdf16aab 100644 --- a/test/functional/manilashare_controller_test.go +++ b/test/functional/manilashare_controller_test.go @@ -19,6 +19,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers" + mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -52,6 +53,10 @@ var _ = Describe("ManilaShare controller", func() { }, ), ) + mariadb.CreateMariaDBDatabase(manilaTest.Instance.Namespace, manilaTest.Instance.Name, mariadbv1.MariaDBDatabaseSpec{}) + mariadb.CreateMariaDBAccount(manilaTest.Instance.Namespace, manilaTest.Instance.Name, mariadbv1.MariaDBAccountSpec{}) + mariadb.SimulateMariaDBAccountCompleted(manilaTest.Instance) + mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.Instance) }) When("ManilaShare CR is created", func() { @@ -117,6 +122,11 @@ var _ = Describe("ManilaShare controller", func() { //Double check customServiceConfig has been applied configData := string(secretDataMap.Data["03-config.conf"]) Expect(configData).Should(ContainSubstring("foo=bar")) + + Expect(secretDataMap.Data).Should(HaveKey("my.cnf")) + configData = string(secretDataMap.Data["my.cnf"]) + Expect(configData).To( + ContainSubstring("[client]\nssl=0")) }) When("manila-share-config is ready", func() { @@ -143,7 +153,7 @@ var _ = Describe("ManilaShare controller", func() { Expect(ss.Spec.Template.Spec.Containers).To(HaveLen(2)) container := ss.Spec.Template.Spec.Containers[1] - Expect(container.VolumeMounts).To(HaveLen(7)) + Expect(container.VolumeMounts).To(HaveLen(8)) Expect(container.Image).To(Equal(manilaTest.ContainerImage)) // the input hash is stored in the current manilaShare.Status