Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Appserver Postgres Client mismatch #2

Open

Description

@dpacassi

When creating a Drupal project with Lando and the following yml file:

name: testproject
recipe: drupal9
config:
  webroot: web
  php: '7.4'
  composer_version: '1.10.22'
  xdebug: false
  database: postgres:13

The DB version is 13 while the client bin versions (psql and pg_dump on appserver) are still on version 10.
If I define another Postgres version in the config, I'd expect that the recipe automatically uses the right version also for the client commands (psql, pg_dump).

I guess this is related to lando/lando#1680. I found a workaround also there.
I added following lines to get the client bins with the right version:

    build_as_root:
      - "apt -y update && apt-get install -y gnupg2 && echo 'deb https://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' >> /etc/apt/sources.list.d/pgdg.list && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && apt -y update && apt-get install -y postgresql-client-13"

Activity

  1. transferred this issue fromlando/landoon Jan 5, 2022
  2. added
    bug
    and removed on Jan 5, 2022
  3. Daisuke-sama commented on Mar 22, 2022

    @Daisuke-sama

    hey!
    Same for me, while I am looking for the twelve version.
    Also I cannot override the credentials

  4. labboy0276 commented on Apr 1, 2022

    @labboy0276
    Sponsor

    @dpacassi @Daisuke-sama can you please provide steps to replicate. Using the following lando file:

    name: d9-postgres
    recipe: drupal9
    config:
      webroot: .
      php: '7.4'
      xdebug: false
      database: postgres:13
    

    The commands show the right version:

    john@tandem:~/lando/1-test-sites/d9-postgres$ lando psql --version
    psql (PostgreSQL) 13.5
    john@tandem:~/lando/1-test-sites/d9-postgres$ lando psql
    psql (13.5)
    
  5. Daisuke-sama commented on Apr 1, 2022

    @Daisuke-sama

    sure, my steps:

    name: web
    recipe: lemp
    config:
      php: 7.4
      database: postgres:12
    //or
    services:
      database:
        type: postgres:12
        portforward: 54321
    

    and I get pg_restore --version or sql --version is 10 unless I force the installation of 12 using the run section of the configuration. Because my dump file doesn't load to the database and writes incompatible version.

  6. Daisuke-sama commented on Apr 1, 2022

    @Daisuke-sama

    image

  7. labboy0276 commented on Apr 1, 2022

    @labboy0276
    Sponsor

    strange @Daisuke-sama on this lando file:

    name: d9-postgres
    recipe: drupal9
    config:
      webroot: .
      php: '7.4'
      xdebug: false
      database: postgres:13
    

    I get the following:

    john@tandem:~/lando/1-test-sites/d9-postgres$ lando ssh -s database
    www-data@5a3068247653:/app$ psql --version
    psql (PostgreSQL) 13.5
    www-data@5a3068247653:/app$ pg_restore --version
    pg_restore (PostgreSQL) 13.5
    

    And on yours:

    name: lando-rando
    recipe: lemp
    config:
      php: 7.4
      database: postgres:12
    
    john@tandem:~/lando/1-test-sites/rando-tests$ lando ssh -s database
    www-data@bed14b152d0c:/app$ pg_restore --version
    pg_restore (PostgreSQL) 12.9
    www-data@bed14b152d0c:/app$ psql --version
    psql (PostgreSQL) 12.9
    

    What version of Lando are you on? Have you tried purging your system and starting over? https://docs.lando.dev/help/purging-containers.html

  8. long-blade commented on Nov 23, 2022

    @long-blade

    Same problem

    After purging my system and starting over.

    image

  9. xurizaemon commented on Jul 7, 2023

    @xurizaemon
    Sponsor

    I think the issue description captures this, but our team ran into this and the cause wasn't obvious so I'll add a comment. Here's a minimal repro, showing that with a simple configuration it's possible to see mismatched client versions:

    .lando.yml:

    name: lando-test
    recipe: drupal7
    config:
      database: postgres:12

    steps to reproduce:

    $ lando ssh -s database -c 'pg_restore --version'
    pg_restore (PostgreSQL) 12.9
    
    $ lando ssh -s appserver -c 'pg_restore --version'
    pg_restore (PostgreSQL) 10.23 (Debian 10.23-1.pgdg110+1)
    $ lando ssh -c 'pg_restore --version'
    pg_restore (PostgreSQL) 10.23 (Debian 10.23-1.pgdg110+1)
    

    (the last two commands are the same, specifying then omitting the host)

    In a Drupal recipe, drush sql:* will be wrapping the appserver versions of the commands, while Lando's sql-import command will use the database host's client tools and versions (unless the user specifies -h).

    If the appserver needs matching versions (eg to use drush sql:* commands with PostgreSQL), then a workaround is to add a build step for your appserver to install a matching set of PostgreSQL client commands, as noted by @dpacassi in the issue description.


    Working on both postgres and non-postgres projects, I'd probably rather Lando didn't add such a build step by default, unless it applied only to Lando configurations where postgres was used, as I wouldn't want to have to wait for extra steps on a rebuild if the project at hand won't use those tools at all.

    NB: @Daisuke-sama #2 (comment) did not behave as expected because the test was done with lando ssh database (which drops the user into an appserver shell), not lando ssh -s database (database shell).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions