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 #282

Merged
merged 1 commit into from
Jun 7, 2024
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
4 changes: 4 additions & 0 deletions api/bases/manila.openstack.org_manilas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ spec:
type: object
spec:
properties:
apiTimeout:
default: 60
minimum: 10
type: integer
customServiceConfig:
default: '# add your customization here'
type: string
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/manila_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ type ManilaSpecBase struct {
// +kubebuilder:validation:Optional
// DBPurge parameters -
DBPurge DBPurge `json:"dbPurge,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=60
// +kubebuilder:validation:Minimum=10
// APITimeout for HAProxy, Apache, and rpc_response_timeout
APITimeout int `json:"apiTimeout"`
}

// ManilaStatus defines the observed state of Manila
Expand Down
26 changes: 26 additions & 0 deletions api/v1beta1/manila_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,29 @@ func (r *Manila) 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
func (spec *ManilaSpecCore) 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 manilaAnno = "api.manila.openstack.org/timeout"

valManila, okManila := annotations[manilaAnno]
valHAProxy, okHAProxy := annotations[haProxyAnno]

// Human operator set the HAProxy timeout manually
if (!okManila && okHAProxy) {
return
}

// Human operator modified the HAProxy timeout manually without removing the Manila flag
if (okManila && okHAProxy && valManila != valHAProxy) {
delete(annotations, manilaAnno)
return
}

timeout := fmt.Sprintf("%ds", spec.APITimeout)
annotations[manilaAnno] = timeout
annotations[haProxyAnno] = timeout
}
4 changes: 4 additions & 0 deletions config/crd/bases/manila.openstack.org_manilas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ spec:
type: object
spec:
properties:
apiTimeout:
default: 60
minimum: 10
type: integer
customServiceConfig:
default: '# add your customization here'
type: string
Expand Down
1 change: 1 addition & 0 deletions controllers/manila_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ func (r *ManilaReconciler) generateServiceConfig(
instance.Status.DatabaseHostname,
manila.DatabaseCRName),
"MemcachedServersWithInet": memcached.GetMemcachedServerListWithInetString(),
"TimeOut": instance.Spec.APITimeout,
}

// create httpd vhost template parameters
Expand Down
3 changes: 3 additions & 0 deletions templates/manila/config/00-config.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ auth_strategy=keystone
control_exchange=openstack
api_paste_config=/etc/manila/api-paste.ini

# Keep the RPC call timeout in sync with HAProxy and Apache timeouts
rpc_response_timeout = {{ .TimeOut }}

[cinder]
[cors]

Expand Down
2 changes: 2 additions & 0 deletions templates/manila/config/10-manila_wsgi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Require all granted
</Directory>

Timeout {{ $.TimeOut }}

## Logging
ErrorLog /dev/stdout
ServerSignature Off
Expand Down
Loading