Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable API Timeouts #463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +265 to +266
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are these being used? This function isn't called from anywhere that I can see, and it doesn't return anything. Should we be taking in a pointer to an annotations map instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
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 }}
Loading