@@ -37,6 +37,7 @@ type SwiftDefaults struct {
3737 ContainerContainerImageURL string
3838 ObjectContainerImageURL string
3939 ProxyContainerImageURL string
40+ ProxyAPITimeout int
4041}
4142
4243var swiftDefaults SwiftDefaults
@@ -100,6 +101,10 @@ func (spec *SwiftSpec) Default() {
100101 if spec .SwiftProxy .ContainerImageProxy == "" {
101102 spec .SwiftProxy .ContainerImageProxy = swiftDefaults .ProxyContainerImageURL
102103 }
104+
105+ if spec .SwiftProxy .APITimeout == 0 {
106+ spec .SwiftProxy .APITimeout = swiftDefaults .ProxyAPITimeout
107+ }
103108}
104109
105110// Default - set defaults for this Swift core spec (this version is used by OpenStackControlplane webhooks)
@@ -312,3 +317,29 @@ func (spec *SwiftSpec) ValidateSwiftTopology(basePath *field.Path, namespace str
312317
313318 return allErrs
314319}
320+
321+ // SetDefaultRouteAnnotations sets HAProxy timeout values of the route
322+ func (spec * SwiftSpecCore ) SetDefaultRouteAnnotations (annotations map [string ]string ) {
323+ const haProxyAnno = "haproxy.router.openshift.io/timeout"
324+ // Use a custom annotation to flag when the operator has set the default HAProxy timeout
325+ // With the annotation func determines when to overwrite existing HAProxy timeout with the APITimeout
326+ const swiftAnno = "api.swift.openstack.org/timeout"
327+
328+ valSwift , okSwift := annotations [swiftAnno ]
329+ valHAProxy , okHAProxy := annotations [haProxyAnno ]
330+
331+ // Human operator set the HAProxy timeout manually
332+ if ! okSwift && okHAProxy {
333+ return
334+ }
335+
336+ // Human operator modified the HAProxy timeout manually without removing the Swift flag
337+ if okSwift && okHAProxy && valSwift != valHAProxy {
338+ delete (annotations , swiftAnno )
339+ return
340+ }
341+
342+ timeout := fmt .Sprintf ("%ds" , spec .SwiftProxy .APITimeout )
343+ annotations [swiftAnno ] = timeout
344+ annotations [haProxyAnno ] = timeout
345+ }
0 commit comments