Skip to content

Commit 484955d

Browse files
committed
Add configurable API Timeouts
1 parent 1d83138 commit 484955d

15 files changed

+99
-0
lines changed

api/bases/ironic.openstack.org_ironicapis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ spec:
5252
spec:
5353
description: IronicAPISpec defines the desired state of IronicAPI
5454
properties:
55+
apiTimeout:
56+
default: 60
57+
description: APITimeout for HAProxy, Apache
58+
minimum: 10
59+
type: integer
5560
containerImage:
5661
description: ContainerImage - Ironic API Container Image
5762
type: string

api/bases/ironic.openstack.org_ironicinspectors.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ spec:
5252
spec:
5353
description: IronicInspectorSpec defines the desired state of IronicInspector
5454
properties:
55+
apiTimeout:
56+
default: 60
57+
description: APITimeout for HAProxy, Apache
58+
minimum: 10
59+
type: integer
5560
containerImage:
5661
description: ContainerImage - Ironic Inspector Container Image
5762
type: string

api/bases/ironic.openstack.org_ironics.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ spec:
4848
spec:
4949
description: IronicSpec defines the desired state of Ironic
5050
properties:
51+
apiTimeout:
52+
default: 60
53+
description: APITimeout for HAProxy, Apache
54+
minimum: 10
55+
type: integer
5156
customServiceConfig:
5257
default: '# add your customization here'
5358
description: |-
@@ -545,6 +550,11 @@ spec:
545550
description: IronicInspector - Spec definition for the inspector service
546551
of this Ironic deployment
547552
properties:
553+
apiTimeout:
554+
default: 60
555+
description: APITimeout for HAProxy, Apache
556+
minimum: 10
557+
type: integer
548558
customServiceConfig:
549559
default: '# add your customization here'
550560
description: |-

api/v1beta1/ironic_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ type IronicSpecCore struct {
149149
// +kubebuilder:validation:Required
150150
// +kubebuilder:default=""
151151
StorageClass string `json:"storageClass"`
152+
153+
// +kubebuilder:validation:Optional
154+
// +kubebuilder:default=60
155+
// +kubebuilder:validation:Minimum=10
156+
// APITimeout for HAProxy, Apache
157+
APITimeout int `json:"apiTimeout"`
152158
}
153159

154160
// IronicImages to specify container images required by all ironic services

api/v1beta1/ironic_webhook.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,29 @@ func (spec *IronicSpecCore) Default() {
600600
spec.RPCTransport = "json-rpc"
601601
}
602602
}
603+
604+
// SetDefaultRouteAnnotations sets HAProxy timeout values of the route
605+
func (spec *IronicAPISpec) SetDefaultRouteAnnotations(annotations map[string]string) {
606+
const haProxyAnno = "haproxy.router.openshift.io/timeout"
607+
// Use a custom annotation to flag when the operator has set the default HAProxy timeout
608+
// The annotation func determines when to overwrite existing HAProxy timeout with the APITimeout
609+
const ironicAnno = "api.ironic.openstack.org/timeout"
610+
611+
valIronic, okIronic := annotations[ironicAnno]
612+
valHAProxy, okHAProxy := annotations[haProxyAnno]
613+
614+
// Human operator sets the HAProxy timeout manually
615+
if !okIronic && okHAProxy {
616+
return
617+
}
618+
619+
// Human operator modified the HAProxy timeout manually without removing the Ironic flag
620+
if okIronic && okHAProxy && valIronic != valHAProxy {
621+
delete(annotations, ironicAnno)
622+
return
623+
}
624+
625+
timeout := fmt.Sprintf("%ds", spec.APITimeout)
626+
annotations[ironicAnno] = timeout
627+
annotations[haProxyAnno] = timeout
628+
}

api/v1beta1/ironicapi_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ type IronicAPISpec struct {
105105
// +kubebuilder:validation:Optional
106106
// KeystoneEndpoints - Internally used Keystone API endpoints
107107
KeystoneEndpoints KeystoneEndpoints `json:"keystoneEndpoints"`
108+
109+
// +kubebuilder:validation:Optional
110+
// +kubebuilder:default=60
111+
// +kubebuilder:validation:Minimum=10
112+
// APITimeout for HAProxy, Apache
113+
APITimeout int `json:"apiTimeout"`
108114
}
109115

110116
// IronicAPIStatus defines the observed state of IronicAPI

api/v1beta1/ironicinspector_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ type IronicInspectorTemplate struct {
111111
// +operator-sdk:csv:customresourcedefinitions:type=spec
112112
// TLS - Parameters related to the TLS
113113
TLS tls.API `json:"tls,omitempty"`
114+
115+
// +kubebuilder:validation:Optional
116+
// +kubebuilder:default=60
117+
// +kubebuilder:validation:Minimum=10
118+
// APITimeout for HAProxy, Apache
119+
APITimeout int `json:"apiTimeout"`
114120
}
115121

116122
// InspectorOverrideSpec to override the generated manifest of several child resources.

config/crd/bases/ironic.openstack.org_ironicapis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ spec:
5252
spec:
5353
description: IronicAPISpec defines the desired state of IronicAPI
5454
properties:
55+
apiTimeout:
56+
default: 60
57+
description: APITimeout for HAProxy, Apache
58+
minimum: 10
59+
type: integer
5560
containerImage:
5661
description: ContainerImage - Ironic API Container Image
5762
type: string

config/crd/bases/ironic.openstack.org_ironicinspectors.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ spec:
5252
spec:
5353
description: IronicInspectorSpec defines the desired state of IronicInspector
5454
properties:
55+
apiTimeout:
56+
default: 60
57+
description: APITimeout for HAProxy, Apache
58+
minimum: 10
59+
type: integer
5560
containerImage:
5661
description: ContainerImage - Ironic Inspector Container Image
5762
type: string

config/crd/bases/ironic.openstack.org_ironics.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ spec:
4848
spec:
4949
description: IronicSpec defines the desired state of Ironic
5050
properties:
51+
apiTimeout:
52+
default: 60
53+
description: APITimeout for HAProxy, Apache
54+
minimum: 10
55+
type: integer
5156
customServiceConfig:
5257
default: '# add your customization here'
5358
description: |-
@@ -545,6 +550,11 @@ spec:
545550
description: IronicInspector - Spec definition for the inspector service
546551
of this Ironic deployment
547552
properties:
553+
apiTimeout:
554+
default: 60
555+
description: APITimeout for HAProxy, Apache
556+
minimum: 10
557+
type: integer
548558
customServiceConfig:
549559
default: '# add your customization here'
550560
description: |-

0 commit comments

Comments
 (0)