netbox-community / netbox-docker

🐳 Docker Image of NetBox
https://github.com/netbox-community/netbox-docker/wiki
Apache License 2.0
1.85k stars 858 forks source link

Netbox exists after a couple of requests #854

Open telmich opened 2 years ago

telmich commented 2 years ago

Current Behavior

Netbox exits after a few requests, causing nginx-ingress to return a 404 on failure. Note though, that the container keeps running, it's merely the python/django process exiting.

This restart happens sometimes after 8 requests, sometimes after 20ish requests, but rather frequent. As exit code 0 is a success code, I wonder what the motivation for netbox is to exit.

Expected Behavior

Netbox does not exit on its own. By exiting the nginx-ingress will return a 404 to clients, every time netbox is unreachable.

Docker Compose Version

kubernetes 1.24

Docker Version

crio / unrelated

The git Revision

docker-hub versions: v3.3.2-2.2.0, v3.3.4-2.2.0

The git Status

No git

Startup Command

The image directly, no commands

NetBox Logs

2a0a:e5c0:10:2:6c4c:27bd:c596:4da4 - - [28/Sep/2022:14:11:55 +0000] "GET /ipam/prefixes/39/prefixes/ HTTP/1.1" 200 108611 "https://netbox.xxx/ipam/prefixes/39/" "Mozilla/5.0 (X11; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0"
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
2022/09/28 14:13:54 [notice] 20#20 app process (isolated 222) exited with code 0

### Content of docker-compose.override.yml

```yaml
- name: netbox
          image: netboxcommunity/netbox:{{ .Chart.AppVersion }}
          ports:
            - containerPort: 8080
          envFrom:
          - secretRef:
              name: {{ .Release.Name }}-netbox-secret
          env:
            - name: DB_HOST
              value: "{{ .Release.Name }}-postgres"
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ .Release.Name }}-postgres-config
                  key: POSTGRES_PASSWORD
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: {{ .Release.Name }}-postgres-config
                  key: POSTGRES_USER
            - name: DB_NAME
              valueFrom:
                secretKeyRef:
                  name: {{ .Release.Name }}-postgres-config
                  key: POSTGRES_DB
telmich commented 2 years ago

Original issue for completeness: https://github.com/netbox-community/netbox/issues/10499

Kartograf commented 1 year ago

I found a workaround for this problem by specifying a static number of processes in nginx-units.json https://github.com/netbox-community/netbox-docker/blob/release/docker/nginx-unit.json#L34

      "applications": {
        "netbox": {
          "type": "python 3",
          "path": "/opt/netbox/netbox/",
          "module": "netbox.wsgi",
          "home": "/opt/netbox/venv",
          "processes": 4
        }
      }
js94x commented 1 year ago

I am observing the same behavior, although i have already implemented the workaround suggested by @Kartograf .

There are five working requests (with "processes": 4 in nginx-unit.json) in total to netbox / wsgi application but afterwards, no request is answered correctly.

2023/04/19 13:44:34 [info] 33#33 "netbox" prototype started
2023/04/19 13:44:34 [info] 34#34 "netbox" application started
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
2023/04/19 13:44:35 [info] 35#35 "netbox" application started
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
2023/04/19 13:44:37 [info] 36#36 "netbox" application started
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
2023/04/19 13:44:38 [info] 37#37 "netbox" application started
🧬 loaded config '/etc/netbox/config/configuration.py'
🧬 loaded config '/etc/netbox/config/extra.py'
🧬 loaded config '/etc/netbox/config/logging.py'
🧬 loaded config '/etc/netbox/config/plugins.py'
✅ Unit configuration loaded successfully
2023/04/19 13:44:39 [notice] 18#18 process 25 exited with code 0
2a05:..... - - [19/Apr/2023:13:44:39 +0000] "GET / HTTP/1.1" 302 0 "-" "kube-probe/1.24+"
2a05:..... - - [19/Apr/2023:13:44:42 +0000] "GET / HTTP/1.1" 302 0 "-" "kube-probe/1.24+"
2a05:..... - - [19/Apr/2023:13:44:47 +0000] "GET / HTTP/1.1" 302 0 "-" "kube-probe/1.24+"
2a05:..... - - [19/Apr/2023:13:44:52 +0000] "GET / HTTP/1.1" 302 0 "-" "kube-probe/1.24+"
2a05:..... - - [19/Apr/2023:13:44:53 +0000] "GET / HTTP/1.1" 302 0 "-" "kube-probe/1.24+"

A request with cURL also times out:

curl localhost:8080/ -v
*   Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.81.0
> Accept: */*
>

Apart from that static assets are working properly:

root@netbox-7b9f7d64cd-22fws:/opt/netbox/netbox# date >> static/date.txt
root@netbox-7b9f7d64cd-22fws:/opt/netbox/netbox# curl localhost:8080/static/date.txt
Wed Apr 19 13:50:34 UTC 2023
jonathon2nd commented 1 year ago

What it wound up being for us was CPU "throttling" image After increasing the limits a bunch, it is not using the new cpu provided, but it is happy that it is there. image