Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication Failure in test and prod env #418

Closed
bosd opened this issue Apr 16, 2021 · 20 comments
Closed

Authentication Failure in test and prod env #418

bosd opened this issue Apr 16, 2021 · 20 comments
Labels

Comments

@bosd
Copy link

bosd commented Apr 16, 2021

Used image postgres 14 13.
Occurs in both odoo 13 and 14

Describe the bug

When starting the production environment the log reads:

db_1                          | 	Connection matched pg_hba.conf line 8: "host all all 172.19.0.0/16 md5"
db_1                          | 2021-04-16 13:21:34.283 GMT [190] FATAL:  password authentication failed for user "odoo"
db_1                          | 2021-04-16 13:21:34.283 GMT [190] DETAIL:  Password does not match for user "odoo".
db_1                          | 	Connection matched pg_hba.conf line 8: "host all all 172.19.0.0/16 md5"
db_1                          | 2021-04-16 13:21:35.409 GMT [191] FATAL:  password authentication failed for user "odoo"
db_1                          | 2021-04-16 13:21:35.409 GMT [191] DETAIL:  Password does not match for user "odoo".
db_1                          | 	Connection matched pg_hba.conf line 8: "host all all 172.19.0.0/16 md5"
db_1                          | 2021-04-16 13:21:36.499 GMT [192] FATAL:  password authentication failed for user "odoo"
db_1                          | 2021-04-16 13:21:36.499 GMT [192] DETAIL:  Password does not match for user "odoo".
db_1                          | 	Connection matched pg_hba.conf line 8: "host all all 172.19.0.0/16 md5"

A clear and concise description of what the bug is.

To Reproduce

Follow regular workflow:
Install copier
invoke img-pull img-build --pull git-aggregate resetdb start

set the secrets in:
./.docker/db-access.env to PGPASSWORD=odoopassword
./.docker/db-creation.env to POSTGRES_PASSWORD=odoopassword
(or leve them alone as they are filled from the copier script)

initiate the database with
docker-compose run --rm odoo --stop-after-init -i base

(Docker may throw an network error, preform an extra compose down and docker network prune)

start production environment with:
docker-compose -f prod.yaml up

Affected versions:
Used image postgres 14 13. (edit: typo)
Occurs in both odoo 13 and 14

Expected behavior
Booting into production environment.

Additional context Add any other context about the problem here. (e.g. OS, Docker
version, ...)
host system debian10

@bosd bosd added the bug label Apr 16, 2021
@pedrobaeza
Copy link
Member

Postgres 14 is not yet compatible. Use <= 13.

@bosd
Copy link
Author

bosd commented Apr 16, 2021

Thanks for the prompt reply. My mad. it was actually using postgresversion 13

@pedrobaeza
Copy link
Member

Do you have any kind of custom rule for DB?

@bosd
Copy link
Author

bosd commented Apr 16, 2021

no

@pedrobaeza
Copy link
Member

@joao-p-marques do you know what is happening?

@joao-p-marques
Copy link
Contributor

@bosd did you have an old password set up and then changed? If so, it might be that that password is not getting updated. It should be done automatically, but try running docker-compose exec odoo config-generate to force Doodba to rewrite the Odoo config and populate that password correctly. Then, you can inspect the file odoo/auto/odoo.conf and check if the password is correct.

@bosd
Copy link
Author

bosd commented Apr 16, 2021

just checked if this was related to the single line yaml input for domain prod and domain test. But even with leaving these values empty it occurs.

log from freshly installed test on a vps:

db_1 | 2021-04-16 14:05:16.937 GMT [1] LOG: starting PostgreSQL 13.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit
db_1 | 2021-04-16 14:05:16.940 GMT [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2021-04-16 14:05:16.940 GMT [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2021-04-16 14:05:16.944 GMT [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

The devel environment is working fine.
Not so experienced debugger. I was thinking it was related to the secrets set in the files.
But even modifying the yaml files with hard-coding the password gives the same result.

@bosd
Copy link
Author

bosd commented Apr 16, 2021

did you have an old password set up and then changed?

No, I experienced this from a fresh copier install.
It was later on in my debuging attempts that I changed the password.
(it kept me busy from this morning on, on multple machines and tests :)

Will try your suggestions and report back.

@joao-p-marques
Copy link
Contributor

Ok, it might also be that the container that is not updating is the Postgres one, so you could try to delete the volumes (invoke stop --purge or docker-compose down -v) and launch them again...

@bosd
Copy link
Author

bosd commented Apr 16, 2021

ran
$ docker-compose exec odoo config-generate
doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf

but still an authentication eror

@joao-p-marques
Copy link
Contributor

Ok, what about the last suggestion and recreating the DB volumes?

@bosd
Copy link
Author

bosd commented Apr 16, 2021

it is still executing :)
Will report back...

I noticed that the conents of odoo.conf is set to odoopassword just like in the dev environment yaml file.
However, the contents of /.docker/db-access.env i left to default on this fresh instance. Which is example-db-password

almost finished loading now. Looks like it is connecting. Because there is the not initilazed db error.

b_1    | 2021-04-16 14:31:39.155 GMT [49] LOG:  database system was shut down at 2021-04-16 14:31:38 GMT
db_1    | 2021-04-16 14:31:39.162 GMT [1] LOG:  database system is ready to accept connections
odoo_1  | doodba INFO: Unaccent extension installed
odoo_1  | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1  | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1  | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1  | doodba INFO: Executing /usr/local/bin/odoo
odoo_1  | 2021-04-16 14:31:42,472 1 INFO ? odoo: Odoo version 14.0 
odoo_1  | 2021-04-16 14:31:42,474 1 INFO ? odoo: Using configuration file at /opt/odoo/auto/odoo.conf 
odoo_1  | 2021-04-16 14:31:42,475 1 INFO ? odoo: addons paths: ['/opt/odoo/custom/src/odoo/odoo/addons', '/var/lib/odoo/addons/14.0', '/opt/odoo/auto/addons'] 
odoo_1  | 2021-04-16 14:31:42,477 1 INFO ? odoo: database: odoo@db:5432 
odoo_1  | 2021-04-16 14:31:43,034 1 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf 
odoo_1  | 2021-04-16 14:31:43,519 1 INFO ? odoo.service.server: HTTP service (werkzeug) running on 5a08e0585834:8069 
odoo_1  | 2021-04-16 14:31:43,540 1 ERROR ? odoo.modules.loading: Database prod not initialized, you can force it with `-i base` 
odoo_1  | 2021-04-16 14:32:43,604 1 ERROR prod odoo.sql_db: bad query: SELECT latest_version FROM ir_module_module WHERE name='base'
odoo_1  | ERROR: relation "ir_module_module" does not exist
odoo_1  | LINE 1: SELECT latest_version FROM ir_module_module WHERE name='base...
odoo_1  |                                    ^
odoo_1  |  
odoo_1  | 2021-04-16 14:32:43,606 1 WARNING ? odoo.addons.base.models.ir_cron: Tried to poll an undefined table on database prod. 

@bosd
Copy link
Author

bosd commented Apr 16, 2021

🎉 it's working now

After my previous message I had to initialize the db.
used the command docker-compose run --rm odoo --stop-after-init -i base
but that command resulted in an endless
doodba INFO: Waiting until postgres is listening at db...
as that command is in the dev environment

after a
$ docker-compose -f prod.yaml run --rm odoo --stop-after-init -i base
it has correctly initialized the prod db.

for testing purposes... continueing the test.
(intitially wanted to update the project by running copier update and copier --force but got an dirty error.)
So I started over. deleted the project folder and run the copier again and changed it to use my own password for postgres.

similar, the prod environment will not launch
docker-compose down -v
and
docker-compose -f prod.yaml up
wil throw a lot of errors:

db_1 | 2021-04-16 15:15:36.072 GMT [1] LOG: database system is ready to accept connections
odoo_1 | doodba INFO: Unaccent extension installed
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1
odoo_1 | doodba INFO: Waiting until postgres is listening at db...
odoo_1 | doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons
odoo_1 | doodba INFO: Generating /opt/odoo/auto/odoo.conf file. Overriding any existing...
odoo_1 | doodba INFO: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1 | doodba INFO: Executing /usr/local/bin/odoo
odoo_1 | Traceback (most recent call last):
odoo_1 | File "/opt/odoo/common/entrypoint", line 75, in
odoo_1 | os.execvp(extra_command[0], extra_command)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 568, in execvp
odoo_1 | _execvpe(file, args)
odoo_1 | File "/usr/local/lib/python3.8/os.py", line 591, in _execvpe
odoo_1 | exec_func(file, *argrest)
odoo_1 | FileNotFoundError: [Errno 2] No such file or directory
int14_odoo_1 exited with code 1

so invoke stop --purge
docker-compose -f prod.yaml up
docker-compose -f prod.yaml run --rm odoo --stop-after-init -i base

Summary for my understanding.
It is not possible anymore to switch directly between environments. The volumes needs to be purged before doing so.
This was not very clearly documented.

Further remarks:
I have set the odoo_initial_lang to my locale. But it still initialized the db in en_US

@joao-p-marques
Copy link
Contributor

Thanks for the detailed description @bosd I am glad it is working for you now.

A few remarks and answers to your questions:

initially wanted to update the project by running copier update and copier --force but got an dirty error

Just for reference, copier will always give you this error when trying to run an update on a git repo with uncommitted changes. You should always commit them before running the update.

Summary for my understanding.
It is not possible anymore to switch directly between environments. The volumes needs to be purged before doing so.
This was not very clearly documented.

Maybe @yajo can give some more insight on the way this should be handled, but the main use case for the copier template project with different environments was not to have them all running on the same server... You would tipically have your development environment in your development machine, and your test/prod environment running in a staging/production server. It makes sense that you would need to rebuild the associated volumes, as they will always have different characteristics depending on the environment.

I have set the odoo_initial_lang to my locale. But it still initialized the db in en_US

AFAICS that variable is only being used in the prod environment: https://github.com/Tecnativa/doodba-copier-template/blob/stable/prod.yaml.jinja#L18
Should we add it to the others @yajo?

@yajo
Copy link
Contributor

yajo commented Apr 20, 2021

the main use case for the copier template project with different environments was not to have them all running on the same server... You would tipically have your development environment in your development machine, and your test/prod environment running in a staging/production server. It makes sense that you would need to rebuild the associated volumes, as they will always have different characteristics depending on the environment.

Yes, and not only the volumes. The image doodba builds for devel isn't compatible with the image built for test/prod.

AFAICS that variable is only being used in the prod environment: https://github.com/Tecnativa/doodba-copier-template/blob/stable/prod.yaml.jinja#L18
Should we add it to the others @yajo?

Nope, devel is always done in English.

This seems fixed, so closing 😺

@yajo yajo closed this as completed Apr 20, 2021
@bosd
Copy link
Author

bosd commented Apr 20, 2021

Yes, issue is fixed.
As it is the result of not using the correct workflow.

I am actually using the devel environment on a different machine and the production env on the server.

Seems, like Im not following the correct workflow for developing local and then take take it into production.
obvisouly the workflow described in the above method for building the prod environment on the server is'nt correct.
As with the stop --purge it is deleting the volumes
regenerating them with the prod.yaml up command
then restoring the backup of the production database
As this is causing downtime..

What is the correct workflow?
In the following situation. The prod env is running. But an module in that environment needs updating..

@yajo
Copy link
Contributor

yajo commented Apr 20, 2021

What is the correct workflow?

That seems like a subject you better ask in the forum.

@pleirb
Copy link

pleirb commented May 29, 2023

Thank you all here for exposing your experience regarding this issue, I spent hours trying to find out why it didn't work and thanks to your comments I was able to do it. It was because I was using the project created by copier to use as development and then intend to use as production (certainly not recommended). However, the key to switching between modes is to purge the volumes and images with:
invoke stop --purge
and then run:
docker-compose -f prod.yaml run --rm odoo --stop-after- init -i base
and then if you can do a:
docker-compose -f prod.yaml up -d
to see it work.

Remember that it is necessary to point the domain to the IP of the pc you are using, at least by editing the hosts file and placing
127.0.0.1 testdomain.com

@pleirb
Copy link

pleirb commented Aug 17, 2023

Thank you all here for exposing your experience regarding this issue, I spent hours trying to find out why it didn't work and thanks to your comments I was able to do it. It was because I was using the project created by copier to use as development and then intend to use as production (certainly not recommended). However, the key to switching between modes is to purge the volumes and images with: invoke stop --purge and then run: docker-compose -f prod.yaml run --rm odoo --stop-after- init -i base and then if you can do a: docker-compose -f prod.yaml up -d to see it work.

Remember that it is necessary to point the domain to the IP of the pc you are using, at least by editing the hosts file and placing 127.0.0.1 testdomain.com

I add another partial solution when even doing all this the error appears: "Internal Server Error"
What I have done is identify the volume associated with the database and delete it and execute the initialization command for production mode again. Maybe someone can suggest a better solution without having to delete the databases.
Unfortunately, I fall into the trap and by mistake the environments are changed, generating this myriad of problems. Ideally, the copier would ask you what environment to work in and not let you make this hard-to-recover mistake.

@pleirb
Copy link

pleirb commented Mar 25, 2024

If you are having problems using development and test/production environments on the same computer, you may be asking yourself some questions like: Why doesn't the copier ask you what type of environment you are going to work in? Should the projects be called something else?
Is it necessary to configure Traefik? Should I configure the domains when you ask me?
For greater clarity you can review:
Tecnativa/doodba-copier-template#456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants