From 3565083eb2df747362727ee7e414e525b9b75733 Mon Sep 17 00:00:00 2001 From: Saloni Date: Fri, 25 Oct 2024 12:36:17 -0700 Subject: [PATCH] update backends and upstreams with a prefix --- internal/mode/static/nginx/config/servers.go | 8 +- .../mode/static/nginx/config/servers_test.go | 74 +++++++++---------- .../mode/static/nginx/config/shared/config.go | 1 + .../mode/static/nginx/config/split_clients.go | 9 ++- .../static/nginx/config/split_clients_test.go | 54 +++++++------- .../static/nginx/config/stream_servers.go | 2 +- .../nginx/config/stream_servers_test.go | 7 +- .../mode/static/nginx/config/upstreams.go | 5 +- .../static/nginx/config/upstreams_test.go | 18 ++--- .../how-to/monitoring/troubleshooting.md | 10 ++- .../routing-traffic-to-your-app.md | 4 +- tests/suite/graceful_recovery_test.go | 7 +- 12 files changed, 109 insertions(+), 90 deletions(-) diff --git a/internal/mode/static/nginx/config/servers.go b/internal/mode/static/nginx/config/servers.go index 33ea858f31..8a2042962e 100644 --- a/internal/mode/static/nginx/config/servers.go +++ b/internal/mode/static/nginx/config/servers.go @@ -738,11 +738,15 @@ func createProxyPass( } backendName := backendGroupName(backendGroup) + // The proxy_pass directive value starts with the namespace name of the backend group. + // We prefix it with "upstream_" to avoid potential situation where the namespace name starts + // with a number, which is not allowed in a variable name in nginx.conf + updatedBackendName := shared.UpstreamPrefix + backendName if backendGroupNeedsSplit(backendGroup) { - return protocol + "://$" + convertStringToSafeVariableName(backendName) + requestURI + return protocol + "://$" + convertStringToSafeVariableName(updatedBackendName) + requestURI } - return protocol + "://" + backendName + requestURI + return protocol + "://" + updatedBackendName + requestURI } func createMatchLocation(path string, grpc bool) http.Location { diff --git a/internal/mode/static/nginx/config/servers_test.go b/internal/mode/static/nginx/config/servers_test.go index f3e523a4c0..d4e840665b 100644 --- a/internal/mode/static/nginx/config/servers_test.go +++ b/internal/mode/static/nginx/config/servers_test.go @@ -1123,21 +1123,21 @@ func TestCreateServers(t *testing.T) { }, { Path: "/_ngf-internal-rule0-route0", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.InternalLocationType, Includes: internalIncludes, }, { Path: "/_ngf-internal-rule0-route1", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.InternalLocationType, Includes: internalIncludes, }, { Path: "/_ngf-internal-rule0-route2", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.InternalLocationType, Includes: internalIncludes, @@ -1150,28 +1150,28 @@ func TestCreateServers(t *testing.T) { }, { Path: "/_ngf-internal-rule1-route0", - ProxyPass: "http://$test__route1_rule1$request_uri", + ProxyPass: "http://$upstream_test__route1_rule1$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.InternalLocationType, Includes: internalIncludes, }, { Path: "/path-only/", - ProxyPass: "http://invalid-backend-ref$request_uri", + ProxyPass: "http://upstream_invalid-backend-ref$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, Includes: externalIncludes, }, { Path: "= /path-only", - ProxyPass: "http://invalid-backend-ref$request_uri", + ProxyPass: "http://upstream_invalid-backend-ref$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, Includes: externalIncludes, }, { Path: "/backend-tls-policy/", - ProxyPass: "https://test_btp_80$request_uri", + ProxyPass: "https://upstream_test_btp_80$request_uri", ProxySetHeaders: httpBaseHeaders, ProxySSLVerify: &http.ProxySSLVerify{ Name: "test-btp.example.com", @@ -1182,7 +1182,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "= /backend-tls-policy", - ProxyPass: "https://test_btp_80$request_uri", + ProxyPass: "https://upstream_test_btp_80$request_uri", ProxySetHeaders: httpBaseHeaders, ProxySSLVerify: &http.ProxySSLVerify{ Name: "test-btp.example.com", @@ -1251,7 +1251,7 @@ func TestCreateServers(t *testing.T) { { Path: "/rewrite/", Rewrites: []string{"^ /replacement break"}, - ProxyPass: "http://test_foo_80", + ProxyPass: "http://upstream_test_foo_80", ProxySetHeaders: rewriteProxySetHeaders, Type: http.ExternalLocationType, Includes: externalIncludes, @@ -1259,7 +1259,7 @@ func TestCreateServers(t *testing.T) { { Path: "= /rewrite", Rewrites: []string{"^ /replacement break"}, - ProxyPass: "http://test_foo_80", + ProxyPass: "http://upstream_test_foo_80", ProxySetHeaders: rewriteProxySetHeaders, Type: http.ExternalLocationType, Includes: externalIncludes, @@ -1279,7 +1279,7 @@ func TestCreateServers(t *testing.T) { { Path: "/_ngf-internal-rule8-route0", Rewrites: []string{"^ $request_uri", "^/rewrite-with-headers(.*)$ /prefix-replacement$1 break"}, - ProxyPass: "http://test_foo_80", + ProxyPass: "http://upstream_test_foo_80", ProxySetHeaders: rewriteProxySetHeaders, Type: http.InternalLocationType, Includes: internalIncludes, @@ -1322,7 +1322,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "= /exact", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, Includes: externalIncludes, @@ -1335,14 +1335,14 @@ func TestCreateServers(t *testing.T) { }, { Path: "/_ngf-internal-rule12-route0", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.InternalLocationType, Includes: internalIncludes, }, { Path: "/proxy-set-headers/", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: []http.Header{ { Name: "my-header", @@ -1396,7 +1396,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "= /proxy-set-headers", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: []http.Header{ { Name: "my-header", @@ -1450,7 +1450,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "= /grpc/method", - ProxyPass: "grpc://test_foo_80", + ProxyPass: "grpc://upstream_test_foo_80", GRPC: true, ProxySetHeaders: grpcBaseHeaders, Type: http.ExternalLocationType, @@ -1458,7 +1458,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "= /grpc-with-backend-tls-policy/method", - ProxyPass: "grpcs://test_btp_80", + ProxyPass: "grpcs://upstream_test_btp_80", ProxySSLVerify: &http.ProxySSLVerify{ Name: "test-btp.example.com", TrustedCertificate: "/etc/nginx/secrets/test-btp.crt", @@ -1470,7 +1470,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "= /include-path-only-match", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, Includes: externalIncludes, @@ -1483,7 +1483,7 @@ func TestCreateServers(t *testing.T) { }, { Path: "/_ngf-internal-rule17-route0", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Rewrites: []string{"^ $request_uri break"}, Type: http.InternalLocationType, @@ -1625,13 +1625,13 @@ func TestCreateServersConflicts(t *testing.T) { expLocs: []http.Location{ { Path: "/coffee/", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "= /coffee", - ProxyPass: "http://test_bar_80$request_uri", + ProxyPass: "http://upstream_test_bar_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, @@ -1665,13 +1665,13 @@ func TestCreateServersConflicts(t *testing.T) { expLocs: []http.Location{ { Path: "= /coffee", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "/coffee/", - ProxyPass: "http://test_bar_80$request_uri", + ProxyPass: "http://upstream_test_bar_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, @@ -1715,13 +1715,13 @@ func TestCreateServersConflicts(t *testing.T) { expLocs: []http.Location{ { Path: "/coffee/", - ProxyPass: "http://test_bar_80$request_uri", + ProxyPass: "http://upstream_test_bar_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "= /coffee", - ProxyPass: "http://test_baz_80$request_uri", + ProxyPass: "http://upstream_test_baz_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, @@ -2163,13 +2163,13 @@ func TestCreateLocationsRootPath(t *testing.T) { expLocations: []http.Location{ { Path: "/path-1", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "/path-2", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, @@ -2188,19 +2188,19 @@ func TestCreateLocationsRootPath(t *testing.T) { expLocations: []http.Location{ { Path: "/path-1", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "/path-2", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "/grpc", - ProxyPass: "grpc://test_foo_80", + ProxyPass: "grpc://upstream_test_foo_80", GRPC: true, ProxySetHeaders: grpcBaseHeaders, Type: http.ExternalLocationType, @@ -2219,19 +2219,19 @@ func TestCreateLocationsRootPath(t *testing.T) { expLocations: []http.Location{ { Path: "/path-1", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "/path-2", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, { Path: "/", - ProxyPass: "http://test_foo_80$request_uri", + ProxyPass: "http://upstream_test_foo_80$request_uri", ProxySetHeaders: httpBaseHeaders, Type: http.ExternalLocationType, }, @@ -2798,7 +2798,7 @@ func TestCreateProxyPass(t *testing.T) { GRPC bool }{ { - expected: "http://10.0.0.1:80$request_uri", + expected: "http://upstream_10.0.0.1:80$request_uri", grp: dataplane.BackendGroup{ Backends: []dataplane.Backend{ { @@ -2810,7 +2810,7 @@ func TestCreateProxyPass(t *testing.T) { }, }, { - expected: "http://$ns1__bg_rule0$request_uri", + expected: "http://$upstream_ns1__bg_rule0$request_uri", grp: dataplane.BackendGroup{ Source: types.NamespacedName{Namespace: "ns1", Name: "bg"}, Backends: []dataplane.Backend{ @@ -2828,7 +2828,7 @@ func TestCreateProxyPass(t *testing.T) { }, }, { - expected: "http://10.0.0.1:80", + expected: "http://upstream_10.0.0.1:80", rewrite: &dataplane.HTTPURLRewriteFilter{ Path: &dataplane.HTTPPathModifier{}, }, @@ -2843,7 +2843,7 @@ func TestCreateProxyPass(t *testing.T) { }, }, { - expected: "grpc://10.0.0.1:80", + expected: "grpc://upstream_10.0.0.1:80", grp: dataplane.BackendGroup{ Backends: []dataplane.Backend{ { diff --git a/internal/mode/static/nginx/config/shared/config.go b/internal/mode/static/nginx/config/shared/config.go index c38acb7e75..664b45e9b5 100644 --- a/internal/mode/static/nginx/config/shared/config.go +++ b/internal/mode/static/nginx/config/shared/config.go @@ -30,6 +30,7 @@ type RewriteClientIPSettings struct { const ( ProxyProtocolDirective = " proxy_protocol" + UpstreamPrefix = "upstream_" ) // Include defines a file that's included via the include directive. diff --git a/internal/mode/static/nginx/config/split_clients.go b/internal/mode/static/nginx/config/split_clients.go index 0e196a2065..a7f574c4fa 100644 --- a/internal/mode/static/nginx/config/split_clients.go +++ b/internal/mode/static/nginx/config/split_clients.go @@ -7,6 +7,7 @@ import ( "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/http" + "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/shared" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane" ) @@ -43,8 +44,10 @@ func createSplitClients(backendGroups []dataplane.BackendGroup) []http.SplitClie continue } + // prefixing the splitClients variable name with "upstream_" + // to match the backend name in the proxy_pass directive. splitClients = append(splitClients, http.SplitClient{ - VariableName: convertStringToSafeVariableName(group.Name()), + VariableName: shared.UpstreamPrefix + convertStringToSafeVariableName(group.Name()), Distributions: distributions, }) } @@ -88,7 +91,7 @@ func createSplitClientDistributions(group dataplane.BackendGroup) []http.SplitCl distributions = append(distributions, http.SplitClientDistribution{ Percent: fmt.Sprintf("%.2f", percentage), - Value: getSplitClientValue(b), + Value: shared.UpstreamPrefix + getSplitClientValue(b), }) } @@ -98,7 +101,7 @@ func createSplitClientDistributions(group dataplane.BackendGroup) []http.SplitCl distributions = append(distributions, http.SplitClientDistribution{ Percent: fmt.Sprintf("%.2f", availablePercentage), - Value: getSplitClientValue(lastBackend), + Value: shared.UpstreamPrefix + getSplitClientValue(lastBackend), }) return distributions diff --git a/internal/mode/static/nginx/config/split_clients_test.go b/internal/mode/static/nginx/config/split_clients_test.go index 44eebf359b..4709a7d82f 100644 --- a/internal/mode/static/nginx/config/split_clients_test.go +++ b/internal/mode/static/nginx/config/split_clients_test.go @@ -52,12 +52,12 @@ func TestExecuteSplitClients(t *testing.T) { bg3, }, expStrings: []string{ - "split_clients $request_id $test__hr_rule0", - "split_clients $request_id $test__hr_rule1", - "50.00% test1;", - "50.00% test2;", - "50.00% test3;", - "50.00% test4;", + "split_clients $request_id $upstream_test__hr_rule0", + "split_clients $request_id $upstream_test__hr_rule1", + "50.00% upstream_test1;", + "50.00% upstream_test2;", + "50.00% upstream_test3;", + "50.00% upstream_test4;", }, notExpStrings: []string{"no-split", "#"}, }, @@ -74,9 +74,9 @@ func TestExecuteSplitClients(t *testing.T) { }, }, expStrings: []string{ - "split_clients $request_id $test__zero_percent_rule0", - "100.00% non-zero;", - "# 0.00% zero;", + "split_clients $request_id $upstream_test__zero_percent_rule0", + "100.00% upstream_non-zero;", + "# 0.00% upstream_zero;", }, notExpStrings: nil, }, @@ -188,45 +188,45 @@ func TestCreateSplitClients(t *testing.T) { }, expSplitClients: []http.SplitClient{ { - VariableName: "test__hr_one_split_rule0", + VariableName: "upstream_test__hr_one_split_rule0", Distributions: []http.SplitClientDistribution{ { Percent: "50.00", - Value: "one-split-1", + Value: "upstream_one-split-1", }, { Percent: "50.00", - Value: "one-split-2", + Value: "upstream_one-split-2", }, }, }, { - VariableName: "test__hr_two_splits_rule0", + VariableName: "upstream_test__hr_two_splits_rule0", Distributions: []http.SplitClientDistribution{ { Percent: "50.00", - Value: "two-split-1", + Value: "upstream_two-split-1", }, { Percent: "50.00", - Value: "two-split-2", + Value: "upstream_two-split-2", }, }, }, { - VariableName: "test__hr_two_splits_rule1", + VariableName: "upstream_test__hr_two_splits_rule1", Distributions: []http.SplitClientDistribution{ { Percent: "33.33", - Value: "two-split-3", + Value: "upstream_two-split-3", }, { Percent: "33.33", - Value: "two-split-4", + Value: "upstream_two-split-4", }, { Percent: "33.34", - Value: "two-split-5", + Value: "upstream_two-split-5", }, }, }, @@ -313,11 +313,11 @@ func TestCreateSplitClientDistributions(t *testing.T) { expDistributions: []http.SplitClientDistribution{ { Percent: "50.00", - Value: "one", + Value: "upstream_one", }, { Percent: "50.00", - Value: "two", + Value: "upstream_two", }, }, }, @@ -343,15 +343,15 @@ func TestCreateSplitClientDistributions(t *testing.T) { expDistributions: []http.SplitClientDistribution{ { Percent: "20.00", - Value: "one", + Value: "upstream_one", }, { Percent: "30.00", - Value: "two", + Value: "upstream_two", }, { Percent: "50.00", - Value: "three", + Value: "upstream_three", }, }, }, @@ -377,15 +377,15 @@ func TestCreateSplitClientDistributions(t *testing.T) { expDistributions: []http.SplitClientDistribution{ { Percent: "33.33", - Value: "one", + Value: "upstream_one", }, { Percent: "33.33", - Value: "two", + Value: "upstream_two", }, { Percent: "33.34", // the last backend gets the remainder. - Value: "three", + Value: "upstream_three", }, }, }, diff --git a/internal/mode/static/nginx/config/stream_servers.go b/internal/mode/static/nginx/config/stream_servers.go index b6cb763cb5..4c92bad645 100644 --- a/internal/mode/static/nginx/config/stream_servers.go +++ b/internal/mode/static/nginx/config/stream_servers.go @@ -50,7 +50,7 @@ func createStreamServers(conf dataplane.Configuration) []stream.Server { streamServer := stream.Server{ Listen: getSocketNameTLS(server.Port, server.Hostname), StatusZone: server.Hostname, - ProxyPass: server.UpstreamName, + ProxyPass: shared.UpstreamPrefix + server.UpstreamName, IsSocket: true, } // set rewriteClientIP settings as this is a socket stream server diff --git a/internal/mode/static/nginx/config/stream_servers_test.go b/internal/mode/static/nginx/config/stream_servers_test.go index 1e5c8b6606..21cb6f3705 100644 --- a/internal/mode/static/nginx/config/stream_servers_test.go +++ b/internal/mode/static/nginx/config/stream_servers_test.go @@ -7,6 +7,7 @@ import ( . "github.com/onsi/gomega" + "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/shared" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/stream" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/resolver" @@ -181,21 +182,21 @@ func TestCreateStreamServers(t *testing.T) { expectedStreamServers := []stream.Server{ { Listen: getSocketNameTLS(conf.TLSPassthroughServers[0].Port, conf.TLSPassthroughServers[0].Hostname), - ProxyPass: conf.TLSPassthroughServers[0].UpstreamName, + ProxyPass: shared.UpstreamPrefix + conf.TLSPassthroughServers[0].UpstreamName, StatusZone: conf.TLSPassthroughServers[0].Hostname, SSLPreread: false, IsSocket: true, }, { Listen: getSocketNameTLS(conf.TLSPassthroughServers[1].Port, conf.TLSPassthroughServers[1].Hostname), - ProxyPass: conf.TLSPassthroughServers[1].UpstreamName, + ProxyPass: shared.UpstreamPrefix + conf.TLSPassthroughServers[1].UpstreamName, StatusZone: conf.TLSPassthroughServers[1].Hostname, SSLPreread: false, IsSocket: true, }, { Listen: getSocketNameTLS(conf.TLSPassthroughServers[2].Port, conf.TLSPassthroughServers[2].Hostname), - ProxyPass: conf.TLSPassthroughServers[2].UpstreamName, + ProxyPass: shared.UpstreamPrefix + conf.TLSPassthroughServers[2].UpstreamName, StatusZone: conf.TLSPassthroughServers[2].Hostname, SSLPreread: false, IsSocket: true, diff --git a/internal/mode/static/nginx/config/upstreams.go b/internal/mode/static/nginx/config/upstreams.go index 88c66c47fd..bdd89fcaff 100644 --- a/internal/mode/static/nginx/config/upstreams.go +++ b/internal/mode/static/nginx/config/upstreams.go @@ -6,6 +6,7 @@ import ( "github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/http" + "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/shared" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/stream" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane" ) @@ -129,8 +130,10 @@ func (g GeneratorImpl) createUpstream(up dataplane.Upstream) http.Upstream { } } + // update the upstream name to include the "upstream_" prefix, + // to match the backend name in the proxy_pass directive. return http.Upstream{ - Name: up.Name, + Name: shared.UpstreamPrefix + up.Name, ZoneSize: zoneSize, Servers: upstreamServers, } diff --git a/internal/mode/static/nginx/config/upstreams_test.go b/internal/mode/static/nginx/config/upstreams_test.go index 5b3a8268a3..384ba29b21 100644 --- a/internal/mode/static/nginx/config/upstreams_test.go +++ b/internal/mode/static/nginx/config/upstreams_test.go @@ -50,10 +50,10 @@ func TestExecuteUpstreams(t *testing.T) { } expectedSubStrings := []string{ - "upstream up1", - "upstream up2", + "upstream upstream_up1", + "upstream upstream_up2", "upstream up3", - "upstream up4-ipv6", + "upstream upstream_up4-ipv6", "upstream invalid-backend-ref", "server 10.0.0.0:80;", "server 11.0.0.0:80;", @@ -120,7 +120,7 @@ func TestCreateUpstreams(t *testing.T) { expUpstreams := []http.Upstream{ { - Name: "up1", + Name: "upstream_up1", ZoneSize: ossZoneSize, Servers: []http.UpstreamServer{ { @@ -135,7 +135,7 @@ func TestCreateUpstreams(t *testing.T) { }, }, { - Name: "up2", + Name: "upstream_up2", ZoneSize: ossZoneSize, Servers: []http.UpstreamServer{ { @@ -153,7 +153,7 @@ func TestCreateUpstreams(t *testing.T) { }, }, { - Name: "up4-ipv6", + Name: "upstream_up4-ipv6", ZoneSize: ossZoneSize, Servers: []http.UpstreamServer{ { @@ -235,7 +235,7 @@ func TestCreateUpstream(t *testing.T) { }, }, expectedUpstream: http.Upstream{ - Name: "multiple-endpoints", + Name: "upstream_multiple-endpoints", ZoneSize: ossZoneSize, Servers: []http.UpstreamServer{ { @@ -263,7 +263,7 @@ func TestCreateUpstream(t *testing.T) { }, }, expectedUpstream: http.Upstream{ - Name: "endpoint-ipv6", + Name: "upstream_endpoint-ipv6", ZoneSize: ossZoneSize, Servers: []http.UpstreamServer{ { @@ -299,7 +299,7 @@ func TestCreateUpstreamPlus(t *testing.T) { }, } expectedUpstream := http.Upstream{ - Name: "multiple-endpoints", + Name: "upstream_multiple-endpoints", ZoneSize: plusZoneSize, Servers: []http.UpstreamServer{ { diff --git a/site/content/how-to/monitoring/troubleshooting.md b/site/content/how-to/monitoring/troubleshooting.md index c14d72ea83..f19f8c8382 100644 --- a/site/content/how-to/monitoring/troubleshooting.md +++ b/site/content/how-to/monitoring/troubleshooting.md @@ -203,7 +203,7 @@ server { proxy_set_header Upgrade "$http_upgrade"; proxy_set_header Connection "$connection_upgrade"; proxy_http_version 1.1; - proxy_pass http://default_coffee_80$request_uri; + proxy_pass http://upstream_default_coffee_80$request_uri; } location = /coffee { @@ -212,7 +212,7 @@ server { proxy_set_header Upgrade "$http_upgrade"; proxy_set_header Connection "$connection_upgrade"; proxy_http_version 1.1; - proxy_pass http://default_coffee_80$request_uri; + proxy_pass http://upstream_default_coffee_80$request_uri; } location / { @@ -220,9 +220,9 @@ server { } } -upstream default_coffee_80 { +upstream upstream_default_coffee_80 { random two least_conn; - zone default_coffee_80 512k; + zone upstream_default_coffee_80 512k; server 10.244.0.13:8080; } @@ -294,6 +294,7 @@ Verify that the port number (for example, `8080`) matches the port number you ha ### Common errors {{< bootstrap-table "table table-striped table-bordered" >}} + | Problem Area | Symptom | Troubleshooting Method | Common Cause | |------------------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------| | Startup | NGINX Gateway Fabric fails to start. | Check logs for _nginx_ and _nginx-gateway_ containers. | Readiness probe failed. | @@ -301,6 +302,7 @@ Verify that the port number (for example, `8080`) matches the port number you ha | NGINX errors | Reload failures on NGINX | Fix permissions for control plane. | Security context not configured. | | Usage reporting | Errors logs related to usage reporting | Enable usage reporting. Refer to [Usage Reporting]({{< relref "installation/usage-reporting.md" >}}) | Usage reporting disabled. | | Client Settings | Request entity too large error | Adjust client settings. Refer to [Client Settings Policy]({{< relref "../traffic-management/client-settings.md" >}}) | Payload is greater than the [`client_max_body_size`](https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size) value.| + {{< /bootstrap-table >}} ##### NGINX fails to reload diff --git a/site/content/how-to/traffic-management/routing-traffic-to-your-app.md b/site/content/how-to/traffic-management/routing-traffic-to-your-app.md index 784c8b9365..1c42a9a662 100644 --- a/site/content/how-to/traffic-management/routing-traffic-to-your-app.md +++ b/site/content/how-to/traffic-management/routing-traffic-to-your-app.md @@ -340,7 +340,7 @@ If you have any issues while testing the configuration, try the following to deb location / { ... - proxy_pass http://default_coffee_80$request_uri; # the upstream is named default_coffee_80 + proxy_pass http://upstream_default_coffee_80$request_uri; # the upstream is named upstream_default_coffee_80 ... } } @@ -349,7 +349,7 @@ If you have any issues while testing the configuration, try the following to deb There should also be an upstream block with a name that matches the upstream in the **proxy_pass** directive. This upstream block should contain the pod IPs of the **coffee** pods: ```nginx configuration - upstream default_coffee_80 { + upstream upstream_default_coffee_80 { ... server 10.12.0.18:8080; # these should be the pod IPs of the coffee pods server 10.12.0.19:8080; diff --git a/tests/suite/graceful_recovery_test.go b/tests/suite/graceful_recovery_test.go index 30fc3b79da..aa30e77a16 100644 --- a/tests/suite/graceful_recovery_test.go +++ b/tests/suite/graceful_recovery_test.go @@ -370,7 +370,12 @@ func checkContainerLogsForErrors(ngfPodName string, checkNginxLogsOnly bool) { // FIXME(salonichf5) remove this error message check // when https://github.com/nginxinc/nginx-gateway-fabric/issues/2090 is completed. expectedError2 := "no live upstreams while connecting to upstream" - Expect(line).To(Or(ContainSubstring(expectedError1), ContainSubstring(expectedError2))) + expectedError3 := "no resolver defined to resolve" + Expect(line).To(Or( + ContainSubstring(expectedError1), + ContainSubstring(expectedError2), + ContainSubstring(expectedError3), + )) } }