Skip to content

[IMP] runbot: support postgres inside docker - #1433

Merged
Xavier-Do merged 1 commit into
19.0from
19.0-docker-pg-xdo
Oct 22, 2026
Merged

Xavier-Do merged 1 commit into
19.0from
19.0-docker-pg-xdo

Conversation

@Xavier-Do

@Xavier-Do Xavier-Do commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Runbot currently work by sharing a postgresql cluster across multiple build, convenient to share, maintain and re-use database but this is not perfect for isolation. Mainly, the cpu limits of docker is not reflected to the PostgreSQL server, meaning that high intensive cpu/memory operation on postgres can exhaust resources to other builds, making the test time vary a lot depending on the load for some builds. This also cause issues where the server load is high making the auto-vaccum behavior unpredictable.

With this change the docker limits will be applied to the PostgreSQL server and we will be able to tweak the config per build if needed (memory, vacuum, ...).

The main change is the introduction of an entrypoint in the docker image. This entrypoint does not depend on the runbot infrastructure and should be generic, to allow to use the image locally. When started, the docker image entrypoint will create/restore a cluster if needed and start postgress. On stop, it will export the cluster if requested.
The entrypoint logic can be skipped by mounting /var/run/postgresql in the docker, forcing the docker file to use another existing socket. This will help in the transition between the two options. a parameter use_host_postgres can be given in the params to prevent mounting /var/run/postgresql in the docker image, as well as a param on the dockerfile, allowing to axis to migrate to the full dockerized postgress: one using the trigger, the other using the docker image config. In the future all of that will be most likely removed to only support docker in postgress.

A little "hacky" but this files are only mounted if PG_VERSION is defined, to avoid to add an entry point in images that don't have/need a pg_server.

restore

While on it a few changes are made in the restore step, in order to make it easier to debug and configure. As a side effect some changes of behavior are expected:

  • the docker file that will be used to restore will be the same as the source build
  • restore_rename_db_suffix is now only applied when downloading a dump from an url
  • generally, once a reference build is found the behavior to select a suffix to download and a target name should be more coherent, only the dump_url part is different.
    - in general this change will need in depth testing and most likely need to adapt some existing restore

Upgrade cluster

A typical upgrade flow will be like this

  • restore a 19 database
  • run pre tests in 19
  • run upgrade to 20
  • run post test in 20

Since the Docker 19 used in the first two can be in a different ubuntu version, the postgresl version is not always the same between the pre steps and the upgrade step. The cluster will be in a different place if it is the case, PGDATA=/data/build/postgres/${PG_VERSION} so if the PG_VERSION changes, we need to restore a database exported from the pre. In this case we can only import the sql file

The current version is far from ideal, we need to explicitly have a zip generation in the previous step, and this will generate a zip file, but detect that we may need the raw dump and leave the files in place. This will work for now but could be replace by a more precise database export, only if the next step will really need it, without always generating the zip of the database and the cluster. In the context of the pre step, it makes sense. We could also want to immediately restore the database in the right docker version if the next won't use the same docker-file. Some cleanup should be done here, most likely by introducing the pre test in the runbot code to make everything more formal.

@C3POdoo
C3POdoo requested a review from a team June 17, 2026 06:49
@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 2 times, most recently from 2040bf1 to 10dceb9 Compare June 29, 2026 11:38
@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 2 times, most recently from c8a8d38 to 44156d9 Compare September 18, 2026 10:42
@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 15 times, most recently from b52936f to 0ff1b3b Compare October 15, 2026 09:03
@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 10 times, most recently from 5fb3eb1 to e8381b7 Compare October 16, 2026 12:55
Comment thread runbot/docker_files/postgres/start_postgres.sh Outdated
@bepro-odoo

bepro-odoo commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

the start/stop scripts are not valid in dash-dialect. dash is the interpreter mode selected when "/bin/sh"-ing in ubuntu resolute containers, verified with runbot image odoo:DockerMaster.future (aka DockerMasterPostgres).

check yourself running shellcheck;

shellcheck --norc --shell dash /tmp/start_postgres.sh

Easy fix is to add the shebang for bash at the top of scripts

#!/bin/bash

@Xavier-Do

Copy link
Copy Markdown
Contributor Author

The scripts are not executable and explicitly called with bash in the entrypoint. But I don't mind adding the shebang.

@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 3 times, most recently from 373258a to 1b622b7 Compare October 20, 2026 07:47
Comment thread runbot/docker_files/postgres/stop_postgres.sh Outdated
@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 5 times, most recently from 531ae78 to 186f71f Compare October 20, 2026 09:13
@Xavier-Do Xavier-Do changed the title 19.0 docker pg xdo [IMP] runbot: support postgres inside docker Oct 20, 2026
@Xavier-Do
Xavier-Do force-pushed the 19.0-docker-pg-xdo branch 14 times, most recently from 725c60c to 9e4140e Compare October 21, 2026 08:21
@Xavier-Do
Xavier-Do merged commit ebaa420 into 19.0 Oct 22, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants