From 7b737cf8d068f7154cfbdfc1628b5b5f37c7f5be Mon Sep 17 00:00:00 2001 From: Francesco Pantano Date: Thu, 5 Dec 2024 09:57:50 +0100 Subject: [PATCH] Add parameter to customize the number of cinderAPI processes Signed-off-by: Francesco Pantano --- api/bases/cinder.openstack.org_cinderapis.yaml | 5 +++++ api/bases/cinder.openstack.org_cinders.yaml | 5 +++++ api/v1beta1/cinderapi_types.go | 6 ++++++ api/v1beta1/zz_generated.deepcopy.go | 5 +++++ config/crd/bases/cinder.openstack.org_cinderapis.yaml | 5 +++++ config/crd/bases/cinder.openstack.org_cinders.yaml | 5 +++++ controllers/cinder_controller.go | 1 + templates/cinder/config/10-cinder_wsgi.conf | 2 +- 8 files changed, 33 insertions(+), 1 deletion(-) diff --git a/api/bases/cinder.openstack.org_cinderapis.yaml b/api/bases/cinder.openstack.org_cinderapis.yaml index 0510f7a3..68cdd865 100644 --- a/api/bases/cinder.openstack.org_cinderapis.yaml +++ b/api/bases/cinder.openstack.org_cinderapis.yaml @@ -666,6 +666,11 @@ spec: type: object transportURLSecret: type: string + workers: + default: 4 + format: int32 + minimum: 1 + type: integer required: - containerImage - databaseHostname diff --git a/api/bases/cinder.openstack.org_cinders.yaml b/api/bases/cinder.openstack.org_cinders.yaml index 1511d932..855f00ab 100644 --- a/api/bases/cinder.openstack.org_cinders.yaml +++ b/api/bases/cinder.openstack.org_cinders.yaml @@ -163,6 +163,11 @@ spec: caBundleSecretName: type: string type: object + workers: + default: 4 + format: int32 + minimum: 1 + type: integer required: - containerImage type: object diff --git a/api/v1beta1/cinderapi_types.go b/api/v1beta1/cinderapi_types.go index df5ab150..5fb44c56 100644 --- a/api/v1beta1/cinderapi_types.go +++ b/api/v1beta1/cinderapi_types.go @@ -51,6 +51,12 @@ type CinderAPITemplate struct { ContainerImage string `json:"containerImage"` CinderAPITemplateCore `json:",inline"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=4 + // +kubebuilder:validation:Minimum=1 + // Workers - Number of processes running CinderAPI + Workers *int32 `json:"workers"` } // APIOverrideSpec to override the generated manifest of several child resources. diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 2164887c..db2fda42 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -232,6 +232,11 @@ func (in *CinderAPIStatus) DeepCopy() *CinderAPIStatus { func (in *CinderAPITemplate) DeepCopyInto(out *CinderAPITemplate) { *out = *in in.CinderAPITemplateCore.DeepCopyInto(&out.CinderAPITemplateCore) + if in.Workers != nil { + in, out := &in.Workers, &out.Workers + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CinderAPITemplate. diff --git a/config/crd/bases/cinder.openstack.org_cinderapis.yaml b/config/crd/bases/cinder.openstack.org_cinderapis.yaml index 0510f7a3..68cdd865 100644 --- a/config/crd/bases/cinder.openstack.org_cinderapis.yaml +++ b/config/crd/bases/cinder.openstack.org_cinderapis.yaml @@ -666,6 +666,11 @@ spec: type: object transportURLSecret: type: string + workers: + default: 4 + format: int32 + minimum: 1 + type: integer required: - containerImage - databaseHostname diff --git a/config/crd/bases/cinder.openstack.org_cinders.yaml b/config/crd/bases/cinder.openstack.org_cinders.yaml index 1511d932..855f00ab 100644 --- a/config/crd/bases/cinder.openstack.org_cinders.yaml +++ b/config/crd/bases/cinder.openstack.org_cinders.yaml @@ -163,6 +163,11 @@ spec: caBundleSecretName: type: string type: object + workers: + default: 4 + format: int32 + minimum: 1 + type: integer required: - containerImage type: object diff --git a/controllers/cinder_controller.go b/controllers/cinder_controller.go index 7bfb6679..70278049 100644 --- a/controllers/cinder_controller.go +++ b/controllers/cinder_controller.go @@ -924,6 +924,7 @@ func (r *CinderReconciler) generateServiceConfigs( cinder.DatabaseName) templateParameters["MemcachedServersWithInet"] = memcached.GetMemcachedServerListWithInetString() templateParameters["TimeOut"] = instance.Spec.APITimeout + templateParameters["Workers"] = instance.Spec.CinderAPI.Workers // create httpd vhost template parameters httpdVhostConfig := map[string]interface{}{} diff --git a/templates/cinder/config/10-cinder_wsgi.conf b/templates/cinder/config/10-cinder_wsgi.conf index e12f1e24..31e5b360 100644 --- a/templates/cinder/config/10-cinder_wsgi.conf +++ b/templates/cinder/config/10-cinder_wsgi.conf @@ -32,7 +32,7 @@ ## WSGI configuration WSGIApplicationGroup %{GLOBAL} - WSGIDaemonProcess {{ $endpt }} display-name={{ $endpt }} group=cinder processes=4 threads=1 user=cinder + WSGIDaemonProcess {{ $endpt }} display-name={{ $endpt }} group=cinder processes={{ $.Workers }} threads=1 user=cinder WSGIProcessGroup {{ $endpt }} WSGIScriptAlias / "/var/www/cgi-bin/cinder/cinder-wsgi" WSGIPassAuthorization On