Skip to content

Commit

Permalink
Merge pull request #282 from Akrog/apiTimeout
Browse files Browse the repository at this point in the history
Add configurable API Timeouts
  • Loading branch information
openshift-merge-bot[bot] authored Jun 7, 2024
2 parents bb1bd22 + 25d0900 commit 84eee55
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 0 deletions.
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

0 comments on commit 84eee55

Please sign in to comment.