kubernetes / ingress-nginx

Ingress-NGINX Controller for Kubernetes
https://kubernetes.github.io/ingress-nginx/
Apache License 2.0
16.96k stars 8.14k forks source link

Updating GeoIP2 data outputs many logs of "File changed detected. Reloading NGINX" #11080

Open atuk721 opened 4 months ago

atuk721 commented 4 months ago

What happened:

When I start ingress-nginx with the folloing settings and update GeoIP2 data, ingress-nginx outputs many logs of File changed detected. Reloading NGINX.

What you expected to happen:

File change detection and nginx reloading should be once per a file change.

NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):

-------------------------------------------------------------------------------
NGINX Ingress controller
  Release:       v1.10.0
  Build:         71f78d49f0a496c31d4c19f095469f3f23900f8a
  Repository:    https://github.com/kubernetes/ingress-nginx
  nginx version: nginx/1.25.3

-------------------------------------------------------------------------------

Kubernetes version (use kubectl version):

Client Version: v1.28.6
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.3

Environment:

How to reproduce this issue:

You need to prepare GeoLite2-City.mmdb that need MaxMind account.

# 1. Download GeoLite2 data and extrat GeoLite2-City.mmdb to a specific directory.

# 2. Start minikube.
$ minikube start

# 3. Mount the specific directory to have GeoLite2-City.mmd to Minikube. 
$ minikube mount {specific folder}:/host

# 4. Install ingress-nginx.
$ cat << EOF > test.yaml
controller:
  config:
    use-geoip: 'false'
    use-geoip2: 'true'

  extraVolumeMounts:
    - name: geoip-data
      mountPath: /etc/ingress-controller/geoip

  extraVolumes:
    - name: geoip-data
      emptyDir: {}

    - name: host
      hostPath:
        path: /host
        type: Directory

  extraInitContainers:
    - name: init-geoip
      image: alpine
      args: ['cp', '/host/GeoLite2-City.mmdb', '/geoip/']

      volumeMounts:
        - name: geoip-data
          mountPath: /geoip

        - name: host
          mountPath: /host
EOF

$ helm install ingress-test ingress-nginx/ingress-nginx --version 4.10.0 -f test.yaml

# 5. Tail logs.
$ kubectl logs -f ingress-test-ingress-nginx-controller-{...}

# 6. Update GeoIP2 data file.
$ kubectl exec -it ingress-test-ingress-nginx-controller-{...} bash

$ cp /etc/ingress-controller/geoip/GeoLite2-City.mmdb /tmp/
$ cp /tmp/GeoLite2-City.mmdb /etc/ingress-controller/geoip/GeoLite2-City.mmdb

A part of the logs:

I0308 14:15:52.622881       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.622926       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.623825       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.623906       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624024       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624078       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624147       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624227       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624322       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624435       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624562       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624663       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624761       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624843       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.624964       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.625056       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.625141       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"                                                                   
I0308 14:15:52.625234       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"

If hostPath mounts directory to the Pod and update local mounted files using the folloing setting, there is no output in logs.

$ cat << EOF > test.yaml
controller:
  config:
    use-geoip: 'false'
    use-geoip2: 'true'

  extraVolumeMounts:
    - name: geoip-data
      mountPath: /etc/ingress-controller/geoip

  extraVolumes:
    - name: geoip-data
      hostPath:
        path: /host
        type: Directory
EOF
k8s-ci-robot commented 4 months ago

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
strongjz commented 3 months ago

once the cp is finished does it still reload?

atuk721 commented 3 months ago

No. It logs about 750 lines of "File changed detected. Reloading NGINX" in 100ms and stops to log.

Start line
I0329 09:16:03.853384       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"

End line
I0329 09:16:03.946326       7 nginx.go:207] "File changed detected. Reloading NGINX" path="/etc/ingress-controller/geoip/GeoLite2-City.mmdb"

Total 757 lines.
github-actions[bot] commented 2 months ago

This is stale, but we won't close it automatically, just bare in mind the maintainers may be busy with other tasks and will reach your issue ASAP. If you have any question or request to prioritize this, please reach #ingress-nginx-dev on Kubernetes Slack.