Skip to content

Commit 00dc128

Browse files
committed
update backends and upstreams with a prefix
1 parent e044a07 commit 00dc128

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

internal/mode/static/nginx/config/servers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ func TestCreateServers(t *testing.T) {
11501150
},
11511151
{
11521152
Path: "/_ngf-internal-rule1-route0",
1153-
ProxyPass: "http://$test__route1_rule1$request_uri",
1153+
ProxyPass: "http://$group_test__route1_rule1$request_uri",
11541154
ProxySetHeaders: httpBaseHeaders,
11551155
Type: http.InternalLocationType,
11561156
Includes: internalIncludes,
@@ -2810,7 +2810,7 @@ func TestCreateProxyPass(t *testing.T) {
28102810
},
28112811
},
28122812
{
2813-
expected: "http://$ns1__bg_rule0$request_uri",
2813+
expected: "http://$group_ns1__bg_rule0$request_uri",
28142814
grp: dataplane.BackendGroup{
28152815
Source: types.NamespacedName{Namespace: "ns1", Name: "bg"},
28162816
Backends: []dataplane.Backend{

internal/mode/static/nginx/config/split_clients_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func TestExecuteSplitClients(t *testing.T) {
5252
bg3,
5353
},
5454
expStrings: []string{
55-
"split_clients $request_id $test__hr_rule0",
56-
"split_clients $request_id $test__hr_rule1",
55+
"split_clients $request_id $group_test__hr_rule0",
56+
"split_clients $request_id $group_test__hr_rule1",
5757
"50.00% test1;",
5858
"50.00% test2;",
5959
"50.00% test3;",
@@ -74,7 +74,7 @@ func TestExecuteSplitClients(t *testing.T) {
7474
},
7575
},
7676
expStrings: []string{
77-
"split_clients $request_id $test__zero_percent_rule0",
77+
"split_clients $request_id $group_test__zero_percent_rule0",
7878
"100.00% non-zero;",
7979
"# 0.00% zero;",
8080
},
@@ -188,7 +188,7 @@ func TestCreateSplitClients(t *testing.T) {
188188
},
189189
expSplitClients: []http.SplitClient{
190190
{
191-
VariableName: "test__hr_one_split_rule0",
191+
VariableName: "group_test__hr_one_split_rule0",
192192
Distributions: []http.SplitClientDistribution{
193193
{
194194
Percent: "50.00",
@@ -201,7 +201,7 @@ func TestCreateSplitClients(t *testing.T) {
201201
},
202202
},
203203
{
204-
VariableName: "test__hr_two_splits_rule0",
204+
VariableName: "group_test__hr_two_splits_rule0",
205205
Distributions: []http.SplitClientDistribution{
206206
{
207207
Percent: "50.00",
@@ -214,7 +214,7 @@ func TestCreateSplitClients(t *testing.T) {
214214
},
215215
},
216216
{
217-
VariableName: "test__hr_two_splits_rule1",
217+
VariableName: "group_test__hr_two_splits_rule1",
218218
Distributions: []http.SplitClientDistribution{
219219
{
220220
Percent: "33.33",
@@ -661,7 +661,7 @@ func TestBackendGroupName(t *testing.T) {
661661
Weight: 1,
662662
},
663663
},
664-
expName: "test__hr_rule0",
664+
expName: "group_test__hr_rule0",
665665
},
666666
{
667667
msg: "multiple invalid backends",
@@ -677,7 +677,7 @@ func TestBackendGroupName(t *testing.T) {
677677
Weight: 1,
678678
},
679679
},
680-
expName: "test__hr_rule0",
680+
expName: "group_test__hr_rule0",
681681
},
682682
}
683683

internal/mode/static/state/dataplane/types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,13 @@ type BackendGroup struct {
267267

268268
// Name returns the name of the backend group.
269269
// This name must be unique across all HTTPRoutes and all rules within the same HTTPRoute.
270+
// It is prefixed with `group_` for cases when namespace name starts with a digit. Variable names
271+
// in nginx configuration cannot start with a digit.
270272
// The RuleIdx is used to make the name unique across all rules within the same HTTPRoute.
271273
// The RuleIdx may change for a given rule if an update is made to the HTTPRoute, but it will always match the index
272274
// of the rule in the stored HTTPRoute.
273275
func (bg *BackendGroup) Name() string {
274-
return fmt.Sprintf("%s__%s_rule%d", bg.Source.Namespace, bg.Source.Name, bg.RuleIdx)
276+
return fmt.Sprintf("group_%s__%s_rule%d", bg.Source.Namespace, bg.Source.Name, bg.RuleIdx)
275277
}
276278

277279
// Backend represents a Backend for a routing rule.

site/content/how-to/monitoring/troubleshooting.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ server {
203203
proxy_set_header Upgrade "$http_upgrade";
204204
proxy_set_header Connection "$connection_upgrade";
205205
proxy_http_version 1.1;
206-
proxy_pass http://default_coffee_80$request_uri;
206+
proxy_pass http://group_default_coffee_80$request_uri;
207207
}
208208
209209
location = /coffee {
@@ -212,17 +212,17 @@ server {
212212
proxy_set_header Upgrade "$http_upgrade";
213213
proxy_set_header Connection "$connection_upgrade";
214214
proxy_http_version 1.1;
215-
proxy_pass http://default_coffee_80$request_uri;
215+
proxy_pass http://group_default_coffee_80$request_uri;
216216
}
217217
218218
location / {
219219
return 404 "";
220220
}
221221
222222
}
223-
upstream default_coffee_80 {
223+
upstream group_default_coffee_80 {
224224
random two least_conn;
225-
zone default_coffee_80 512k;
225+
zone group_default_coffee_80 512k;
226226
227227
server 10.244.0.13:8080;
228228
}
@@ -294,13 +294,15 @@ Verify that the port number (for example, `8080`) matches the port number you ha
294294
### Common errors
295295

296296
{{< bootstrap-table "table table-striped table-bordered" >}}
297+
297298
| Problem Area | Symptom | Troubleshooting Method | Common Cause |
298299
|------------------------------|----------------------------------------|---------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
299300
| Startup | NGINX Gateway Fabric fails to start. | Check logs for _nginx_ and _nginx-gateway_ containers. | Readiness probe failed. |
300301
| Resources not configured | Status missing on resources. | Check referenced resources. | Referenced resources do not belong to NGINX Gateway Fabric. |
301302
| NGINX errors | Reload failures on NGINX | Fix permissions for control plane. | Security context not configured. |
302303
| Usage reporting | Errors logs related to usage reporting | Enable usage reporting. Refer to [Usage Reporting]({{< relref "installation/usage-reporting.md" >}}) | Usage reporting disabled. |
303304
| 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.|
305+
304306
{{< /bootstrap-table >}}
305307

306308
##### NGINX fails to reload

site/content/how-to/traffic-management/routing-traffic-to-your-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ If you have any issues while testing the configuration, try the following to deb
340340
341341
location / {
342342
...
343-
proxy_pass http://default_coffee_80$request_uri; # the upstream is named default_coffee_80
343+
proxy_pass http://group_default_coffee_80$request_uri; # the upstream is named group_default_coffee_80
344344
...
345345
}
346346
}
@@ -349,7 +349,7 @@ If you have any issues while testing the configuration, try the following to deb
349349
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:
350350

351351
```nginx configuration
352-
upstream default_coffee_80 {
352+
upstream group_default_coffee_80 {
353353
...
354354
server 10.12.0.18:8080; # these should be the pod IPs of the coffee pods
355355
server 10.12.0.19:8080;

tests/suite/graceful_recovery_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ func checkContainerLogsForErrors(ngfPodName string, checkNginxLogsOnly bool) {
370370
// FIXME(salonichf5) remove this error message check
371371
// when https://github.com/nginxinc/nginx-gateway-fabric/issues/2090 is completed.
372372
expectedError2 := "no live upstreams while connecting to upstream"
373-
Expect(line).To(Or(ContainSubstring(expectedError1), ContainSubstring(expectedError2)))
373+
Expect(line).To(Or(
374+
ContainSubstring(expectedError1),
375+
ContainSubstring(expectedError2),
376+
))
374377
}
375378
}
376379

0 commit comments

Comments
 (0)