BaseAdresseNationale / addok-docker

Conteneurs Addok pour Docker
157 stars 29 forks source link

Internal Server Error 500 #8

Closed louia closed 5 years ago

louia commented 5 years ago

Voici l'erreur que j'obtiens sous windows 10 avec Docker Desktop.

Que faire?


addok_1        | Traceback (most recent call last):
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 484, in connect
addok_1        |     sock = self._connect()
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 511, in _connect
addok_1        |     socket.SOCK_STREAM):
addok_1        |   File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
addok_1        |     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
addok_1        | socket.gaierror: [Errno -5] No address associated with hostname
addok_1        |
addok_1        | During handling of the above exception, another exception occurred:
addok_1        |
addok_1        | Traceback (most recent call last):
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 667, in execute_command
addok_1        |     connection.send_command(*args)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 610, in send_command
addok_1        |     self.send_packed_command(self.pack_command(*args))
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 585, in send_packed_command
addok_1        |     self.connect()
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 489, in connect
addok_1        |     raise ConnectionError(self._error_message(e))
addok_1        | redis.exceptions.ConnectionError: Error -5 connecting to redis:6379. No address associated with hostname.
addok_1        |
addok_1        | During handling of the above exception, another exception occurred:
addok_1        |
addok_1        | Traceback (most recent call last):
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 484, in connect
addok_1        |     sock = self._connect()
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 511, in _connect
addok_1        |     socket.SOCK_STREAM):
addok_1        |   File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
addok_1        |     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
addok_1        | socket.gaierror: [Errno -5] No address associated with hostname
addok_1        |
addok_1        | During handling of the above exception, another exception occurred:
addok_1        |
addok_1        | Traceback (most recent call last):
addok_1        |   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 135, in handle
addok_1        |     self.handle_request(listener, req, client, addr)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
addok_1        |     respiter = self.wsgi(environ, resp.start_response)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/falcon/api.py", line 227, in __call__
addok_1        |     responder(req, resp, **params)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/addok/http/base.py", line 134, in on_get
addok_1        |     lat=lat, lon=lon, **filters)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/addok/core.py", line 331, in search
addok_1        |     return helper(query, lat=lat, lon=lon, **filters)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/addok/core.py", line 158, in __call__
addok_1        |     func(self)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/addok/helpers/search.py", line 21, in search_tokens
addok_1        |     token.search()
addok_1        |   File "/usr/local/lib/python3.6/site-packages/addok/helpers/text.py", line 47, in search
addok_1        |     if DB.exists(self.key):
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 951, in exists
addok_1        |     return self.execute_command('EXISTS', name)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 673, in execute_command
addok_1        |     connection.send_command(*args)
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 610, in send_command
addok_1        |     self.send_packed_command(self.pack_command(*args))
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 585, in send_packed_command
addok_1        |     self.connect()
addok_1        |   File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 489, in connect
addok_1        |     raise ConnectionError(self._error_message(e))
addok_1        | redis.exceptions.ConnectionError: Error -5 connecting to redis:6379. No address associated with hostname.
addok_1        | Loaded local config from /etc/addok/addok.patched.conf
addok_1        | Loaded plugins:
addok_1        | addok.shell==1.0.2, addok.http.base==1.0.2, addok.batch==1.0.2, addok.pairs==1.0.2, addok.fuzzy==1.0.2, addok.autocomplete==1.0.2, sqlite-store==1.0.0, france==1.1.0, fr==1.0.1, csv==1.0.1
addok_1        | 172.18.0.1 - - [04/May/2019:16:03:00 +0000] "GET /search?q=paris HTTP/1.1" 500 0 "-" "-"```
jdesboeufs commented 5 years ago

Bonjour,

Pouvez-vous nous donner un peu plus de contexte ? Quelles sont les commandes que vous avez tapé ?

louia commented 5 years ago

Bonjour,

Je lance juste l'instance avec "docker-compose up", une fois démarrer je lance une requete de test "http://localhost:7878/search?q=1+rue+de+la+paix+paris" et c'est à ce moment là que j'ai le soucis.

louia commented 5 years ago

Je pense que celui à un rapport avec la #2

louia commented 5 years ago

Après de nouveaux tests, je remarque que quelques minutes après le démarrage de l'instance j'ai ce message : ap_addok-redis_1 exited with code 137

puis je lance un essai avec http://localhost:7878/search?q=1+rue+de+la+paix+paris mais cela echoue et j'obtiens l'erreur décrite plus haut

pourquoi le conteneur se ferme-t-il? cordialement

jdesboeufs commented 5 years ago

L'erreur No address associated with hostname indique que le mapping que devrait faire docker-compose n'a pas été couronné de succès.

Essayez docker-compose down pour bien effacer le contexte, et recommencer.

Malheureusement nous n'avons jamais testé avec Docker Desktop pour Windows. Peut-être qu'il y a des incompatibilités avec Compose 2.

sneycampos commented 5 years ago

Maybe your redis are crashed. Try remove relateds containers with docker ps -a and remove with docker rm -v <container_id> Then run again your docker-compose up --build

If redis dont start, open another terminal window and run docker-compose logs -f addok_redis and see the log

loverg-c commented 5 years ago

Bonjour,

J'ai le même problème sur linux (antergos 5.1.14-arch1-1-ARCH avec Docker version 18.09.6-ce et docker-compose version 1.24.1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 667, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 610, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 585, in send_packed_command
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 489, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error -2 connecting to redis:6379. Name or service not known.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 484, in connect
    sock = self._connect()
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 511, in _connect
    socket.SOCK_STREAM):
  File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 135, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python3.6/site-packages/falcon/api.py", line 227, in __call__
    responder(req, resp, **params)
  File "/usr/local/lib/python3.6/site-packages/addok/http/base.py", line 134, in on_get
    lat=lat, lon=lon, **filters)
  File "/usr/local/lib/python3.6/site-packages/addok/core.py", line 331, in search
    return helper(query, lat=lat, lon=lon, **filters)
  File "/usr/local/lib/python3.6/site-packages/addok/core.py", line 158, in __call__
    func(self)
  File "/usr/local/lib/python3.6/site-packages/addok/helpers/search.py", line 21, in search_tokens
    token.search()
  File "/usr/local/lib/python3.6/site-packages/addok/helpers/text.py", line 47, in search
    if DB.exists(self.key):
  File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 951, in exists
    return self.execute_command('EXISTS', name)
  File "/usr/local/lib/python3.6/site-packages/redis/client.py", line 673, in execute_command
    connection.send_command(*args)
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 610, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 585, in send_packed_command
    self.connect()
  File "/usr/local/lib/python3.6/site-packages/redis/connection.py", line 489, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error -2 connecting to redis:6379. Name or service not known.

Pourtant le container redis est bien up et tourne encore sans aucune erreur,

f813abf77c7b        etalab/addok                       "/bin/sh -c docker-e…"   9 minutes ago       Up 9 minutes               0.0.0.0:7878->7878/tcp             capsule_dev_addok_1
a254d7df14eb        etalab/addok-redis                 "docker-entrypoint.s…"   9 minutes ago       Up 9 minutes               6379/tcp                           capsule_dev_addok-redis_1

J'ai aussi essayé de modifier le docker-compose.yml:

    addok:
        image: etalab/addok
        ports:
            - "7878:7878"
        volumes:
            - ./addok/addok-data/addok.conf:/etc/addok/addok.conf
            - ./addok/addok-data/addok.db:/data/addok.db
            - ./addok/logs:/logs
        links:
            - addok-redis:redis
        networks:
          - net_addok #le network pour ma couche application
        depends_on:
          - addok-redis
        restart: unless-stopped
        environment:
            WORKERS: 1
            WORKER_TIMEOUT: 30
            LOG_QUERIES: 1
            LOG_NOT_FOUND: 1
            SLOW_QUERIES: 200
    addok-redis:
        image: etalab/addok-redis
        restart: unless-stopped
        volumes:
            - ./addok/addok-data/dump.rdb:/data/dump.rdb

Mais rien n'y fait, cela donne une erreur 500 :/

loverg-c commented 5 years ago

nb : J'ai rajouté le network net_addok sur le container redis et addok, et cela fonctionne au bout de quelques secondes, idem que @louia je pense que cela vient de la #2

jdesboeufs commented 5 years ago

Oui c'est probablement ça.

martinezhermes commented 5 years ago

Alors le problème de @louia ne vient que de la configuration du docker en dehors de linux, (en utilisant Windows ou macOS), la config par defaut sur ces OS n'est qu'une virtualisation d'Alpine linux avec 2GB de RAM (même la dernière version avec les hyperviseurs), les index de la base de référentiels dépassent  les 1.5 Go, donc redis crash avec l'erreur 137. Il suffit d'augmenter la RAM dans les config de docker au tailles recommandées dans ce git.