From 079ec6cfc354254e262b03bc9dd32e2b07ceaadc Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Thu, 23 Jan 2025 12:24:16 +0100 Subject: [PATCH] Allow customize http vhost config using HttpdCustomization.CustomConfigSecret This change allows to customize the httpd vhost config using this parameter to specify a secret that contains service config data. The content of each provided snippet gets rendered as a go template and placed into /etc/httpd/conf/httpd_custom__ . At the end of the vhost config in the default httpd template these custom configs get included using `Include conf/httpd_custom__*`. For information on how sections in httpd configuration get merged, check section "How the sections are merged" in https://httpd.apache.org/docs/current/sections.html#merging All possible parameters which can be use in a template can be looked up in the -config-data secret of the service like: ``` $ oc get secret -n openstack placement-config-data -o json | jq -r .data.TemplateParameters | base64 -d ``` or in the running pod of the service in the file: ``` $ cat /var/lib/config-data/default/TemplateParameters ``` The content is a versioned dump of the parameters of the service operator, like: ~~~ DatabaseConnection: mysql+pymysql://user:pwd@openstack.openstack.svc/keystone?read_default_file=/etc/my.cnf KeystoneEndpointInternal: https://keystone-internal.openstack.svc:5000 KeystoneEndpointPublic: https://keystone-public-openstack.apps-crc.testing TransportURL: rabbit://user:pwd@rabbitmq.openstack.svc:5671/?ssl=1 VHosts: internal: Override: false SSLCertificateFile: /etc/pki/tls/certs/internal.crt SSLCertificateKeyFile: /etc/pki/tls/private/internal.key ServerName: keystone-internal.openstack.svc TLS: true public: Override: false SSLCertificateFile: /etc/pki/tls/certs/public.crt SSLCertificateKeyFile: /etc/pki/tls/private/public.key ServerName: keystone-public.openstack.svc TLS: true MemcachedServers: memcached-0.memcached.openstack.svc:11212 MemcachedServersWithInet: inet:[memcached-0.memcached.openstack.svc]:11211 ... ~~~ Depends-On: https://github.com/openstack-k8s-operators/lib-common/pull/591 Depends-On: https://github.com/openstack-k8s-operators/lib-common/pull/593 Jira: https://issues.redhat.com/browse/OSPRH-13100 Signed-off-by: Martin Schuppert --- .../manila.openstack.org_manilaapis.yaml | 5 ++ api/bases/manila.openstack.org_manilas.yaml | 5 ++ api/go.mod | 2 +- api/go.sum | 2 + api/v1beta1/manilaapi_types.go | 17 +++++ api/v1beta1/zz_generated.deepcopy.go | 21 ++++++ .../manila.openstack.org_manilaapis.yaml | 5 ++ .../bases/manila.openstack.org_manilas.yaml | 5 ++ controllers/manila_controller.go | 52 ++++++++++--- controllers/manilaapi_controller.go | 21 ++++++ controllers/manilascheduler_controller.go | 1 + controllers/manilashare_controller.go | 1 + go.mod | 2 +- go.sum | 2 + templates/manila/config/10-manila_wsgi.conf | 5 ++ .../manila/config/manila-api-config.json | 7 ++ test/functional/manila_controller_test.go | 73 +++++++++++++++++++ 17 files changed, 213 insertions(+), 13 deletions(-) diff --git a/api/bases/manila.openstack.org_manilaapis.yaml b/api/bases/manila.openstack.org_manilaapis.yaml index 635ce150..6ef9b292 100644 --- a/api/bases/manila.openstack.org_manilaapis.yaml +++ b/api/bases/manila.openstack.org_manilaapis.yaml @@ -536,6 +536,11 @@ spec: - extraVol type: object type: array + httpdCustomization: + properties: + customConfigSecret: + type: string + type: object networkAttachments: items: type: string diff --git a/api/bases/manila.openstack.org_manilas.yaml b/api/bases/manila.openstack.org_manilas.yaml index d37f66a6..d38bc0cb 100644 --- a/api/bases/manila.openstack.org_manilas.yaml +++ b/api/bases/manila.openstack.org_manilas.yaml @@ -557,6 +557,11 @@ spec: items: type: string type: array + httpdCustomization: + properties: + customConfigSecret: + type: string + type: object networkAttachments: items: type: string diff --git a/api/go.mod b/api/go.mod index bce827e8..66188b5d 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,7 +3,7 @@ module github.com/openstack-k8s-operators/manila-operator/api go 1.21 require ( - github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241216113837-d172b3ac0f4e + github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250116145727-01a8948d5dd7 github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e k8s.io/api v0.29.12 k8s.io/apimachinery v0.29.12 diff --git a/api/go.sum b/api/go.sum index bff38bcb..e66ffd20 100644 --- a/api/go.sum +++ b/api/go.sum @@ -75,6 +75,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241216113837-d172b3ac0f4e h1:hf4kVQBkyG79WcHBxdQ25QrDBbGFdarebS1Tc0Xclq4= github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241216113837-d172b3ac0f4e/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250116145727-01a8948d5dd7 h1:vXHpH93PjbAgg5ZN6n5WmxkybVQOs0nhXvVw62o7aZs= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250116145727-01a8948d5dd7/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e h1:Qz0JFEoRDUyjEWorNY3LggwxTsmpMtQkcpmZDQulGHQ= github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e/go.mod h1:tfgBeLRqmlH/NQkLPe7396rj+t0whv2wPuMb8Ttvh8w= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/api/v1beta1/manilaapi_types.go b/api/v1beta1/manilaapi_types.go index d21709db..97533cfa 100644 --- a/api/v1beta1/manilaapi_types.go +++ b/api/v1beta1/manilaapi_types.go @@ -53,6 +53,10 @@ type ManilaAPITemplateCore struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // TLS - Parameters related to the TLS TLS tls.API `json:"tls,omitempty"` + + // +kubebuilder:validation:Optional + // HttpdCustomization - customize the httpd service + HttpdCustomization HttpdCustomization `json:"httpdCustomization,omitempty"` } // APIOverrideSpec to override the generated manifest of several child resources. @@ -62,6 +66,19 @@ type APIOverrideSpec struct { Service map[service.Endpoint]service.RoutedOverrideSpec `json:"service,omitempty"` } +// HttpdCustomization - customize the httpd service +type HttpdCustomization struct { + // +kubebuilder:validation:Optional + // CustomConfigSecret - customize the httpd vhost config using this parameter to specify + // a secret that contains service config data. The content of each provided snippet gets + // rendered as a go template and placed into /etc/httpd/conf/httpd_custom_ . + // In the default httpd template at the end of the vhost those custom configs get + // included using `Include conf/httpd_custom__*`. + // For information on how sections in httpd configuration get merged, check section + // "How the sections are merged" in https://httpd.apache.org/docs/current/sections.html#merging + CustomConfigSecret *string `json:"customConfigSecret,omitempty"` +} + // ManilaAPISpec defines the desired state of ManilaAPI type ManilaAPISpec struct { diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index c1672ae4..64297f91 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -64,6 +64,26 @@ func (in *DBPurge) DeepCopy() *DBPurge { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HttpdCustomization) DeepCopyInto(out *HttpdCustomization) { + *out = *in + if in.CustomConfigSecret != nil { + in, out := &in.CustomConfigSecret, &out.CustomConfigSecret + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HttpdCustomization. +func (in *HttpdCustomization) DeepCopy() *HttpdCustomization { + if in == nil { + return nil + } + out := new(HttpdCustomization) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Manila) DeepCopyInto(out *Manila) { *out = *in @@ -246,6 +266,7 @@ func (in *ManilaAPITemplateCore) DeepCopyInto(out *ManilaAPITemplateCore) { } in.Override.DeepCopyInto(&out.Override) in.TLS.DeepCopyInto(&out.TLS) + in.HttpdCustomization.DeepCopyInto(&out.HttpdCustomization) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManilaAPITemplateCore. diff --git a/config/crd/bases/manila.openstack.org_manilaapis.yaml b/config/crd/bases/manila.openstack.org_manilaapis.yaml index 635ce150..6ef9b292 100644 --- a/config/crd/bases/manila.openstack.org_manilaapis.yaml +++ b/config/crd/bases/manila.openstack.org_manilaapis.yaml @@ -536,6 +536,11 @@ spec: - extraVol type: object type: array + httpdCustomization: + properties: + customConfigSecret: + type: string + type: object networkAttachments: items: type: string diff --git a/config/crd/bases/manila.openstack.org_manilas.yaml b/config/crd/bases/manila.openstack.org_manilas.yaml index d37f66a6..d38bc0cb 100644 --- a/config/crd/bases/manila.openstack.org_manilas.yaml +++ b/config/crd/bases/manila.openstack.org_manilas.yaml @@ -557,6 +557,11 @@ spec: items: type: string type: array + httpdCustomization: + properties: + customConfigSecret: + type: string + type: object networkAttachments: items: type: string diff --git a/controllers/manila_controller.go b/controllers/manila_controller.go index f893042d..5fca53f2 100644 --- a/controllers/manila_controller.go +++ b/controllers/manila_controller.go @@ -20,6 +20,7 @@ import ( "context" "fmt" + "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" @@ -215,10 +216,11 @@ func (r *ManilaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res // fields to index to reconcile when change const ( - passwordSecretField = ".spec.secret" - caBundleSecretNameField = ".spec.tls.caBundleSecretName" - tlsAPIInternalField = ".spec.tls.api.internal.secretName" - tlsAPIPublicField = ".spec.tls.api.public.secretName" + passwordSecretField = ".spec.secret" + caBundleSecretNameField = ".spec.tls.caBundleSecretName" + tlsAPIInternalField = ".spec.tls.api.internal.secretName" + tlsAPIPublicField = ".spec.tls.api.public.secretName" + httpdCustomServiceConfigSecretField = ".spec.httpdCustomization.customServiceConfigSecret" ) var ( @@ -231,6 +233,7 @@ var ( caBundleSecretNameField, tlsAPIInternalField, tlsAPIPublicField, + httpdCustomServiceConfigSecretField, } ) @@ -880,6 +883,14 @@ func (r *ManilaReconciler) generateServiceConfig( return err } + httpdOverrideSecret := &corev1.Secret{} + if instance.Spec.ManilaAPI.HttpdCustomization.CustomConfigSecret != nil && *instance.Spec.ManilaAPI.HttpdCustomization.CustomConfigSecret != "" { + httpdOverrideSecret, _, err = secret.GetSecret(ctx, h, *instance.Spec.ManilaAPI.HttpdCustomization.CustomConfigSecret, instance.Namespace) + if err != nil { + return err + } + } + databaseAccount := db.GetAccount() databaseSecret := db.GetSecret() @@ -900,6 +911,7 @@ func (r *ManilaReconciler) generateServiceConfig( } // create httpd vhost template parameters + customTemplates := map[string]string{} httpdVhostConfig := map[string]interface{}{} for _, endpt := range []service.Endpoint{service.EndpointInternal, service.EndpointPublic} { endptConfig := map[string]interface{}{} @@ -910,10 +922,27 @@ func (r *ManilaReconciler) generateServiceConfig( endptConfig["SSLCertificateFile"] = fmt.Sprintf("/etc/pki/tls/certs/%s.crt", endpt.String()) endptConfig["SSLCertificateKeyFile"] = fmt.Sprintf("/etc/pki/tls/private/%s.key", endpt.String()) } + + endptConfig["Override"] = false + if len(httpdOverrideSecret.Data) > 0 { + endptConfig["Override"] = true + for key, data := range httpdOverrideSecret.Data { + if len(data) > 0 { + customTemplates["httpd_custom_"+endpt.String()+"_"+key] = string(data) + } + } + } httpdVhostConfig[endpt.String()] = endptConfig } templateParameters["VHosts"] = httpdVhostConfig + // Marshal the templateParameters map to YAML + yamlData, err := yaml.Marshal(templateParameters) + if err != nil { + return fmt.Errorf("Error marshalling to YAML: %w", err) + } + customData[common.TemplateParameters] = string(yamlData) + configTemplates := []util.Template{ // ScriptsConfigMap { @@ -925,13 +954,14 @@ func (r *ManilaReconciler) generateServiceConfig( }, // ConfigMap { - Name: fmt.Sprintf("%s-config-data", instance.Name), - Namespace: instance.Namespace, - Type: util.TemplateTypeConfig, - InstanceType: instance.Kind, - CustomData: customData, - ConfigOptions: templateParameters, - Labels: labels, + Name: fmt.Sprintf("%s-config-data", instance.Name), + Namespace: instance.Namespace, + Type: util.TemplateTypeConfig, + InstanceType: instance.Kind, + CustomData: customData, + ConfigOptions: templateParameters, + StringTemplate: customTemplates, + Labels: labels, }, } diff --git a/controllers/manilaapi_controller.go b/controllers/manilaapi_controller.go index d28becdd..588eee7a 100644 --- a/controllers/manilaapi_controller.go +++ b/controllers/manilaapi_controller.go @@ -19,6 +19,9 @@ package controllers import ( "context" "fmt" + "strings" + + "golang.org/x/exp/maps" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/runtime" @@ -309,6 +312,18 @@ func (r *ManilaAPIReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } + // index httpdOverrideSecretField + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &manilav1beta1.ManilaAPI{}, httpdCustomServiceConfigSecretField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*manilav1beta1.ManilaAPI) + if cr.Spec.HttpdCustomization.CustomConfigSecret == nil { + return nil + } + return []string{*cr.Spec.HttpdCustomization.CustomConfigSecret} + }); err != nil { + return err + } + return ctrl.NewControllerManagedBy(mgr). For(&manilav1beta1.ManilaAPI{}). Owns(&keystonev1.KeystoneService{}). @@ -947,6 +962,12 @@ func (r *ManilaAPIReconciler) generateServiceConfig( } customData[manila.DefaultsConfigFileName] = string(manilaSecret.Data[manila.DefaultsConfigFileName]) customData[manila.CustomConfigFileName] = string(manilaSecret.Data[manila.CustomConfigFileName]) + customData[common.TemplateParameters] = string(manilaSecret.Data[common.TemplateParameters]) + for _, key := range maps.Keys(manilaSecret.Data) { + if strings.HasPrefix(key, "httpd_custom_") { + customData[key] = string(manilaSecret.Data[key]) + } + } customSecrets := "" for _, secretName := range instance.Spec.CustomServiceConfigSecrets { diff --git a/controllers/manilascheduler_controller.go b/controllers/manilascheduler_controller.go index 31e09f93..a39e952f 100644 --- a/controllers/manilascheduler_controller.go +++ b/controllers/manilascheduler_controller.go @@ -596,6 +596,7 @@ func (r *ManilaSchedulerReconciler) generateServiceConfig( } customData[manila.DefaultsConfigFileName] = string(manilaSecret.Data[manila.DefaultsConfigFileName]) customData[manila.CustomConfigFileName] = string(manilaSecret.Data[manila.CustomConfigFileName]) + customData[common.TemplateParameters] = string(manilaSecret.Data[common.TemplateParameters]) customSecrets := "" for _, secretName := range instance.Spec.CustomServiceConfigSecrets { diff --git a/controllers/manilashare_controller.go b/controllers/manilashare_controller.go index aa22b5c8..e21e829f 100644 --- a/controllers/manilashare_controller.go +++ b/controllers/manilashare_controller.go @@ -594,6 +594,7 @@ func (r *ManilaShareReconciler) generateServiceConfig( } customData[manila.DefaultsConfigFileName] = string(manilaSecret.Data[manila.DefaultsConfigFileName]) customData[manila.CustomConfigFileName] = string(manilaSecret.Data[manila.CustomConfigFileName]) + customData[common.TemplateParameters] = string(manilaSecret.Data[common.TemplateParameters]) customSecrets := "" for _, secretName := range instance.Spec.CustomServiceConfigSecrets { diff --git a/go.mod b/go.mod index 6f733231..257ef951 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/onsi/gomega v1.34.1 github.com/openstack-k8s-operators/infra-operator/apis v0.5.1-0.20250108092548-58707fa645ce github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20250107165241-16c3ed8e549f - github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241216113837-d172b3ac0f4e + github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250116145727-01a8948d5dd7 github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241216113837-d172b3ac0f4e github.com/openstack-k8s-operators/manila-operator/api v0.0.0-00010101000000-000000000000 diff --git a/go.sum b/go.sum index 2be20578..22220d73 100644 --- a/go.sum +++ b/go.sum @@ -84,6 +84,8 @@ github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20250107165241 github.com/openstack-k8s-operators/keystone-operator/api v0.5.1-0.20250107165241-16c3ed8e549f/go.mod h1:CyuEOM1TpXKNUR1n8cudNtRzTEwkzv90JFkpDPPId8E= github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241216113837-d172b3ac0f4e h1:hf4kVQBkyG79WcHBxdQ25QrDBbGFdarebS1Tc0Xclq4= github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241216113837-d172b3ac0f4e/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250116145727-01a8948d5dd7 h1:vXHpH93PjbAgg5ZN6n5WmxkybVQOs0nhXvVw62o7aZs= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20250116145727-01a8948d5dd7/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.1-0.20241216113837-d172b3ac0f4e h1:HFo4OqPY0x4ZQeaWI2YGonTXAGTQFt+rOEJlfZVhS7s= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.5.1-0.20241216113837-d172b3ac0f4e/go.mod h1:IASoGvp5QM/tBJUd/8i8uIjj4DBnI+64Ydh4r7pmnvA= github.com/openstack-k8s-operators/lib-common/modules/storage v0.5.1-0.20241216113837-d172b3ac0f4e h1:Qz0JFEoRDUyjEWorNY3LggwxTsmpMtQkcpmZDQulGHQ= diff --git a/templates/manila/config/10-manila_wsgi.conf b/templates/manila/config/10-manila_wsgi.conf index 3a304576..abe8b41c 100644 --- a/templates/manila/config/10-manila_wsgi.conf +++ b/templates/manila/config/10-manila_wsgi.conf @@ -36,5 +36,10 @@ WSGIProcessGroup {{ $endpt }} WSGIScriptAlias / "/var/www/cgi-bin/manila/manila-wsgi" WSGIPassAuthorization On + +{{- if $vhost.Override }} + Include conf/httpd_custom_{{ $endpt }}_* +{{- end }} + {{ end }} diff --git a/templates/manila/config/manila-api-config.json b/templates/manila/config/manila-api-config.json index 31689ac7..592f0a94 100644 --- a/templates/manila/config/manila-api-config.json +++ b/templates/manila/config/manila-api-config.json @@ -34,6 +34,13 @@ "perm": "0600", "optional": true, "merge": true + }, + { + "source": "/var/lib/config-data/default/httpd_custom_*", + "dest": "/etc/httpd/conf/", + "owner": "apache", + "perm": "0444", + "optional": true } ], "permissions": [ diff --git a/test/functional/manila_controller_test.go b/test/functional/manila_controller_test.go index 9fee90c9..9f8a666e 100644 --- a/test/functional/manila_controller_test.go +++ b/test/functional/manila_controller_test.go @@ -32,6 +32,7 @@ import ( "k8s.io/utils/ptr" memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1" + "github.com/openstack-k8s-operators/lib-common/modules/common" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" util "github.com/openstack-k8s-operators/lib-common/modules/common/util" manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" @@ -931,6 +932,78 @@ var _ = Describe("Manila controller", func() { }) }) + When("A ManilaAPI is created with HttpdCustomization.CustomConfigSecret", func() { + + BeforeEach(func() { + customServiceConfigSecretName := types.NamespacedName{Name: "foo", Namespace: manilaTest.Instance.Namespace} + customConfig := []byte(`CustomParam "foo" +CustomKeystonePublicURL "{{ .KeystonePublicURL }}"`) + th.CreateSecret( + customServiceConfigSecretName, + map[string][]byte{ + "bar.conf": customConfig, + }, + ) + + spec := GetDefaultManilaSpec() + apiSpec := GetDefaultManilaAPISpec() + apiSpec["httpdCustomization"] = map[string]interface{}{ + "customConfigSecret": customServiceConfigSecretName.Name, + } + spec["manilaAPI"] = apiSpec + + DeferCleanup(th.DeleteInstance, CreateManila(manilaTest.Instance, spec)) + DeferCleanup(k8sClient.Delete, ctx, CreateManilaMessageBusSecret(manilaTest.Instance.Namespace, manilaTest.RabbitmqSecretName)) + DeferCleanup( + mariadb.DeleteDBService, + mariadb.CreateDBService( + manilaTest.Instance.Namespace, + GetManila(manilaName).Spec.DatabaseInstance, + corev1.ServiceSpec{ + Ports: []corev1.ServicePort{{Port: 3306}}, + }, + ), + ) + infra.SimulateTransportURLReady(manilaTest.ManilaTransportURL) + DeferCleanup(infra.DeleteMemcached, infra.CreateMemcached(namespace, manilaTest.MemcachedInstance, memcachedSpec)) + infra.SimulateMemcachedReady(manilaTest.ManilaMemcached) + DeferCleanup(keystone.DeleteKeystoneAPI, keystone.CreateKeystoneAPI(manilaTest.Instance.Namespace)) + mariadb.SimulateMariaDBDatabaseCompleted(manilaTest.ManilaDatabaseName) + mariadb.SimulateMariaDBAccountCompleted(manilaTest.ManilaDatabaseAccount) + th.SimulateJobSuccess(manilaTest.ManilaDBSync) + keystone.SimulateKeystoneServiceReady(manilaTest.Instance) + keystone.SimulateKeystoneEndpointReady(manilaTest.ManilaKeystoneEndpoint) + th.SimulateStatefulSetReplicaReady(manilaTest.ManilaAPI) + th.SimulateStatefulSetReplicaReady(manilaTest.ManilaScheduler) + th.SimulateStatefulSetReplicaReady(manilaTest.ManilaShares[0]) + }) + + It("it renders the custom template and adds it to the manila-config-data secret", func() { + scrt := th.GetSecret(manilaTest.ManilaConfigSecret) + Expect(scrt).ShouldNot(BeNil()) + Expect(scrt.Data).Should(HaveKey(common.TemplateParameters)) + configData := string(scrt.Data[common.TemplateParameters]) + keystonePublicURL := "http://keystone-public-openstack.testing" + Expect(configData).Should(ContainSubstring(fmt.Sprintf("KeystonePublicURL: %s", keystonePublicURL))) + + for _, cfg := range []string{"httpd_custom_internal_bar.conf", "httpd_custom_public_bar.conf"} { + Expect(scrt.Data).Should(HaveKey(cfg)) + configData := string(scrt.Data[cfg]) + Expect(configData).Should(ContainSubstring("CustomParam \"foo\"")) + Expect(configData).Should(ContainSubstring(fmt.Sprintf("CustomKeystonePublicURL \"%s\"", keystonePublicURL))) + } + + scrt = th.GetSecret(manilaTest.ManilaAPIConfigSecret) + Expect(scrt).ShouldNot(BeNil()) + for _, cfg := range []string{"httpd_custom_internal_bar.conf", "httpd_custom_public_bar.conf"} { + Expect(scrt.Data).Should(HaveKey(cfg)) + configData := string(scrt.Data[cfg]) + Expect(configData).Should(ContainSubstring("CustomParam \"foo\"")) + Expect(configData).Should(ContainSubstring(fmt.Sprintf("CustomKeystonePublicURL \"%s\"", keystonePublicURL))) + } + }) + }) + // Run MariaDBAccount suite tests. these are pre-packaged ginkgo tests // that exercise standard account create / update patterns that should be // common to all controllers that ensure MariaDBAccount CRs.