GitLab CI generates database name for Postgres that is longer than the 63 character limit (django.core.exceptions.ImproperlyConfigured)
Summary
A pipeline is failing because of a service that the job depends on. The service is postgres, and it is generating a database name that is too long.
Steps to reproduce
https://gitlab.com/briancaffey/django-step-by-step
This repo contains all of the code to reproduce this issue. Here is a line from the logs of a recent pipeline that describes the issue: https://gitlab.com/briancaffey/django-step-by-step/-/jobs/1337996442#L4902
.gitlab-ci.yml
stages:
- test
Pytest:
image: python:3.9
stage: test
services:
- postgres:12.2-alpine
- redis:6.2.4
variables:
# https://docs.gitlab.com/ee/ci/services/postgres.html#use-postgresql-with-the-docker-executor
POSTGRES_DB: postgresabc
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: "trust"
POSTGRES_SERVICE_HOST: "postgres"
REDIS_SERVICE_HOST: "redis"
SECRET_KEY: "secret"
DEBUG: "1"
before_script:
- cd backend
- pip install -r requirements_dev.txt
script:
- flake8
- black -l 79 -S --check .
- pytest --cov
after_script:
- echo "Pytest tests complete"
coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
Actual behavior
The pipeline fails with the following error message:
E django.core.exceptions.ImproperlyConfigured: The database name 'test_/runner-72989761-project-24058109-concurrent-0-6bdae66575c5a712-build-2/postgres' (85 characters) is longer than PostgreSQL's limit of 63 characters. Supply a shorter NAME in settings.DATABASES.
Expected behavior
I would expect the pipeline to succeed. I'm also not sure why the database name is as long as it is, given that I name it postgres
in my database settings.
Relevant logs and/or screenshots
job log
https://gitlab.com/briancaffey/django-step-by-step/-/jobs/1337996442#L4902
E django.core.exceptions.ImproperlyConfigured: The database name 'test_/runner-72989761-project-24058109-concurrent-0-6bdae66575c5a712-build-2/postgres' (85 characters) is longer than PostgreSQL's limit of 63 characters. Supply a shorter NAME in settings.DATABASES.
Environment description
I am using GitLab.com.
Edited by Brian Caffey