Make proxy_next_upstream_tries configurable (#2232)
* Make proxy_next_upstream_tries configurable * Code generation
This commit is contained in:
parent
4f5fa47d27
commit
8575769781
9 changed files with 59 additions and 28 deletions
|
|
@ -33,6 +33,7 @@ type Config struct {
|
|||
CookieDomain string `json:"cookieDomain"`
|
||||
CookiePath string `json:"cookiePath"`
|
||||
NextUpstream string `json:"nextUpstream"`
|
||||
NextUpstreamTries int `json:"nextUpstreamTries"`
|
||||
ProxyRedirectFrom string `json:"proxyRedirectFrom"`
|
||||
ProxyRedirectTo string `json:"proxyRedirectTo"`
|
||||
RequestBuffering string `json:"requestBuffering"`
|
||||
|
|
@ -71,6 +72,9 @@ func (l1 *Config) Equal(l2 *Config) bool {
|
|||
if l1.NextUpstream != l2.NextUpstream {
|
||||
return false
|
||||
}
|
||||
if l1.NextUpstreamTries != l2.NextUpstreamTries {
|
||||
return false
|
||||
}
|
||||
if l1.RequestBuffering != l2.RequestBuffering {
|
||||
return false
|
||||
}
|
||||
|
|
@ -141,6 +145,11 @@ func (a proxy) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
nu = defBackend.ProxyNextUpstream
|
||||
}
|
||||
|
||||
nut, err := parser.GetIntAnnotation("proxy-next-upstream-tries", ing)
|
||||
if err != nil {
|
||||
nut = defBackend.ProxyNextUpstreamTries
|
||||
}
|
||||
|
||||
rb, err := parser.GetStringAnnotation("proxy-request-buffering", ing)
|
||||
if err != nil || rb == "" {
|
||||
rb = defBackend.ProxyRequestBuffering
|
||||
|
|
@ -161,5 +170,5 @@ func (a proxy) Parse(ing *extensions.Ingress) (interface{}, error) {
|
|||
pb = defBackend.ProxyBuffering
|
||||
}
|
||||
|
||||
return &Config{bs, ct, st, rt, bufs, cd, cp, nu, prf, prt, rb, pb}, nil
|
||||
return &Config{bs, ct, st, rt, bufs, cd, cp, nu, nut, prf, prt, rb, pb}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,15 +70,16 @@ type mockBackend struct {
|
|||
|
||||
func (m mockBackend) GetDefaultBackend() defaults.Backend {
|
||||
return defaults.Backend{
|
||||
UpstreamFailTimeout: 1,
|
||||
ProxyConnectTimeout: 10,
|
||||
ProxySendTimeout: 15,
|
||||
ProxyReadTimeout: 20,
|
||||
ProxyBufferSize: "10k",
|
||||
ProxyBodySize: "3k",
|
||||
ProxyNextUpstream: "error",
|
||||
ProxyRequestBuffering: "on",
|
||||
ProxyBuffering: "off",
|
||||
UpstreamFailTimeout: 1,
|
||||
ProxyConnectTimeout: 10,
|
||||
ProxySendTimeout: 15,
|
||||
ProxyReadTimeout: 20,
|
||||
ProxyBufferSize: "10k",
|
||||
ProxyBodySize: "3k",
|
||||
ProxyNextUpstream: "error",
|
||||
ProxyNextUpstreamTries: 3,
|
||||
ProxyRequestBuffering: "on",
|
||||
ProxyBuffering: "off",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,6 +93,7 @@ func TestProxy(t *testing.T) {
|
|||
data[parser.GetAnnotationWithPrefix("proxy-buffer-size")] = "1k"
|
||||
data[parser.GetAnnotationWithPrefix("proxy-body-size")] = "2k"
|
||||
data[parser.GetAnnotationWithPrefix("proxy-next-upstream")] = "off"
|
||||
data[parser.GetAnnotationWithPrefix("proxy-next-upstream-tries")] = "3"
|
||||
data[parser.GetAnnotationWithPrefix("proxy-request-buffering")] = "off"
|
||||
data[parser.GetAnnotationWithPrefix("proxy-buffering")] = "on"
|
||||
ing.SetAnnotations(data)
|
||||
|
|
@ -122,6 +124,9 @@ func TestProxy(t *testing.T) {
|
|||
if p.NextUpstream != "off" {
|
||||
t.Errorf("expected off as next-upstream but returned %v", p.NextUpstream)
|
||||
}
|
||||
if p.NextUpstreamTries != 3 {
|
||||
t.Errorf("expected 3 as next-upstream-tries but returned %v", p.NextUpstreamTries)
|
||||
}
|
||||
if p.RequestBuffering != "off" {
|
||||
t.Errorf("expected off as request-buffering but returned %v", p.RequestBuffering)
|
||||
}
|
||||
|
|
@ -162,6 +167,9 @@ func TestProxyWithNoAnnotation(t *testing.T) {
|
|||
if p.NextUpstream != "error" {
|
||||
t.Errorf("expected error as next-upstream but returned %v", p.NextUpstream)
|
||||
}
|
||||
if p.NextUpstreamTries != 3 {
|
||||
t.Errorf("expected 3 as next-upstream-tries but returned %v", p.NextUpstreamTries)
|
||||
}
|
||||
if p.RequestBuffering != "on" {
|
||||
t.Errorf("expected on as request-buffering but returned %v", p.RequestBuffering)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue