getsentry / self-hosted

Sentry, feature-complete and packaged up for low-volume deployments and proofs-of-concept
https://develop.sentry.dev/self-hosted/
Other
7.83k stars 1.76k forks source link

(Open Source) Docker Desktop is Absolutely Not Cooperating on Install #3269

Closed ApprenticeofEnder closed 2 months ago

ApprenticeofEnder commented 2 months ago

Environment

self-hosted (https://develop.sentry.dev/self-hosted/)

Steps to Reproduce

  1. Be on Linux Mint 21.3 with a fresh install of Docker Desktop. Versions for Docker Desktop and Docker Engine are 4.32.0 (157355) and 27.0.3 in the app respectively, however docker --version in the shell shows 27.1.2. Take that as you may.
  2. Clone the repository (or fork and clone).
  3. Install devenv.
  4. Run devenv boostrap.
  5. Run brew bundle in the event something goes wonky with direnv.
  6. Run devenv sync to try to sync dependencies and spool up development-related containers.

Expected Result

The containers should spool up without issue.

Actual Result

Using docker desktop.
> Container 'sentry_postgres' is already running
> Container 'sentry_redis' is already running
> Checking container health 'postgres'
> Checking container health 'redis'
  > Health check for 'redis' failed, retrying in 5s (attempt 2 of 3)...
  > Health check for 'postgres' failed, retrying in 5s (attempt 2 of 3)...
  > Health check for 'redis' failed, retrying in 5s (attempt 3 of 3)...
  > Health check for 'postgres' failed, retrying in 5s (attempt 3 of 3)...
  > 'redis' is not healthy
  > 'postgres' is not healthy
> Failed to check health: Command '('docker', 'exec', 'sentry_redis', 'redis-cli', 'ping')' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/home/ender/Documents/Projects/sentry/.venv/bin/sentry", line 4, in <module>
    raise SystemExit(main())
                     ^^^^^^
  File "/home/ender/Documents/Projects/sentry/src/sentry/runner/main.py", line 149, in main
    func(**kwargs)
  File "/home/ender/Documents/Projects/sentry/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/src/sentry/runner/commands/devservices.py", line 359, in up
    future.result()
  File "/home/ender/.local/share/sentry-devenv/pythons/3.11.8/python/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/ender/.local/share/sentry-devenv/pythons/3.11.8/python/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/ender/.local/share/sentry-devenv/pythons/3.11.8/python/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ender/Documents/Projects/sentry/src/sentry/runner/commands/devservices.py", line 633, in check_health
    run_with_retries(
  File "/home/ender/Documents/Projects/sentry/src/sentry/runner/commands/devservices.py", line 650, in run_with_retries
    cmd()
  File "/home/ender/Documents/Projects/sentry/src/sentry/runner/commands/devservices.py", line 630, in hc
    healthcheck.check(options)
  File "/home/ender/Documents/Projects/sentry/src/sentry/runner/commands/devservices.py", line 701, in check_redis
    subprocess.run(
  File "/home/ender/.local/share/sentry-devenv/pythons/3.11.8/python/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('docker', 'exec', 'sentry_redis', 'redis-cli', 'ping')' returned non-zero exit status 1.
Command `.venv/bin/sentry devservices up redis postgres` failed! (code 1)

For reference, docker context ls gives:

NAME              DESCRIPTION                               DOCKER ENDPOINT                                  ERROR
default           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                      
desktop-linux *   Docker Desktop                            unix:///home/ender/.docker/desktop/docker.sock

docker ps -a comes up empty for containers.

AMENDMENT: Realized I originally ran devenv sync while in the default context and then switched after the fact. However, even when I ran devenv sync under the desktop-linux context, the containers were actually under the default context?

$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$ docker context use default
default
Current context is now "default"
$ docker ps
CONTAINER ID   IMAGE                                                       COMMAND                  CREATED         STATUS                 PORTS                                                                  NAMES
6d114f60fa62   ghcr.io/getsentry/image-mirror-library-redis:5.0-alpine     "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes           127.0.0.1:6379->6379/tcp                                               sentry_redis
37948c301c4f   ghcr.io/getsentry/image-mirror-library-postgres:14-alpine   "docker-entrypoint.s…"   2 minutes ago   Up 2 minutes           127.0.0.1:5432->5432/tcp                                               sentry_postgres

Note that this was after I made sure to kill the containers within the default context and then reran devenv sync under desktop-linux.

Setting the DOCKER_CONTEXT environment variable gave, surprisingly, the same result.

I tried deleting the images entirely from the default context and then reran under desktop-linux and this happened:

Using docker desktop.
> Creating 'sentry' network
> Pulling image 'ghcr.io/getsentry/image-mirror-library-postgres:14-alpine'
> Pulling image 'ghcr.io/getsentry/image-mirror-library-redis:5.0-alpine'
> Creating container 'sentry_redis'
> Starting container 'sentry_redis' (listening: ('127.0.0.1', 6379))
> Creating container 'sentry_postgres'
> Starting container 'sentry_postgres' (listening: ('127.0.0.1', 5432))
> Checking container health 'redis'
> Checking container health 'postgres'
  > Health check for 'postgres' failed, retrying in 5s (attempt 2 of 3)...
  > Health check for 'redis' failed, retrying in 5s (attempt 2 of 3)...
  > Health check for 'redis' failed, retrying in 5s (attempt 3 of 3)...
  > Health check for 'postgres' failed, retrying in 5s (attempt 3 of 3)...
  > 'postgres' is not healthy
  > 'redis' is not healthy
> Failed to check health: Command '('docker', 'exec', 'sentry_postgres', 'pg_isready', '-U', 'postgres')' returned non-zero exit status 1.

For some reason, it doesn't want to actually get the containers into the Docker Desktop context. I think it might be something to do with how it's run on a VM?

For the record, I can't run sentry devservices up because I think devenv sync does something to make a sentry binary available in the PATH? I'm not 100% sure at this point.

Product Area

Other

Link

No response

DSN

No response

Version

24.7.1

getsantry[bot] commented 2 months ago

Assigning to @getsentry/support for routing ⏲️

aldy505 commented 2 months ago

@dalnoki devenv is about developing sentry repository, it has nothing to do with self-hosted.

@hubertdeng123 @joshuarli help on re-transferring this back to sentry, please?

joshuarli commented 2 months ago

Not a self-hosted issue, but I think your problem should be fixed with https://github.com/getsentry/sentry/pull/76334. Please open a ticket in sentry if you run into further issues and I can get you a closer look (devenv for sentry on linux is somewhat untested)