Skip to content

Commit e7e1757

Browse files
authored
refactor: fix nil pointer when glog is removed & update old -v= to -log-level= (#6620)
1 parent 153224e commit e7e1757

19 files changed

+33
-45
lines changed

cmd/nginx-ingress/flags.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,6 @@ func initValidate(ctx context.Context) {
265265

266266
func mustValidateInitialChecks(ctx context.Context) {
267267
l := nl.LoggerFromContext(ctx)
268-
err := flag.Lookup("logtostderr").Value.Set("true")
269-
if err != nil {
270-
nl.Fatalf(l, "Error setting logtostderr to true: %v", err)
271-
}
272-
273-
err = flag.Lookup("include_year").Value.Set("true")
274-
if err != nil {
275-
nl.Fatalf(l, "Error setting include_year flag: %v", err)
276-
}
277268

278269
if startupCheckFn != nil {
279270
err := startupCheckFn()

deployments/daemon-set/nginx-ingress.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ spec:
9191
- -report-ingress-status
9292
- -external-service=nginx-ingress
9393
#- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
94-
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
94+
#- -log-level=debug # Enables extensive logging. Useful for troubleshooting. Options include: trace, debug, info, warning, error, fatal
95+
#- -log-format=glog # Sets the log format. Options include: glog, json, text
9596
#- -enable-prometheus-metrics
9697
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
9798
# initContainers:

deployments/daemon-set/nginx-plus-ingress.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ spec:
9494
#- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
9595
#- -enable-app-protect
9696
#- -enable-app-protect-dos
97-
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
97+
#- -log-level=debug # Enables extensive logging. Useful for troubleshooting. Options include: trace, debug, info, warning, error, fatal
98+
#- -log-format=glog # Sets the log format. Options include: glog, json, text
9899
#- -enable-prometheus-metrics
99100
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
100101
# initContainers:

deployments/deployment/nginx-ingress.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ spec:
9292
#- -default-server-tls-secret=$(POD_NAMESPACE)/default-server-secret
9393
#- -enable-cert-manager
9494
#- -enable-external-dns
95-
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
95+
#- -log-level=debug # Enables extensive logging. Useful for troubleshooting. Options include: trace, debug, info, warning, error, fatal
96+
#- -log-format=glog # Sets the log format. Options include: glog, json, text
9697
#- -enable-prometheus-metrics
9798
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration
9899
# initContainers:

deployments/deployment/nginx-plus-ingress.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ spec:
9797
#- -enable-external-dns
9898
#- -enable-app-protect
9999
#- -enable-app-protect-dos
100-
#- -v=3 # Enables extensive logging. Useful for troubleshooting.
100+
#- -log-level=debug # Enables extensive logging. Useful for troubleshooting. Options include: trace, debug, info, warning, error, fatal
101+
#- -log-format=glog # Sets the log format. Options include: glog, json, text
101102
#- -enable-prometheus-metrics
102103
#- -enable-service-insight
103104
#- -global-configuration=$(POD_NAMESPACE)/nginx-configuration

examples/shared-examples/usage-reporting/cluster-connector.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ spec:
140140
- -nms-server-address=https://apigw.nms.svc.cluster.local:443/api/platform/v1
141141
- -nms-basic-auth-secret=nginx-cluster-connector/nms-basic-auth
142142
# - -cluster-display-name=my-cluster
143-
# - -v=3
143+
# - -log-level=debug
144+
# - -log-format=glog
144145
# - -skip-tls-verify
145146
# - -min-update-interval=24h

internal/telemetry/collector_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,21 +1056,21 @@ func TestCollectInstallationFlags(t *testing.T) {
10561056
{
10571057
name: "second flag",
10581058
setFlags: []string{
1059-
"-v=3",
1059+
"-log-level=debug",
10601060
},
10611061
wantFlags: []string{
1062-
"-v=3",
1062+
"-log-level=debug",
10631063
},
10641064
},
10651065
{
10661066
name: "multiple flags",
10671067
setFlags: []string{
10681068
"nginx-plus=true",
1069-
"-v=3",
1069+
"-log-level=debug",
10701070
},
10711071
wantFlags: []string{
10721072
"nginx-plus=true",
1073-
"-v=3",
1073+
"-log-level=debug",
10741074
},
10751075
},
10761076
{

site/content/configuration/global-configuration/command-line-arguments.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,6 @@ Path to the TransportServer NGINX configuration template for a TransportServer r
316316
- Default for NGINX is `nginx.transportserver.tmpl`.
317317
- Default for NGINX Plus is `nginx-plus.transportserver.tmpl`.
318318

319-
<a name="cmdoption-v"></a>
320-
321-
---
322-
323-
### -v `<value>`
324-
325-
Log level for V logs.
326-
327319
<a name="cmdoption-log-level"></a>
328320

329321
---

site/content/logging-and-monitoring/logging.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ weight: 1800
99

1010
This document gives an overview of logging provided by NGINX Ingress Controller.
1111

12-
NGINX Ingress Controller exposes the logs of the Ingress Controller process (the process that generates NGINX configuration and reloads NGINX to apply it) and NGINX access and error logs. All logs are sent to the standard output and error of the Ingress Controller process. To view the logs, you can execute the `kubectl logs` command for an Ingress Controller pod. For example:
12+
NGINX Ingress Controller exposes the logs of the Ingress Controller process (the process that generates NGINX configuration and reloads NGINX to apply it) and NGINX access and error logs. All logs are sent to the standard output and error of the NGINX Ingress Controller process. To view the logs, you can execute the `kubectl logs` command for an Ingress Controller pod. For example:
1313

1414
```shell
1515
kubectl logs <nginx-ingress-pod> -n nginx-ingress
1616
```
1717

18-
## Ingress Controller Process Logs
18+
## NGINX Ingress Controller Process Logs
1919

20-
The Ingress Controller process logs are configured through the `-v` command-line argument of the Ingress Controller, which sets the log verbosity level. The default value is `1`, for which the minimum amount of logs is reported. The value `3` is useful for troubleshooting: you will be able to see how the Ingress Controller gets updates from the Kubernetes API, generates NGINX configuration and reloads NGINX.
20+
The NGINX Ingress Controller process logs are configured through the `-log-level` command-line argument of the NGINX Ingress Controller, which sets the log level. The default value is `info`. Other options include: `trace`, `debug`, `info`, `warning`, `error` and `fatal`. The value `debug` is useful for troubleshooting: you will be able to see how NGINX Ingress Controller gets updates from the Kubernetes API, generates NGINX configuration and reloads NGINX.
2121

22-
See also the doc about Ingress Controller [command-line arguments](/nginx-ingress-controller/configuration/global-configuration/command-line-arguments).
22+
See also the doc about NGINX Ingress Controller [command-line arguments](/nginx-ingress-controller/configuration/global-configuration/command-line-arguments).
2323

2424
## NGINX Logs
2525

tests/data/virtual-server-certmanager/certmanager.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5186,7 +5186,7 @@ spec:
51865186
image: "quay.io/jetstack/cert-manager-cainjector:v1.9.1"
51875187
imagePullPolicy: IfNotPresent
51885188
args:
5189-
- --v=2
5189+
- --log-level=debug
51905190
- --leader-election-namespace=kube-system
51915191
env:
51925192
- name: POD_NAMESPACE
@@ -5238,7 +5238,7 @@ spec:
52385238
image: "quay.io/jetstack/cert-manager-controller:v1.9.1"
52395239
imagePullPolicy: IfNotPresent
52405240
args:
5241-
- --v=2
5241+
- --log-level=debug
52425242
- --cluster-resource-namespace=$(POD_NAMESPACE)
52435243
- --leader-election-namespace=kube-system
52445244
ports:
@@ -5291,7 +5291,7 @@ spec:
52915291
image: "quay.io/jetstack/cert-manager-webhook:v1.9.1"
52925292
imagePullPolicy: IfNotPresent
52935293
args:
5294-
- --v=2
5294+
- --log-level=debug
52955295
- --secure-port=10250
52965296
- --dynamic-serving-ca-secret-namespace=$(POD_NAMESPACE)
52975297
- --dynamic-serving-ca-secret-name=cert-manager-webhook-ca

0 commit comments

Comments
 (0)