Skip to content

Commit f62ed37

Browse files
committed
Fix failing handler test
1 parent 7ee9489 commit f62ed37

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

charts/nginx-gateway-fabric/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,17 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
259259
| `certGenerator.serverTLSSecretName` | The name of the Secret containing TLS CA, certificate, and key for the NGINX Gateway Fabric control plane to securely communicate with the NGINX Agent. Must exist in the same namespace that the NGINX Gateway Fabric control plane is running in (default namespace: nginx-gateway). | string | `"server-tls"` |
260260
| `clusterDomain` | The DNS cluster domain of your Kubernetes cluster. | string | `"cluster.local"` |
261261
| `nginx` | The nginx section contains the configuration for all NGINX data plane deployments installed by the NGINX Gateway Fabric control plane. | object | `{"config":{},"container":{},"debug":false,"image":{"pullPolicy":"Always","repository":"ghcr.io/nginx/nginx-gateway-fabric/nginx","tag":"edge"},"imagePullSecret":"","imagePullSecrets":[],"kind":"deployment","plus":false,"pod":{},"replicas":1,"service":{"annotations":{},"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"},"usage":{"caSecretName":"","clientSSLSecretName":"","endpoint":"","resolver":"","secretName":"nplus-license","skipVerify":false}}` |
262-
| `nginx.config` | The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways. | object | `{}` |
263-
| `nginx.container` | The container configuration for the NGINX container. This is applied globally to all Gateways. | object | `{}` |
262+
| `nginx.config` | The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
263+
| `nginx.container` | The container configuration for the NGINX container. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
264264
| `nginx.debug` | Enable debugging for NGINX. Uses the nginx-debug binary. The NGINX error log level should be set to debug in the NginxProxy resource. | bool | `false` |
265265
| `nginx.image.repository` | The NGINX image to use. | string | `"ghcr.io/nginx/nginx-gateway-fabric/nginx"` |
266266
| `nginx.imagePullSecret` | The name of the secret containing docker registry credentials. Secret must exist in the same namespace as the helm release. The control plane will copy this secret into any namespace where NGINX is deployed. | string | `""` |
267267
| `nginx.imagePullSecrets` | A list of secret names containing docker registry credentials. Secrets must exist in the same namespace as the helm release. The control plane will copy these secrets into any namespace where NGINX is deployed. | list | `[]` |
268268
| `nginx.kind` | The kind of NGINX deployment. | string | `"deployment"` |
269269
| `nginx.plus` | Is NGINX Plus image being used. | bool | `false` |
270-
| `nginx.pod` | The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways. | object | `{}` |
270+
| `nginx.pod` | The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{}` |
271271
| `nginx.replicas` | The number of replicas of the NGINX Deployment. | int | `1` |
272-
| `nginx.service` | The service configuration for the NGINX data plane. This is applied globally to all Gateways. | object | `{"annotations":{},"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"}` |
272+
| `nginx.service` | The service configuration for the NGINX data plane. This is applied globally to all Gateways managed by this instance of NGINX Gateway Fabric. | object | `{"annotations":{},"externalTrafficPolicy":"Local","loadBalancerClass":"","loadBalancerIP":"","loadBalancerSourceRanges":[],"nodePorts":[],"type":"LoadBalancer"}` |
273273
| `nginx.service.annotations` | The annotations of the NGINX data plane service. | object | `{}` |
274274
| `nginx.service.externalTrafficPolicy` | The externalTrafficPolicy of the service. The value Local preserves the client source IP. | string | `"Local"` |
275275
| `nginx.service.loadBalancerClass` | LoadBalancerClass is the class of the load balancer implementation this Service belongs to. Requires nginx.service.type set to LoadBalancer. | string | `""` |

charts/nginx-gateway-fabric/values.schema.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"description": "The nginx section contains the configuration for all NGINX data plane deployments\ninstalled by the NGINX Gateway Fabric control plane.",
5454
"properties": {
5555
"config": {
56-
"description": "The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways.",
56+
"description": "The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways\nmanaged by this instance of NGINX Gateway Fabric.",
5757
"properties": {
5858
"disableHTTP2": {
5959
"description": "DisableHTTP2 defines if http2 should be disabled for all servers.",
@@ -266,7 +266,7 @@
266266
"type": "object"
267267
},
268268
"container": {
269-
"description": "The container configuration for the NGINX container. This is applied globally to all Gateways.",
269+
"description": "The container configuration for the NGINX container. This is applied globally to all Gateways managed by this\ninstance of NGINX Gateway Fabric.",
270270
"required": [],
271271
"title": "container",
272272
"type": "object"
@@ -341,7 +341,7 @@
341341
"type": "boolean"
342342
},
343343
"pod": {
344-
"description": "The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways.",
344+
"description": "The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways managed by this\ninstance of NGINX Gateway Fabric.",
345345
"required": [],
346346
"title": "pod",
347347
"type": "object"
@@ -354,7 +354,7 @@
354354
"type": "integer"
355355
},
356356
"service": {
357-
"description": "The service configuration for the NGINX data plane. This is applied globally to all Gateways.",
357+
"description": "The service configuration for the NGINX data plane. This is applied globally to all Gateways managed by this\ninstance of NGINX Gateway Fabric.",
358358
"properties": {
359359
"annotations": {
360360
"description": "The annotations of the NGINX data plane service.",

charts/nginx-gateway-fabric/values.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,12 @@ nginx:
367367
# value:
368368
# type: string
369369
# @schema
370-
# -- The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways.
370+
# -- The configuration for the data plane that is contained in the NginxProxy resource. This is applied globally to all Gateways
371+
# managed by this instance of NGINX Gateway Fabric.
371372
config: {}
372373

373-
# -- The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways.
374+
# -- The pod configuration for the NGINX data plane pod. This is applied globally to all Gateways managed by this
375+
# instance of NGINX Gateway Fabric.
374376
pod: {}
375377
# -- The termination grace period of the NGINX data plane pod.
376378
# terminationGracePeriodSeconds: 30
@@ -391,7 +393,8 @@ nginx:
391393
# nginx.container.extraVolumeMounts mount additional volumes to the container.
392394
# extraVolumes: []
393395

394-
# -- The container configuration for the NGINX container. This is applied globally to all Gateways.
396+
# -- The container configuration for the NGINX container. This is applied globally to all Gateways managed by this
397+
# instance of NGINX Gateway Fabric.
395398
container: {}
396399
# -- The resource requirements of the NGINX container.
397400
# resources: {}
@@ -402,7 +405,8 @@ nginx:
402405
# -- extraVolumeMounts are the additional volume mounts for the NGINX container.
403406
# extraVolumeMounts: []
404407

405-
# -- The service configuration for the NGINX data plane. This is applied globally to all Gateways.
408+
# -- The service configuration for the NGINX data plane. This is applied globally to all Gateways managed by this
409+
# instance of NGINX Gateway Fabric.
406410
service:
407411
# @schema
408412
# enum:

internal/mode/static/handler.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,11 @@ func getGatewayAddresses(
474474
svcName := controller.CreateNginxResourceName(gateway.Source.GetName(), gatewayClassName)
475475
key := types.NamespacedName{Name: svcName, Namespace: gateway.Source.GetNamespace()}
476476

477+
pollCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
478+
defer cancel()
479+
477480
if err := wait.PollUntilContextCancel(
478-
ctx,
481+
pollCtx,
479482
500*time.Millisecond,
480483
true, /* poll immediately */
481484
func(ctx context.Context) (bool, error) {

internal/mode/static/handler_test.go

+26-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package static
33
import (
44
"context"
55
"errors"
6+
"time"
67

78
"github.com/go-logr/logr"
89
pb "github.com/nginx/agent/v3/api/grpc/mpi/v1"
@@ -87,8 +88,13 @@ var _ = Describe("eventHandler", func() {
8788
baseGraph = &graph.Graph{
8889
Gateways: map[types.NamespacedName]*graph.Gateway{
8990
{Namespace: "test", Name: "gateway"}: {
90-
Valid: true,
91-
Source: &gatewayv1.Gateway{},
91+
Valid: true,
92+
Source: &gatewayv1.Gateway{
93+
ObjectMeta: metav1.ObjectMeta{
94+
Name: "gateway",
95+
Namespace: "test",
96+
},
97+
},
9298
DeploymentName: types.NamespacedName{
9399
Namespace: "test",
94100
Name: controller.CreateNginxResourceName("gateway", "nginx"),
@@ -107,9 +113,19 @@ var _ = Describe("eventHandler", func() {
107113
fakeStatusUpdater = &statusfakes.FakeGroupUpdater{}
108114
fakeEventRecorder = record.NewFakeRecorder(1)
109115
zapLogLevelSetter = newZapLogLevelSetter(zap.NewAtomicLevel())
110-
fakeK8sClient = fake.NewFakeClient()
111116
queue = status.NewQueue()
112117

118+
gatewaySvc := &v1.Service{
119+
ObjectMeta: metav1.ObjectMeta{
120+
Namespace: "test",
121+
Name: "gateway-nginx",
122+
},
123+
Spec: v1.ServiceSpec{
124+
ClusterIP: "1.2.3.4",
125+
},
126+
}
127+
fakeK8sClient = fake.NewFakeClient(gatewaySvc)
128+
113129
handler = newEventHandlerImpl(eventHandlerConfig{
114130
ctx: ctx,
115131
k8sClient: fakeK8sClient,
@@ -520,16 +536,20 @@ var _ = Describe("getGatewayAddresses", func() {
520536
It("gets gateway addresses from a Service", func() {
521537
fakeClient := fake.NewFakeClient()
522538

523-
// no Service exists yet, should get error and Pod Address
539+
// no Service exists yet, should get error and no Address
524540
gateway := &graph.Gateway{
525541
Source: &gatewayv1.Gateway{
526542
ObjectMeta: metav1.ObjectMeta{
527543
Name: "gateway",
528-
Namespace: "test-ns",
544+
Namespace: "test",
529545
},
530546
},
531547
}
532-
addrs, err := getGatewayAddresses(context.Background(), fakeClient, nil, gateway, "nginx")
548+
549+
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
550+
defer cancel()
551+
552+
addrs, err := getGatewayAddresses(ctx, fakeClient, nil, gateway, "nginx")
533553
Expect(err).To(HaveOccurred())
534554
Expect(addrs).To(BeNil())
535555

0 commit comments

Comments
 (0)