Skip to content

Commit

Permalink
Merge pull request #463 from fao89/OSPRH-10965
Browse files Browse the repository at this point in the history
Add configurable API Timeouts
  • Loading branch information
openshift-merge-bot[bot] authored Nov 5, 2024
2 parents 4de16f0 + 29325b1 commit bd9afac
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions api/bases/heat.openstack.org_heats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ spec:
spec:
description: HeatSpec defines the desired state of Heat
properties:
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
customServiceConfig:
description: CustomServiceConfig - customize the service config using
this parameter to change service defaults, or overwrite rendered
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/heat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ type HeatSpecBase struct {
// NodeSelector to target subset of worker nodes for running the Heat services
NodeSelector map[string]string `json:"nodeSelector,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=600
// +kubebuilder:validation:Minimum=60
// APITimeout for Route and Apache
APITimeout int `json:"apiTimeout"`

// Common input parameters for all Heat services
HeatTemplate `json:",inline"`
}
Expand Down
27 changes: 27 additions & 0 deletions api/v1beta1/heat_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,30 @@ func (r *Heat) ValidateDelete() (admission.Warnings, error) {
// TODO(user): fill in your validation logic upon object deletion.
return nil, nil
}

// SetDefaultRouteAnnotations sets HAProxy timeout values of the route
// NOTE: it is used by ctlplane webhook on openstack-operator
func (spec *HeatSpecCore) 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 heatAnno = "api.heat.openstack.org/timeout"

valHeat, okHeat := annotations[heatAnno]
valHAProxy, okHAProxy := annotations[haProxyAnno]

// Human operator set the HAProxy timeout manually
if !okHeat && okHAProxy {
return
}

// Human operator modified the HAProxy timeout manually without removing the Heat flag
if okHeat && okHAProxy && valHeat != valHAProxy {
delete(annotations, heatAnno)
return
}

timeout := fmt.Sprintf("%ds", spec.APITimeout)
annotations[heatAnno] = timeout
annotations[haProxyAnno] = timeout
}
5 changes: 5 additions & 0 deletions config/crd/bases/heat.openstack.org_heats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ spec:
spec:
description: HeatSpec defines the desired state of Heat
properties:
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
customServiceConfig:
description: CustomServiceConfig - customize the service config using
this parameter to change service defaults, or overwrite rendered
Expand Down
1 change: 1 addition & 0 deletions controllers/heat_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ func initTemplateParameters(
"MemcachedServersWithInet": mc.GetMemcachedServerListWithInetString(),
"MemcachedTLS": mc.GetMemcachedTLSSupport(),
"DatabaseConnection": mysqlConnectionString,
"Timeout": instance.Spec.APITimeout,
}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/heat/config/heat-api-httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ ErrorLog /dev/stdout
WSGIScriptAlias / "/usr/bin/heat-wsgi-api"
WSGIPassAuthorization On

Timeout 600
Timeout {{ $.Timeout }}
</VirtualHost>
{{ end }}
2 changes: 1 addition & 1 deletion templates/heat/config/heat-cfnapi-httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ ErrorLog /dev/stdout
WSGIScriptAlias / "/usr/bin/heat-wsgi-api-cfn"
WSGIPassAuthorization On

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

0 comments on commit bd9afac

Please sign in to comment.