File tree 3 files changed +26
-10
lines changed
images/router/haproxy/conf
3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,11 @@ backend be_edge_http_{{$cfgIdx}}
226
226
{{ else }}
227
227
balance leastconn
228
228
{{ end }}
229
+ {{ with $value := index $cfg.Annotations "router.openshift.io/haproxy.timeout"}}
230
+ {{if (matchPattern "[1-9][0-9]*(us|ms|s|m|h|d)?" $value) }}
231
+ timeout server {{$value}}
232
+ {{ end }}
233
+ {{ end }}
229
234
timeout check 5000ms
230
235
http-request set-header X-Forwarded-Host %[req.hdr(host)]
231
236
http-request set-header X-Forwarded-Port %[dst_port]
@@ -259,6 +264,11 @@ backend be_tcp_{{$cfgIdx}}
259
264
{{ else }}
260
265
balance {{ env "ROUTER_TCP_BALANCE_SCHEME" "source" }}
261
266
{{ end }}
267
+ {{ with $value := index $cfg.Annotations "router.openshift.io/haproxy.timeout"}}
268
+ {{if (matchPattern "[1-9][0-9]*(us|ms|s|m|h|d)?" $value) }}
269
+ timeout server {{$value}}
270
+ {{ end }}
271
+ {{ end }}
262
272
hash-type consistent
263
273
timeout check 5000ms
264
274
{{ range $serviceUnitName, $weight := $cfg.ServiceUnitNames }}
@@ -282,6 +292,12 @@ backend be_secure_{{$cfgIdx}}
282
292
{{ else }}
283
293
balance leastconn
284
294
{{ end }}
295
+ {{ with $value := index $cfg.Annotations "router.openshift.io/haproxy.timeout"}}
296
+ {{if (matchPattern "[1-9][0-9]*(us|ms|s|m|h|d)?" $value) }}
297
+ timeout server {{$value}}
298
+ {{ end }}
299
+ {{ end }}
300
+
285
301
timeout check 5000ms
286
302
cookie {{$cfg.RoutingKeyName}} insert indirect nocache httponly secure
287
303
{{ range $serviceUnitName, $weight := $cfg.ServiceUnitNames }}
Original file line number Diff line number Diff line change @@ -97,11 +97,11 @@ func env(name, defaultValue string) string {
97
97
func NewTemplatePlugin (cfg TemplatePluginConfig ) (* TemplatePlugin , error ) {
98
98
templateBaseName := filepath .Base (cfg .TemplatePath )
99
99
globalFuncs := template.FuncMap {
100
- "endpointsForAlias" : endpointsForAlias ,
101
- "env" : env ,
102
- "matchString " : matchString ,
103
- "isInteger" : isInteger ,
104
- "matchValues" : matchValues ,
100
+ "endpointsForAlias" : endpointsForAlias , //returns the list of valid endpoints
101
+ "env" : env , //tries to get an environment variable if it can't return a default
102
+ "matchPattern " : matchPattern , //anchors provided regular expression and evaluates against given string
103
+ "isInteger" : isInteger , //determines if a given variable is an integer
104
+ "matchValues" : matchValues , //compares a given string to a list of allowed strings
105
105
}
106
106
masterTemplate , err := template .New ("config" ).Funcs (globalFuncs ).ParseFiles (cfg .TemplatePath )
107
107
if err != nil {
Original file line number Diff line number Diff line change @@ -187,14 +187,14 @@ func matchValues(s string, allowedValues ...string) bool {
187
187
return false
188
188
}
189
189
190
- func matchString (pattern , s string ) bool {
191
- glog .V (4 ).Infof ("Matchstring called with %s and %s" , pattern , s )
192
- status , err := regexp .MatchString (pattern , s )
190
+ func matchPattern (pattern , s string ) bool {
191
+ glog .V (4 ).Infof ("matchPattern called with %s and %s" , pattern , s )
192
+ status , err := regexp .MatchString ("^(" + pattern + ")$" , s )
193
193
if err == nil {
194
- glog .V (4 ).Infof ("Matchstring returning status: %v" , status )
194
+ glog .V (4 ).Infof ("matchPattern returning status: %v" , status )
195
195
return status
196
196
}
197
- glog .Errorf ("Error with regex pattern in call to matchString : %v" , err )
197
+ glog .Errorf ("Error with regex pattern in call to matchPattern : %v" , err )
198
198
return false
199
199
}
200
200
You can’t perform that action at this time.
0 commit comments