Skip to content

Commit d04d2c0

Browse files
committed
Code review
1 parent ff195bd commit d04d2c0

File tree

11 files changed

+68
-43
lines changed

11 files changed

+68
-43
lines changed

cmd/gateway/commands.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ func createStaticModeCommand() *cobra.Command {
186186
GatewayClassName: gatewayClassName.value,
187187
GatewayNsName: gwNsName,
188188
UpdateGatewayClassStatus: updateGCStatus,
189-
DisableProductTelemetry: disableProductTelemetry,
190189
GatewayPodConfig: config.GatewayPodConfig{
191190
PodIP: podIP,
192191
ServiceName: serviceName.value,
@@ -207,12 +206,15 @@ func createStaticModeCommand() *cobra.Command {
207206
LockName: leaderElectionLockName.String(),
208207
Identity: podName,
209208
},
210-
UsageReportConfig: usageReportConfig,
211-
Plus: plus,
212-
TelemetryReportPeriod: period,
213-
Version: version,
214-
ExperimentalFeatures: gwExperimentalFeatures,
215-
ImageSource: imageSource,
209+
UsageReportConfig: usageReportConfig,
210+
ProductTelemetryConfig: config.ProductTelemetryConfig{
211+
TelemetryReportPeriod: period,
212+
DisableProductTelemetry: disableProductTelemetry,
213+
},
214+
Plus: plus,
215+
Version: version,
216+
ExperimentalFeatures: gwExperimentalFeatures,
217+
ImageSource: imageSource,
216218
}
217219

218220
if err := static.StartManager(conf); err != nil {
@@ -323,7 +325,7 @@ func createStaticModeCommand() *cobra.Command {
323325
&disableProductTelemetry,
324326
productTelemetryDisableFlag,
325327
false,
326-
"Disable the collection of product telemetry every 24 hours.",
328+
"Disable the collection of product telemetry.",
327329
)
328330

329331
cmd.Flags().BoolVar(

deploy/helm-chart/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ The following tables lists the configurable parameters of the NGINX Gateway Fabr
294294
| `nginxGateway.leaderElection.enable` | Enable leader election. Leader election is used to avoid multiple replicas of the NGINX Gateway Fabric reporting the status of the Gateway API resources. | true |
295295
| `nginxGateway.leaderElection.lockName` | The name of the leader election lock. A Lease object with this name will be created in the same Namespace as the controller. | Autogenerated |
296296
| `nginxGateway.securityContext.allowPrivilegeEscalation` | Some environments may need this set to true in order for the control plane to successfully reload NGINX. | false |
297-
| `nginxGateway.productTelemetry.enable` | Enable the collection of product telemetry every 24 hours. | true |
297+
| `nginxGateway.productTelemetry.enable` | Enable the collection of product telemetry. | true |
298298
| `nginxGateway.gwAPIExperimentalFeatures.enable` | Enable the experimental features of Gateway API which are supported by NGINX Gateway Fabric. Requires the Gateway APIs installed from the experimental channel. | false |
299299
| `nginx.image.repository` | The repository for the NGINX image. | ghcr.io/nginxinc/nginx-gateway-fabric/nginx |
300300
| `nginx.image.tag` | The tag for the NGINX image. | edge |

deploy/helm-chart/templates/rbac.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,34 @@ rules:
3939
- get
4040
- list
4141
- watch
42-
{{- if or .Values.nginxGateway.productTelemetry.enable .Values.nginx.plus }}
42+
{{- if .Values.nginxGateway.productTelemetry.enable }}
4343
- apiGroups:
4444
- ""
4545
resources:
4646
- pods
4747
verbs:
4848
- get
4949
- apiGroups:
50-
- ""
50+
- apps
5151
resources:
52-
- nodes
52+
- replicasets
5353
verbs:
54-
- list
54+
- get
55+
{{- end }}
56+
{{- if .Values.nginx.plus }}
5557
- apiGroups:
5658
- apps
5759
resources:
5860
- replicasets
5961
verbs:
60-
- get
62+
- list
63+
{{- end }}
64+
{{- if or .Values.nginxGateway.productTelemetry.enable .Values.nginx.plus }}
65+
- apiGroups:
66+
- ""
67+
resources:
68+
- nodes
69+
verbs:
6170
- list
6271
{{- end }}
6372
- apiGroups:

deploy/helm-chart/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ nginxGateway:
4646
allowPrivilegeEscalation: false
4747

4848
productTelemetry:
49-
## Enable the collection of product telemetry every 24 hours.
49+
## Enable the collection of product telemetry.
5050
enable: true
5151

5252
## The lifecycle of the nginx-gateway container.

deploy/manifests/nginx-gateway-experimental.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,17 @@ rules:
4343
- pods
4444
verbs:
4545
- get
46-
- apiGroups:
47-
- ""
48-
resources:
49-
- nodes
50-
verbs:
51-
- list
5246
- apiGroups:
5347
- apps
5448
resources:
5549
- replicasets
5650
verbs:
5751
- get
52+
- apiGroups:
53+
- ""
54+
resources:
55+
- nodes
56+
verbs:
5857
- list
5958
- apiGroups:
6059
- ""

deploy/manifests/nginx-gateway.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,17 @@ rules:
4242
- pods
4343
verbs:
4444
- get
45-
- apiGroups:
46-
- ""
47-
resources:
48-
- nodes
49-
verbs:
50-
- list
5145
- apiGroups:
5246
- apps
5347
resources:
5448
- replicasets
5549
verbs:
5650
- get
51+
- apiGroups:
52+
- ""
53+
resources:
54+
- nodes
55+
verbs:
5756
- list
5857
- apiGroups:
5958
- ""

deploy/manifests/nginx-plus-gateway-experimental.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,22 @@ rules:
4444
verbs:
4545
- get
4646
- apiGroups:
47-
- ""
47+
- apps
4848
resources:
49-
- nodes
49+
- replicasets
5050
verbs:
51-
- list
51+
- get
5252
- apiGroups:
5353
- apps
5454
resources:
5555
- replicasets
5656
verbs:
57-
- get
57+
- list
58+
- apiGroups:
59+
- ""
60+
resources:
61+
- nodes
62+
verbs:
5863
- list
5964
- apiGroups:
6065
- ""

deploy/manifests/nginx-plus-gateway.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,22 @@ rules:
4343
verbs:
4444
- get
4545
- apiGroups:
46-
- ""
46+
- apps
4747
resources:
48-
- nodes
48+
- replicasets
4949
verbs:
50-
- list
50+
- get
5151
- apiGroups:
5252
- apps
5353
resources:
5454
- replicasets
5555
verbs:
56-
- get
56+
- list
57+
- apiGroups:
58+
- ""
59+
resources:
60+
- nodes
61+
verbs:
5762
- list
5863
- apiGroups:
5964
- ""

internal/mode/static/config/config.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ type Config struct {
3636
MetricsConfig MetricsConfig
3737
// HealthConfig specifies the health probe config.
3838
HealthConfig HealthConfig
39-
// TelemetryReportPeriod is the period at which telemetry reports are sent.
40-
TelemetryReportPeriod time.Duration
39+
// ProductTelemetryConfig contains the configuration for collecting product telemetry.
40+
ProductTelemetryConfig ProductTelemetryConfig
4141
// UpdateGatewayClassStatus enables updating the status of the GatewayClass resource.
4242
UpdateGatewayClassStatus bool
43-
// DisableProductTelemetry disables the collection of product telemetry.
44-
DisableProductTelemetry bool
4543
// Plus indicates whether NGINX Plus is being used.
4644
Plus bool
4745
// ExperimentalFeatures indicates if experimental features are enabled.
@@ -88,6 +86,14 @@ type LeaderElectionConfig struct {
8886
Enabled bool
8987
}
9088

89+
// ProductTelemetryConfig contains the configuration for collecting product telemetry.
90+
type ProductTelemetryConfig struct {
91+
// TelemetryReportPeriod is the period at which telemetry reports are sent.
92+
TelemetryReportPeriod time.Duration
93+
// DisableProductTelemetry disables the collection of product telemetry.
94+
DisableProductTelemetry bool
95+
}
96+
9197
// UsageReportConfig contains the configuration for NGINX Plus usage reporting.
9298
type UsageReportConfig struct {
9399
// SecretNsName is the namespaced name of the Secret containing the server credentials.

internal/mode/static/manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func StartManager(cfg config.Config) error {
242242
return fmt.Errorf("cannot register status updater: %w", err)
243243
}
244244

245-
if !cfg.DisableProductTelemetry {
245+
if !cfg.ProductTelemetryConfig.DisableProductTelemetry {
246246
dataCollector := telemetry.NewDataCollectorImpl(telemetry.DataCollectorConfig{
247247
K8sClientReader: mgr.GetAPIReader(),
248248
GraphGetter: processor,
@@ -475,7 +475,7 @@ func createTelemetryJob(
475475
runnables.CronJobConfig{
476476
Worker: telemetry.CreateTelemetryJobWorker(logger, exporter, dataCollector),
477477
Logger: logger,
478-
Period: cfg.TelemetryReportPeriod,
478+
Period: cfg.ProductTelemetryConfig.TelemetryReportPeriod,
479479
JitterFactor: telemetryJitterFactor,
480480
ReadyCh: readyCh,
481481
},
@@ -503,7 +503,7 @@ func createUsageReporterJob(
503503
Runnable: runnables.NewCronJob(runnables.CronJobConfig{
504504
Worker: usage.CreateUsageJobWorker(logger, k8sClient, reporter, cfg),
505505
Logger: logger,
506-
Period: cfg.TelemetryReportPeriod,
506+
Period: cfg.ProductTelemetryConfig.TelemetryReportPeriod,
507507
JitterFactor: telemetryJitterFactor,
508508
ReadyCh: readyCh,
509509
}),

site/content/reference/cli-help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _Usage_:
3636
| _health-port_ | _int_ | Set the port where the health probe server is exposed. An integer between 1024 - 65535 (Default: `8081`). |
3737
| _leader-election-disable_ | _bool_ | Disable leader election, which is used to avoid multiple replicas of the NGINX Gateway Fabric reporting the status of the Gateway API resources. If disabled, all replicas of NGINX Gateway Fabric will update the statuses of the Gateway API resources (Default: `false`). |
3838
| _leader-election-lock-name_ | _string_ | The name of the leader election lock. A lease object with this name will be created in the same namespace as the controller (Default: `"nginx-gateway-leader-election-lock"`). |
39-
| _product-telemetry-disable_ | _bool_ | Disable the collection of product telemetry every 24 hours (Default: `false`). |
39+
| _product-telemetry-disable_ | _bool_ | Disable the collection of product telemetry (Default: `false`). |
4040
| _usage-report-secret_ | _string_ | The namespace/name of the Secret containing the credentials for NGINX Plus usage reporting. |
4141
| _usage-report-server-url_ | _string_ | The base server URL of the NGINX Plus usage reporting server. |
4242
| _usage-report-cluster-name_ | _string_ | The display name of the Kubernetes cluster in the NGINX Plus usage reporting server. |

0 commit comments

Comments
 (0)