From 3a5a9f402b5dc66ee4c5f67b0704684449ecd11c Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Mon, 11 Nov 2024 18:20:39 -0500 Subject: [PATCH 1/2] Add API Timeout for Aodh --- .../telemetry.openstack.org_autoscalings.yaml | 4 +++ .../telemetry.openstack.org_telemetries.yaml | 4 +++ api/v1beta1/autoscaling_types.go | 6 ++++ api/v1beta1/autoscaling_webhook.go | 28 +++++++++++++++++++ .../telemetry.openstack.org_autoscalings.yaml | 4 +++ .../telemetry.openstack.org_telemetries.yaml | 4 +++ controllers/autoscaling_controller.go | 1 + templates/autoscaling/config/wsgi-aodh.conf | 1 + 8 files changed, 52 insertions(+) diff --git a/api/bases/telemetry.openstack.org_autoscalings.yaml b/api/bases/telemetry.openstack.org_autoscalings.yaml index c3ce7e9b..ed7c37cf 100644 --- a/api/bases/telemetry.openstack.org_autoscalings.yaml +++ b/api/bases/telemetry.openstack.org_autoscalings.yaml @@ -62,6 +62,10 @@ spec: properties: apiImage: type: string + apiTimeout: + description: APITimeout for Route and Apache + minimum: 60 + type: integer customServiceConfig: default: '# add your customization here' description: CustomServiceConfig - customize the service config diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 4df8d764..5c48d2f3 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -65,6 +65,10 @@ spec: properties: apiImage: type: string + apiTimeout: + description: APITimeout for Route and Apache + minimum: 60 + type: integer customServiceConfig: default: '# add your customization here' description: CustomServiceConfig - customize the service config diff --git a/api/v1beta1/autoscaling_types.go b/api/v1beta1/autoscaling_types.go index 1129ef20..579d0ff9 100644 --- a/api/v1beta1/autoscaling_types.go +++ b/api/v1beta1/autoscaling_types.go @@ -58,6 +58,12 @@ type Aodh struct { // Aodh defines the aodh component spec type AodhCore struct { + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=60 + // +kubebuilder:Default=60 + // APITimeout for Route and Apache + APITimeout int `json:"apiTimeout,omitempty"` + // RabbitMQ instance name // Needed to request a transportURL that is created and used in Aodh // +kubebuilder:default=rabbitmq diff --git a/api/v1beta1/autoscaling_webhook.go b/api/v1beta1/autoscaling_webhook.go index 47049716..c2083ba9 100644 --- a/api/v1beta1/autoscaling_webhook.go +++ b/api/v1beta1/autoscaling_webhook.go @@ -17,6 +17,7 @@ limitations under the License. package v1beta1 import ( + "fmt" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/log" @@ -80,6 +81,33 @@ func (spec *AutoscalingSpec) Default() { } } +// SetDefaultRouteAnnotations sets HAProxy timeout values of the route +// NOTE: it is used by ctlplane webhook on openstack-operator +func (spec *AutoscalingSpecCore) SetDefaultRouteAnnotations(annotations map[string]string) { + const haProxyAnno = "haproxy.router.openshift.io/timeout" + // Use a custom annotation to flag when the operator has set the default HAProxy timeout + // With the annotation func determines when to overwrite existing HAProxy timeout with the APITimeout + const aodhAnno = "api.aodh.openstack.org/timeout" + + valAodh, okAodh := annotations[aodhAnno] + valHAProxy, okHAProxy := annotations[haProxyAnno] + + // Human operator set the HAProxy timeout manually + if !okAodh && okHAProxy { + return + } + + // Human operator modified the HAProxy timeout manually without removing the Aodh flag + if okAodh && okHAProxy && valAodh != valHAProxy { + delete(annotations, aodhAnno) + return + } + + timeout := fmt.Sprintf("%ds", spec.Aodh.APITimeout) + annotations[aodhAnno] = timeout + annotations[haProxyAnno] = timeout +} + // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. //+kubebuilder:webhook:path=/validate-telemetry-openstack-org-v1beta1-autoscaling,mutating=false,failurePolicy=fail,sideEffects=None,groups=telemetry.openstack.org,resources=autoscalings,verbs=create;update,versions=v1beta1,name=vautoscaling.kb.io,admissionReviewVersions=v1 diff --git a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml index c3ce7e9b..ed7c37cf 100644 --- a/config/crd/bases/telemetry.openstack.org_autoscalings.yaml +++ b/config/crd/bases/telemetry.openstack.org_autoscalings.yaml @@ -62,6 +62,10 @@ spec: properties: apiImage: type: string + apiTimeout: + description: APITimeout for Route and Apache + minimum: 60 + type: integer customServiceConfig: default: '# add your customization here' description: CustomServiceConfig - customize the service config diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 4df8d764..5c48d2f3 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -65,6 +65,10 @@ spec: properties: apiImage: type: string + apiTimeout: + description: APITimeout for Route and Apache + minimum: 60 + type: integer customServiceConfig: default: '# add your customization here' description: CustomServiceConfig - customize the service config diff --git a/controllers/autoscaling_controller.go b/controllers/autoscaling_controller.go index e1f92143..b117dace 100644 --- a/controllers/autoscaling_controller.go +++ b/controllers/autoscaling_controller.go @@ -604,6 +604,7 @@ func (r *AutoscalingReconciler) generateServiceConfig( string(databaseSecret.Data[mariadbv1.DatabasePasswordSelector]), instance.Status.DatabaseHostname, autoscaling.DatabaseName), + "Timeout": instance.Spec.Aodh.APITimeout, } prometheusParams := map[string]interface{}{ diff --git a/templates/autoscaling/config/wsgi-aodh.conf b/templates/autoscaling/config/wsgi-aodh.conf index cae8eb57..499bf72f 100644 --- a/templates/autoscaling/config/wsgi-aodh.conf +++ b/templates/autoscaling/config/wsgi-aodh.conf @@ -34,5 +34,6 @@ WSGIProcessGroup {{ $endpt }} WSGIScriptAlias / "/var/www/cgi-bin/aodh/aodh-api" WSGIPassAuthorization On + Timeout {{ $.Timeout }} {{ end }} From f8906f301d6a5547bc5bfaa605a93404983cdcdd Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Tue, 12 Nov 2024 05:56:46 -0500 Subject: [PATCH 2/2] Add API Timeout for ceilometer --- api/bases/telemetry.openstack.org_ceilometers.yaml | 5 +++++ api/bases/telemetry.openstack.org_telemetries.yaml | 5 +++++ api/v1beta1/ceilometer_types.go | 6 ++++++ config/crd/bases/telemetry.openstack.org_ceilometers.yaml | 5 +++++ config/crd/bases/telemetry.openstack.org_telemetries.yaml | 5 +++++ controllers/ceilometer_controller.go | 1 + templates/ceilometercentral/config/httpd.conf | 2 ++ 7 files changed, 29 insertions(+) diff --git a/api/bases/telemetry.openstack.org_ceilometers.yaml b/api/bases/telemetry.openstack.org_ceilometers.yaml index 0b63680d..d9c3b38a 100644 --- a/api/bases/telemetry.openstack.org_ceilometers.yaml +++ b/api/bases/telemetry.openstack.org_ceilometers.yaml @@ -108,6 +108,11 @@ spec: spec: description: CeilometerSpec defines the desired state of Ceilometer properties: + apiTimeout: + default: 60 + description: APITimeout for Apache + minimum: 60 + type: integer centralImage: type: string computeImage: diff --git a/api/bases/telemetry.openstack.org_telemetries.yaml b/api/bases/telemetry.openstack.org_telemetries.yaml index 5c48d2f3..93f0a962 100644 --- a/api/bases/telemetry.openstack.org_telemetries.yaml +++ b/api/bases/telemetry.openstack.org_telemetries.yaml @@ -425,6 +425,11 @@ spec: ceilometer: description: Ceilometer - Parameters related to the ceilometer service properties: + apiTimeout: + default: 60 + description: APITimeout for Apache + minimum: 60 + type: integer centralImage: type: string computeImage: diff --git a/api/v1beta1/ceilometer_types.go b/api/v1beta1/ceilometer_types.go index 835f191d..70334afe 100644 --- a/api/v1beta1/ceilometer_types.go +++ b/api/v1beta1/ceilometer_types.go @@ -70,6 +70,12 @@ type CeilometerSpec struct { // CeilometerSpecCore defines the desired state of Ceilometer. This version is used by the OpenStackControlplane (no image parameters) type CeilometerSpecCore struct { + // +kubebuilder:validation:Optional + // +kubebuilder:default=60 + // +kubebuilder:validation:Minimum=60 + // APITimeout for Apache + APITimeout int `json:"apiTimeout"` + // RabbitMQ instance name // Needed to request a transportURL that is created and used in Telemetry // +kubebuilder:default=rabbitmq diff --git a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml index 0b63680d..d9c3b38a 100644 --- a/config/crd/bases/telemetry.openstack.org_ceilometers.yaml +++ b/config/crd/bases/telemetry.openstack.org_ceilometers.yaml @@ -108,6 +108,11 @@ spec: spec: description: CeilometerSpec defines the desired state of Ceilometer properties: + apiTimeout: + default: 60 + description: APITimeout for Apache + minimum: 60 + type: integer centralImage: type: string computeImage: diff --git a/config/crd/bases/telemetry.openstack.org_telemetries.yaml b/config/crd/bases/telemetry.openstack.org_telemetries.yaml index 5c48d2f3..93f0a962 100644 --- a/config/crd/bases/telemetry.openstack.org_telemetries.yaml +++ b/config/crd/bases/telemetry.openstack.org_telemetries.yaml @@ -425,6 +425,11 @@ spec: ceilometer: description: Ceilometer - Parameters related to the ceilometer service properties: + apiTimeout: + default: 60 + description: APITimeout for Apache + minimum: 60 + type: integer centralImage: type: string computeImage: diff --git a/controllers/ceilometer_controller.go b/controllers/ceilometer_controller.go index 9fff9a32..4a380d4f 100644 --- a/controllers/ceilometer_controller.go +++ b/controllers/ceilometer_controller.go @@ -839,6 +839,7 @@ func (r *CeilometerReconciler) generateServiceConfig( "CeilometerPassword": string(ceilometerPasswordSecret.Data["CeilometerPassword"]), "TLS": false, // Default to false. Change to true later if TLS enabled "SwiftRole": false, // + "Timeout": instance.Spec.APITimeout, } // create httpd vhost template parameters diff --git a/templates/ceilometercentral/config/httpd.conf b/templates/ceilometercentral/config/httpd.conf index e762a446..ffbdfbe4 100644 --- a/templates/ceilometercentral/config/httpd.conf +++ b/templates/ceilometercentral/config/httpd.conf @@ -53,4 +53,6 @@ CustomLog /dev/stdout proxy env=forwarded SSLCertificateFile "{{ .vhost.SSLCertificateFile }}" SSLCertificateKeyFile "{{ .vhost.SSLCertificateKeyFile }}" {{- end }} + + Timeout {{ $.Timeout }}