Skip to content

Commit

Permalink
Remove zone size for invalid backend ref (#1931)
Browse files Browse the repository at this point in the history
Problem: The invalid-backend-ref size of 32k is too small for some environments causing an inability of the gateway to program.

Solution: Do not specify zone size for invalid-backend-ref so that NGINX does not share upstream state across backends. This is ok for this specific upstream because we will only ever proxy to one backend.

Testing: Adjusted unit test to match. Deployed NGF with HTTPRoutes and verified it correctly still generates zone sizes for normal upstreams, an upstream missing its endpoint (service is present but no deployment/pod), and invalid-backend-ref
  • Loading branch information
bjee19 authored May 7, 2024
1 parent 2a1bef5 commit b07458d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions internal/mode/static/nginx/config/upstreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const (
ossZoneSize = "512k"
// plusZoneSize is the upstream zone size for nginx plus.
plusZoneSize = "1m"
// invalidBackendZoneSize is the upstream zone size for the invalid backend upstream.
invalidBackendZoneSize = "32k"
)

func (g GeneratorImpl) executeUpstreams(conf dataplane.Configuration) []executeResult {
Expand Down Expand Up @@ -81,9 +79,9 @@ func (g GeneratorImpl) createUpstream(up dataplane.Upstream) http.Upstream {
}

func createInvalidBackendRefUpstream() http.Upstream {
// ZoneSize is omitted since we will only ever proxy to one destination/backend.
return http.Upstream{
Name: invalidBackendRef,
ZoneSize: invalidBackendZoneSize,
Name: invalidBackendRef,
Servers: []http.UpstreamServer{
{
Address: nginx500Server,
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/nginx/config/upstreams_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const upstreamsTemplateText = `
{{ range $u := . }}
upstream {{ $u.Name }} {
random two least_conn;
{{ if $u.ZoneSize -}}
zone {{ $u.Name }} {{ $u.ZoneSize }};
{{ end -}}
{{ range $server := $u.Servers }}
server {{ $server.Address }};
{{- end }}
Expand Down
3 changes: 1 addition & 2 deletions internal/mode/static/nginx/config/upstreams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ func TestCreateUpstreams(t *testing.T) {
},
},
{
Name: invalidBackendRef,
ZoneSize: invalidBackendZoneSize,
Name: invalidBackendRef,
Servers: []http.UpstreamServer{
{
Address: nginx500Server,
Expand Down

0 comments on commit b07458d

Please sign in to comment.