Skip to content

composer:warmup required database connection (server version doesn't resolved it) #61570

@TheDudoser

Description

@TheDudoser

Symfony version(s) affected

7.2

Description

symfony 7.2, composer warmup command in my pipline gitlab ci.

I was getting rid of the bundle structure in the project and suddenly, when warming up the cache, I had problems with the database link. In .env file, I have host.docker.internal specified and the replacement with the correct link occurs already when rolling out to the production kube cluster in secrets. However, now I have problems even at the project assembly stage, since symfony needs a connection to the database for some unknown reason. With host.docker.internal, the following error occurs:

#8 8.176 // Warming up the cache for the prod environment with debug false

#8 8.176

#8 9.473

#8 9.479 In ExceptionConverter.php line 101:

#8 9.479

#8 9.479 An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_get

#8 9.479 addresses: getaddrinfo for host.docker.internal failed: Name does not resol

#8 9.479 ve

#8 9.479

#8 9.479

#8 9.483 In Exception.php line 24:

#8 9.483

#8 9.483 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for host.docke

#8 9.483 r.internal failed: Name does not resolve

#8 9.483

#8 9.483

#8 9.487 In Driver.php line 33:

#8 9.487

#8 9.487 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for host.docke

#8 9.487 r.internal failed: Name does not resolve

#8 9.487

#8 9.487

#8 9.490 In Driver.php line 33:

#8 9.490

#8 9.490 PDO::__construct(): php_network_getaddresses: getaddrinfo for host.docker.i

#8 9.490 nternal failed: Name does not resolve

#8 9.490

#8 9.491

#8 9.491 cache:warmup [--no-optional-warmers]

If you specify, for example, localhost or 127.0.0.1, you will get the following error:

#16 8.276 // Warming up the cache for the prod environment with debug false

#16 8.276

#16 9.563

#16 9.566 In ExceptionConverter.php line 101:

#16 9.566

#16 9.566 An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refu

#16 9.566 sed

#16 9.566

#16 9.566

#16 9.567 In Exception.php line 24:

#16 9.567

#16 9.567 SQLSTATE[HY000] [2002] Connection refused

#16 9.567

#16 9.567

#16 9.568 In Driver.php line 33:

#16 9.568

#16 9.568 SQLSTATE[HY000] [2002] Connection refused

#16 9.568

#16 9.568

#16 9.568 cache:warmup [--no-optional-warmers]

My .env:

...
DB_USER=root
DB_PASS=root
DB_HOST=host.docker.internal
DB_PORT="3306"
DB_NAME=afisha
DB_SERVER_VERSION="5.7"
DB_CHARSET=utf8mb4
DATABASE_URL="mysql://${DB_USER}:${DB_PASS}@${DB_HOST}/${DB_NAME}?serverVersion=${DB_SERVER_VERSION}&charset=${DB_CHARSET}"

my doctrine.yaml:

doctrine:
  dbal:
    connections:
      default:
        server_version: '%env(DB_SERVER_VERSION)%'
        driver: 'pdo_mysql'
        host: '%env(DB_HOST)%'
        port: '%env(DB_PORT)%'
        dbname: '%env(DB_NAME)%'
        user: '%env(DB_USER)%'
        password: '%env(DB_PASS)%'
        charset: '%env(DB_CHARSET)%'
...

For doctrine.yaml I'm tried replace to url: '%env(resolve:DATABASE_URL)%'

How to reproduce

Changed DATABASE_URL, server_version, IP, cleared the cache of runners in gitlab

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions