Skip to content

set-up-and-migrate-database.sh uses hard exec into container #2804

@puittenbroek

Description

@puittenbroek

Self-Hosted Version

24.2.0

CPU Architecture

x86_64

Docker Version

25.0.3

Docker Compose Version

v2.23.3

Steps to Reproduce

Two ways this will not work:

  1. Use an 'off site' postgres configuring DATABASES in sentry.conf.py
  2. Use different user then postgres in postgres (also via sentry.conf.py and POSTGRES_USER env)

For the 'off site postgres' you could argue it's not a 'supported feature'; but without recent changes it worked fine.

To limit resource usage we also disabled the postgres service by using a docker-compose.override.yml:

services:
  postgres:
    restart: ''
    image: alpine
    command: sh -c "while true; do sleep 60; done"
    entrypoint: [] 
    healthcheck:
      test: 'echo "Running"'
      start_period: 0s

In sentry.conf.py:

DATABASES = {
    "default": {
        "ENGINE": "sentry.db.postgres",
        "NAME": "sentry",
        "USER": "sentry",
        "PASSWORD": "superseret",
        "HOST": "somehost.ofours.com",
        "PORT": "1337",
    }
}

install.sh wlll fail because it cannot exe into the postgres service here;

$dc exec postgres psql -qAt -U postgres -c "ALTER TABLE IF EXISTS sentry_groupedmessage DROP CONSTRAINT IF EXISTS sentry_groupedmessage_project_id_id_515aaa7e_uniq;"
$dc exec postgres psql -qAt -U postgres -c "DROP INDEX IF EXISTS sentry_groupedmessage_project_id_id_515aaa7e_uniq;"

Expected Result

  • Using Django to execute database changes
  • Not using 'hard coded' exec like this.

I understand this is due to a Django bug and is (being?) fixed. So I wonder if recent changes in install/set-up-and-migrate-database.sh are still needed.

Actual Result

▶ Setting up / migrating database ...
 Container sentry-self-hosted-postgres-1  Creating
 Container sentry-self-hosted-postgres-1  Created
 Container sentry-self-hosted-postgres-1  Starting
 Container sentry-self-hosted-postgres-1  Started
Waiting for postgres server, 5 remaining attempts...
Waiting for postgres server, 4 remaining attempts...
Waiting for postgres server, 3 remaining attempts...
Waiting for postgres server, 2 remaining attempts...
Waiting for postgres server, 1 remaining attempts...
OCI runtime exec failed: exec failed: unable to start container process: exec: "psql": executable file not found in $PATH: unknown
Error in install/set-up-and-migrate-database.sh:11.
'$dc exec postgres psql -qAt -U postgres -c "ALTER TABLE IF EXISTS sentry_groupedmessage DROP CONSTRAINT IF EXISTS sentry_groupedmessage_project_id_id_515aaa7e_uniq;"' exited with status 126
-> ./install.sh:main:35
--> install/set-up-and-migrate-database.sh:source:11

Event ID

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions