Merge branch 'fix_psycopg2_and_pg_auth_method_conflict' into 'main'
[FIX] psycopg2 / pg versions auth conflict See merge request odoo-openupgrade-wizard/odoo-openupgrade-wizard!83
This commit is contained in:
commit
3159d61b8c
2
newsfragments/fix-odoo-12-postgresql-14.fix
Normal file
2
newsfragments/fix-odoo-12-postgresql-14.fix
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Make odoo openupgrade wizard working in the following combination:
|
||||||
|
Odoo version <= 12 + Postgresql version >= 14
|
||||||
|
|
@ -47,24 +47,54 @@ def get_postgres_container(ctx):
|
||||||
logger.info(f"Creating Postgres volume: {volume_name}")
|
logger.info(f"Creating Postgres volume: {volume_name}")
|
||||||
client.volumes.create(volume_name)
|
client.volumes.create(volume_name)
|
||||||
|
|
||||||
command = None
|
command = "postgres"
|
||||||
postgres_extra_settings = ctx.obj["config"].get("postgres_extra_settings")
|
postgres_extra_settings = ctx.obj["config"].get("postgres_extra_settings")
|
||||||
if postgres_extra_settings:
|
if postgres_extra_settings:
|
||||||
command = "postgres"
|
|
||||||
for key, value in postgres_extra_settings.items():
|
for key, value in postgres_extra_settings.items():
|
||||||
command += f" -c {key}={value}"
|
command += f" -c {key}={value}"
|
||||||
|
|
||||||
logger.info(f"Launching Postgres Container. (Image {image_name})")
|
logger.info(f"Launching Postgres Container. (Image {image_name})")
|
||||||
container = run_container(
|
|
||||||
image_name,
|
# base environement variables
|
||||||
container_name,
|
environments = {
|
||||||
command=command,
|
|
||||||
environments={
|
|
||||||
"POSTGRES_USER": "odoo",
|
"POSTGRES_USER": "odoo",
|
||||||
"POSTGRES_PASSWORD": "odoo",
|
"POSTGRES_PASSWORD": "odoo",
|
||||||
"POSTGRES_DB": "postgres",
|
"POSTGRES_DB": "postgres",
|
||||||
"PGDATA": "/var/lib/postgresql/data/pgdata",
|
"PGDATA": "/var/lib/postgresql/data/pgdata",
|
||||||
},
|
}
|
||||||
|
|
||||||
|
# if postgresql version is >= 14 and odoo <= 12 we need to use md5 for auth
|
||||||
|
# method and password encryption
|
||||||
|
try:
|
||||||
|
postgres_version = float(image_name.split(":")[1])
|
||||||
|
except ValueError:
|
||||||
|
raise Exception(
|
||||||
|
"Unable to extract postgres version "
|
||||||
|
f"from image name {image_name}. "
|
||||||
|
"Define version in the image name is mandatory."
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
odoo_start_version = float(ctx.obj["config"]["odoo_versions"][0])
|
||||||
|
except ValueError:
|
||||||
|
raise Exception(
|
||||||
|
"Unable to extract start odoo version from odoo_versions "
|
||||||
|
f"{ctx.obj['config']['odoo_versions']}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if odoo_start_version <= 12 and postgres_version >= 14:
|
||||||
|
environments |= {
|
||||||
|
"POSTGRES_HOST_AUTH_METHOD": "md5",
|
||||||
|
"POSTGRES_INITDB_ARGS": "--auth-host=md5",
|
||||||
|
}
|
||||||
|
|
||||||
|
command += " -c password_encryption=md5"
|
||||||
|
|
||||||
|
container = run_container(
|
||||||
|
image_name,
|
||||||
|
container_name,
|
||||||
|
command=command,
|
||||||
|
environments=environments,
|
||||||
volumes={
|
volumes={
|
||||||
# Data volume
|
# Data volume
|
||||||
volume_name: "/var/lib/postgresql/data/pgdata/",
|
volume_name: "/var/lib/postgresql/data/pgdata/",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
from . import cli_runner_invoke, move_to_test_folder
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_downgrade_pg_auth_method_for_old_versions():
|
||||||
|
move_to_test_folder()
|
||||||
|
|
||||||
|
cli_runner_invoke(
|
||||||
|
[
|
||||||
|
"init",
|
||||||
|
"--project-name=test-cli-downgrade-auth-method",
|
||||||
|
"--initial-version=12.0",
|
||||||
|
"--final-version=13.0",
|
||||||
|
"--postgresql-version=14",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
move_to_test_folder()
|
||||||
|
cli_runner_invoke(["get-code"])
|
||||||
|
cli_runner_invoke(["docker-build", "--versions=12.0"])
|
||||||
|
|
||||||
|
db_name = "database_test_cli-downgrade-auth-method__run"
|
||||||
|
cli_runner_invoke(
|
||||||
|
[
|
||||||
|
"run",
|
||||||
|
"--step=1",
|
||||||
|
f"--database={db_name}",
|
||||||
|
"--init-modules=base",
|
||||||
|
"--stop-after-init",
|
||||||
|
],
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue
Block a user