edgedb / edgedb-docker

Official Docker Image packaging for EdgeDB
83 stars 16 forks source link

edgedb:1-beta1 is no longer Plug and Play? #16

Closed Mulugruntz closed 3 years ago

Mulugruntz commented 3 years ago

I switched to edgedb/edgedb:1-beta1 and just running this code fails:

import asyncio
import edgedb

DB_CONNECTION_PROPS = {
    "host": "localhost",
    "port": 5656,
    "user": "edgedb",
    "database": "edgedb",
}

async def main():
    pool = await edgedb.create_async_pool(min_size=2, **DB_CONNECTION_PROPS)

if __name__ == "__main__":
    asyncio.run(main())

Error message:

Traceback (most recent call last):
  File "/Users/sgiffard/Library/Application Support/JetBrains/PyCharm2020.3/scratches/scratch_17.py", line 16, in <module>
    asyncio.run(main())
  File "/usr/local/Cellar/python@3.9/3.9.1_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python@3.9/3.9.1_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/sgiffard/Library/Application Support/JetBrains/PyCharm2020.3/scratches/scratch_17.py", line 12, in main
    pool = await edgedb.create_async_pool(min_size=2, **DB_CONNECTION_PROPS)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_pool.py", line 339, in _async__init__
    await self._initialize()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_pool.py", line 356, in _initialize
    await first_ch.connect()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_pool.py", line 107, in connect
    self._con = await self._pool._get_new_connection()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_pool.py", line 397, in _get_new_connection
    con = await asyncio_con.async_connect(
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_con.py", line 462, in async_connect
    await connection.ensure_connected()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_con.py", line 175, in ensure_connected
    await self._reconnect(single_attempt=single_attempt)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_pool.py", line 54, in _reconnect
    return await super()._reconnect(single_attempt=single_attempt)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_con.py", line 182, in _reconnect
    await self._impl.connect(self._loop, self._addrs,
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_con.py", line 70, in connect
    await compat.wait_for(
  File "/usr/local/Cellar/python@3.9/3.9.1_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 478, in wait_for
    return fut.result()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/asyncio_con.py", line 122, in _connect_addr
    await pr.connect()
  File "edgedb/protocol/protocol.pyx", line 915, in connect
  File "edgedb/protocol/protocol.pyx", line 983, in _auth_sasl
edgedb.errors.AuthenticationError: invalid SCRAM verifier for user 'edgedb'

The Python client is 0.13.0 https://pypi.org/project/edgedb/0.13.0/

Is it related to the new CLI mentioned here? https://www.edgedb.com/blog/edgedb-1-0-beta-1-sirius I tried to search for an answer in the docs but couldn't. Would they need to be updated?

elprans commented 3 years ago

The default Docker image no longer defaults to Trust auth for security considerations, you need to make an explicit choice: either set -v EDGEDB_PASSWORD=... to configure an explicit password or set -v EDGEDB_BOOTSTRAP_COMMAND="CONFIGURE SYSTEM INSERT Auth {priority := 0, method := (INSERT Trust)}" to restore the old insecure behavior. Both need to be specified once when you first run a container on a fresh data dir.

All that said, the recommended way is to use the edgedb server CLI instead:

edgedb server install --method=docker --version=1-beta1
edgedb server init --version=1-beta1 my_instance

This will configure strong auth and store credentials in a local file (under ~/.edgedb by default). Then, connecting to a named instance is as easy as:

async def main():
    pool = await edgedb.create_async_pool('my_instance', min_size=2)
Mulugruntz commented 3 years ago

Thanks @elprans .

However, I'm not sure I understand the recommended way. If I use docker-compose with something like

services:
  app:
    container_name: app
    build: .
  edgedb:
    container_name: edgedb
    image: edgedb/edgedb:1-beta1
    # ...

where would I do my edgedb server commands? In the client container (app)? As it doesn't seem to be a command for the container. Which still raises the question if the official hub image is still "plug and play".

Or maybe that implies that the "recommended way" is to not use the docker hub image?

elprans commented 3 years ago

Oh, for compose, the EDGEDB_PASSWORD is probably simplest. Example: https://github.com/edgedb/edgedb-docker/blob/master/tests/compose/docker-compose.yml

Mulugruntz commented 3 years ago

Thanks for your quick reply as always, @elprans .

I'm not sure if I'm missing something obvious here. I actually already digged in this repo and found this EDGEDB_PASSWORD/EDGEDB_USER env. I already added them into my compose file, but it didn't change the result. I just tried by adding this &pwd/[*pwd] thing as well. And it's still the same result.

  edgedb:
    container_name: edgedb
    image: edgedb/edgedb:1-beta1
    environment:
      - EDGEDB_USER=edgedb
      - EDGEDB_PASSWORD=edgedb
$> docker exec -it 784e971341f5 env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=784e971341f5
TERM=xterm
EDGEDB_USER=edgedb
EDGEDB_PASSWORD=edgedb
GOSU_VERSION=1.11
LANG=en_US.utf8
VERSION=1-beta1
EDGEDB_DATADIR=/var/lib/edgedb/data
HOME=/root
import edgedb
edgedb.connect(user='edgedb', password='edgedb')
Traceback (most recent call last):
  File "/Users/sgiffard/Library/Application Support/JetBrains/PyCharm2020.3/scratches/scratch_17.py", line 2, in <module>
    edgedb.connect(user='edgedb', password='edgedb')
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 374, in connect
    conn.ensure_connected()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 165, in ensure_connected
    self._reconnect(single_attempt=single_attempt)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 171, in _reconnect
    self._impl.connect(self._addrs, self._config, self._params,
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 62, in connect
    self._connect_addr(addr, config, params, connection)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 126, in _connect_addr
    proto.sync_connect()
  File "edgedb/protocol/blocking_proto.pyx", line 88, in edgedb.protocol.blocking_proto.BlockingIOProtocol.sync_connect
  File "edgedb/protocol/blocking_proto.pyx", line 77, in edgedb.protocol.blocking_proto.BlockingIOProtocol._iter_coroutine
  File "edgedb/protocol/protocol.pyx", line 915, in connect
  File "edgedb/protocol/protocol.pyx", line 983, in _auth_sasl
edgedb.errors.AuthenticationError: invalid SCRAM verifier for user 'edgedb'
Mulugruntz commented 3 years ago

When changing to


  edgedb:
    container_name: edgedb
    image: edgedb/edgedb:1-beta1
    environment:
      - EDGEDB_USER=test1
      - EDGEDB_PASSWORD=test2
import edgedb
edgedb.connect(user='test1', password='test2')

I get a different error message:

Traceback (most recent call last):
  File "/Users/sgiffard/Library/Application Support/JetBrains/PyCharm2020.3/scratches/scratch_17.py", line 2, in <module>
    edgedb.connect(user='test1', password='test2')
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 374, in connect
    conn.ensure_connected()
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 165, in ensure_connected
    self._reconnect(single_attempt=single_attempt)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 171, in _reconnect
    self._impl.connect(self._addrs, self._config, self._params,
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 62, in connect
    self._connect_addr(addr, config, params, connection)
  File "/Users/sgiffard/.local/share/virtualenvs/cfd-bot-async-dKbG-5ki/lib/python3.9/site-packages/edgedb/blocking_con.py", line 126, in _connect_addr
    proto.sync_connect()
  File "edgedb/protocol/blocking_proto.pyx", line 88, in edgedb.protocol.blocking_proto.BlockingIOProtocol.sync_connect
  File "edgedb/protocol/blocking_proto.pyx", line 77, in edgedb.protocol.blocking_proto.BlockingIOProtocol._iter_coroutine
  File "edgedb/protocol/protocol.pyx", line 915, in connect
  File "edgedb/protocol/protocol.pyx", line 1023, in _auth_sasl
edgedb.errors.AuthenticationError: authentication failed
elprans commented 3 years ago

EDGEDB_PASSWORD/EDGEDB_USER are only applied on new datadirs, so make sure the mounted data volume is empty when you change them.

Mulugruntz commented 3 years ago

It works! Thanks @elprans !

Should I open an issue to update documentation? Here or on the other repo? Or should I leave this one open?

elprans commented 3 years ago

I already opened #17 for the docs issue. Feel free to close this.