Skip to content

Commit

Permalink
Merge pull request #531 from openshift-cherrypick-robot/cherry-pick-5…
Browse files Browse the repository at this point in the history
…26-to-18.0-fr1

[18.0-fr1] [OSPRH-10956] Httpd timeout for ceilometer and aodh
  • Loading branch information
openshift-merge-bot[bot] authored Nov 18, 2024
2 parents 2aa2e69 + 05fa454 commit 7e172ac
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/bases/telemetry.openstack.org_autoscalings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions api/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions api/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -421,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:
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/autoscaling_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions api/v1beta1/autoscaling_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ceilometer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/telemetry.openstack.org_autoscalings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -421,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:
Expand Down
1 change: 1 addition & 0 deletions controllers/autoscaling_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand Down
1 change: 1 addition & 0 deletions controllers/ceilometer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/autoscaling/config/wsgi-aodh.conf
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
WSGIProcessGroup {{ $endpt }}
WSGIScriptAlias / "/var/www/cgi-bin/aodh/aodh-api"
WSGIPassAuthorization On
Timeout {{ $.Timeout }}
</VirtualHost>
{{ end }}
2 changes: 2 additions & 0 deletions templates/ceilometercentral/config/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ CustomLog /dev/stdout proxy env=forwarded
SSLCertificateFile "{{ .vhost.SSLCertificateFile }}"
SSLCertificateKeyFile "{{ .vhost.SSLCertificateKeyFile }}"
{{- end }}

Timeout {{ $.Timeout }}
</VirtualHost>

0 comments on commit 7e172ac

Please sign in to comment.