Tecnativa / doodba-copier-template

A Copier template for Doodba projects
Boost Software License 1.0
86 stars 114 forks source link

Permission error in addons-link #36

Closed hhgabelgaard closed 4 years ago

hhgabelgaard commented 4 years ago

First, thanks for a great project. I have previously used the doodba-scaffolding "way" with success.

On a new (and my first) copier initiated project I'm getting this error on invoke start

File "/opt/odoo/common/entrypoint.d/40-addons-link", line 17, in <module>
    os.symlink(src, dst)
PermissionError: [Errno 13] Permission denied: '../../custom/src/odoo/addons/http_routing' -> '/opt/odoo/auto/addons/http_routing'

The problem is that odoo/auto and odoo/auto/addons is owned by root Changing owner to my user account, and issuing:

chmod -R ug+rwX odoo/auto

from the old scaffolding "quick start" notes fixes this.

Should that be part of the development task?

Anyone else seeing this? Should this issue be filed under doodba-copier-template?

theangryangel commented 4 years ago

I hit the same problem in a testing setup.

I altered my setup-devel.yaml to drop the root user, which prevents this by having the directories created as my user. I'm sure there are scenarios where that's not the right fix, but with my umask, etc. set as env vars it seems appropriate

yajo commented 4 years ago

So, what's the process you followed to download git code?

Did you try using just invoke git-aggregate? Didn't it fix your issue?

@manuelcalerosolis did you experience this?

hhgabelgaard commented 4 years ago

Yes, i've downloaded the code using invoke git-aggregate via the VS code invoke task First with the default repos.yaml containing OCB and an empty addons.yaml When it then failed on invoke start I've added a single OCA repo to addons.yaml (partner-contact) and re-ran invoke git-aggregate, then invoke startwith the same error.

My host OS is ubuntu 18.04 using bash as shell docker version 19.03.08 docker-compose version 1.24.1

estudiobeta commented 4 years ago

Same problem here, using default copier answers just to check my development enviroment is ready and after running invoke git-aggregate invoke img-build --pull invoke start got same error

yajo commented 4 years ago

What's your template version and your host UID (id -u)?

theangryangel commented 4 years ago

My umask is 0022, so if the setup-devel.yaml has the user root, this results in perms u=rwx,go=rx and an auto directory owned by root. devel.yaml then runs as my UID (or 1000) and then it can't create the symlinks because it's a different user.

The only reason why I've not submitted a PR yet is because I'm not sure why it's running as root. I'm sure there's a reason... I'm not just not seeing it :)

yajo commented 4 years ago

OK I have the bug, thanks.

yajo commented 4 years ago

This will be fixed with #38, but for those of you that already had the bug, you have to fix it manually, as it requires sudo to fix and I don't want to execute root code here automatically:

sudo chown -R $USER:$(id -g) odoo/auto

Sorry, and thanks for reporting! :raised_hands:

hhgabelgaard commented 4 years ago

Hi @Yajo Thanks for the fix in #38 - And thanks again for at great project. It really makes life with Odoo easier ;-)

But I'm still getting erros on invoke start:

/usr/local/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.

  """)

doodba INFO: Waiting until postgres is listening at db...

doodba INFO: Unaccent extension installed

doodba INFO: Linking all addons from /opt/odoo/custom/src/addons.yaml in /opt/odoo/auto/addons

Traceback (most recent call last):

  File "/opt/odoo/common/entrypoint.d/40-addons-link", line 17, in <module>

    os.symlink(src, dst)

PermissionError: [Errno 13] Permission denied: '../../custom/src/odoo/addons/http_routing' -> '/opt/odoo/auto/addons/http_routing'

Traceback (most recent call last):

  File "/opt/odoo/common/entrypoint", line 32, in <module>

    subprocess.check_call(command)

  File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call

    raise CalledProcessError(retcode, cmd)

subprocess.CalledProcessError: Command '/opt/odoo/common/entrypoint.d/40-addons-link' returned non-zero exit status 1.

What I've did:

copier copy gh:Tecnativa/doodba-copier-template odoo13-devel
cd odoo13-devel/
invoke git-aggregate
invoke img-build --pull
invoke start

odoo/auto is owned by me, but odoo/auto/addonsis owned by root

Did I miss a step ? It seems to be the same as #40

estudiobeta commented 4 years ago

I have the same problem trying to build a new project with all default copier answers but pg version where I select v11, it gets solved with @Yajo ´s last answer

sudo chown -R $USER:$(id -g) odoo/auto

After giving permissions over the folder I get another new error.

Reinitialized existing Git repository in /home/estudiobeta/odoo13pg11/.git/
pre-commit installed at .git/hooks/pre-commit
The SMTP_REAL_NON_CANONICAL_DEFAULT variable is not set. Defaulting to a blank string.
Starting odoo13pg11_gravatar_proxy_1         ... done
Starting odoo13pg11_db_1                     ... done
Starting odoo13pg11_fonts_googleapis_proxy_1 ... done
Starting odoo13pg11_cdnjs_cloudflare_proxy_1 ... done
Starting odoo13pg11_wdb_1                    ... done
Starting odoo13pg11_fonts_gstatic_proxy_1    ... done
Starting odoo13pg11_smtp_1                   ... done
Starting odoo13pg11_google_proxy_1           ... done
Starting odoo13pg11_odoo_1                   ... done
Starting odoo13pg11_odoo_proxy_1             ... done
Attaching to odoo13pg11_odoo_proxy_1, odoo13pg11_odoo_1, odoo13pg11_gravatar_proxy_1, odoo13pg11_fonts_googleapis_proxy_1, odoo13pg11_cdnjs_cloudflare_proxy_1, odoo13pg11_google_proxy_1, odoo13pg11_wdb_1, odoo13pg11_smtp_1, odoo13pg11_fonts_gstatic_proxy_1, odoo13pg11_db_1
db_1                      | 2020-04-18 22:02:09.630 GMT [47] LOG:  shutting down
db_1                      | 2020-04-18 22:02:09.738 GMT [1] LOG:  database system is shut down
db_1                      |
db_1                      | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1                      |
db_1                      | 2020-04-18 22:02:32.279 GMT [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1                      | 2020-04-18 22:02:32.279 GMT [1] LOG:  listening on IPv6 address "::", port 5432
db_1                      | 2020-04-18 22:02:32.288 GMT [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1                      | 2020-04-18 22:02:32.310 GMT [20] LOG:  database system was shut down at 2020-04-18 22:02:09 GMT
db_1                      | 2020-04-18 22:02:32.334 GMT [1] LOG:  database system is ready to accept connections
fonts_gstatic_proxy_1     | INFO:root:Resolved fonts.gstatic.com to 216.58.211.35
fonts_gstatic_proxy_1     | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:216.58.211.35:80
fonts_gstatic_proxy_1     | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:216.58.211.35:443
fonts_gstatic_proxy_1     | INFO:root:Resolved fonts.gstatic.com to 216.58.209.67
fonts_gstatic_proxy_1     | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:216.58.209.67:80
fonts_gstatic_proxy_1     | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:216.58.209.67:443
fonts_googleapis_proxy_1  | INFO:root:Resolved fonts.googleapis.com to 172.217.168.170
fonts_googleapis_proxy_1  | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:172.217.168.170:80
fonts_googleapis_proxy_1  | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:172.217.168.170:443
fonts_googleapis_proxy_1  | INFO:root:Resolved fonts.googleapis.com to 172.217.17.10
fonts_googleapis_proxy_1  | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:172.217.17.10:80
fonts_googleapis_proxy_1  | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:172.217.17.10:443
google_proxy_1            | INFO:root:Resolved www.google.com to 172.217.16.228
google_proxy_1            | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:172.217.16.228:80
google_proxy_1            | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:172.217.16.228:443
google_proxy_1            | INFO:root:Resolved www.google.com to 172.217.17.4
google_proxy_1            | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:172.217.17.4:80
google_proxy_1            | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:172.217.17.4:443
cdnjs_cloudflare_proxy_1  | INFO:root:Resolved cdnjs.cloudflare.com to 104.16.132.229
cdnjs_cloudflare_proxy_1  | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:104.16.132.229:80
cdnjs_cloudflare_proxy_1  | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:104.16.132.229:443
cdnjs_cloudflare_proxy_1  | INFO:root:Resolved cdnjs.cloudflare.com to 104.16.132.229
cdnjs_cloudflare_proxy_1  | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:104.16.132.229:80
cdnjs_cloudflare_proxy_1  | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:104.16.132.229:443
gravatar_proxy_1          | INFO:root:Resolved www.gravatar.com to 192.0.73.2
gravatar_proxy_1          | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:192.0.73.2:80
gravatar_proxy_1          | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:192.0.73.2:443
gravatar_proxy_1          | INFO:root:Resolved www.gravatar.com to 192.0.73.2
gravatar_proxy_1          | INFO:root:Executing: socat tcp-listen:80,fork,reuseaddr tcp-connect:192.0.73.2:80
gravatar_proxy_1          | INFO:root:Executing: socat tcp-listen:443,fork,reuseaddr tcp-connect:192.0.73.2:443
odoo_1                    |     subprocess.check_call(command)
odoo_1                    |   File "/usr/local/lib/python3.7/subprocess.py", line 363, in check_call
odoo_1                    |     raise CalledProcessError(retcode, cmd)
odoo_1                    | subprocess.CalledProcessError: Command '/opt/odoo/common/entrypoint.d/40-addons-link' returned non-zero exit status 1.
odoo_1                    | /usr/local/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
odoo_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: Merging found configuration files in /opt/odoo/auto/odoo.conf
odoo_1                    | doodba INFO: Executing odoo --limit-memory-soft=0 --limit-time-real-cron=9999999 --limit-time-real=9999999 --workers=0 --dev=reload,qweb,werkzeug,xml
odoo_proxy_1              | INFO:root:Executing: socat tcp-listen:6899,fork,reuseaddr tcp-connect:odoo:6899
odoo_proxy_1              | INFO:root:Executing: socat tcp-listen:8069,fork,reuseaddr tcp-connect:odoo:8069
odoo_proxy_1              | INFO:root:Executing: socat tcp-listen:6899,fork,reuseaddr tcp-connect:odoo:6899
odoo_proxy_1              | INFO:root:Executing: socat tcp-listen:8069,fork,reuseaddr tcp-connect:odoo:8069
smtp_1                    | 2020/04/18 22:01:47 Serving under http://0.0.0.0:8025/
smtp_1                    | [HTTP] Binding to address: 0.0.0.0:8025
smtp_1                    | Creating API v1 with WebPath:
smtp_1                    | Creating API v2 with WebPath:
smtp_1                    | 2020/04/18 22:02:33 Using in-memory storage
smtp_1                    | 2020/04/18 22:02:33 [SMTP] Binding to address: 0.0.0.0:1025
smtp_1                    | 2020/04/18 22:02:33 Serving under http://0.0.0.0:8025/
smtp_1                    | [HTTP] Binding to address: 0.0.0.0:8025
smtp_1                    | Creating API v1 with WebPath:
smtp_1                    | Creating API v2 with WebPath:
odoo_1                    | /usr/local/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
odoo_1                    |   """)
odoo_1                    | /usr/local/lib/python3.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.25.8) or chardet (3.0.4) doesn't match a supported version!
odoo_1                    |   RequestsDependencyWarning)
odoo_1                    | 2020-04-18 22:02:36,454 1 INFO ? odoo: Odoo version 13.0
odoo_1                    | 2020-04-18 22:02:36,454 1 INFO ? odoo: Using configuration file at /opt/odoo/auto/odoo.conf
odoo_1                    | 2020-04-18 22:02:36,454 1 INFO ? odoo: addons paths: ['/opt/odoo/custom/src/odoo/odoo/addons', '/var/lib/odoo/addons/13.0', '/opt/odoo/auto/addons']
odoo_1                    | 2020-04-18 22:02:36,455 1 INFO ? odoo: database: odoo@db:5432
odoo_1                    | 2020-04-18 22:02:36,862 1 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
odoo_1                    | 2020-04-18 22:02:37,170 1 INFO ? odoo.service.server: Watching addons folder /opt/odoo/custom/src/odoo/odoo/addons
odoo_1                    | 2020-04-18 22:02:37,170 1 INFO ? odoo.service.server: Watching addons folder /var/lib/odoo/addons/13.0
odoo_1                    | 2020-04-18 22:02:37,170 1 INFO ? odoo.service.server: Watching addons folder /opt/odoo/auto/addons
odoo_1                    | 2020-04-18 22:02:37,182 1 INFO ? odoo.service.server: AutoReload watcher running with watchdog
odoo_1                    | 2020-04-18 22:02:37,183 1 INFO ? odoo.service.server: HTTP service (werkzeug) running on 442906f472b4:8069
odoo_1                    | 2020-04-18 22:02:37,197 1 ERROR ? odoo.modules.loading: Database devel not initialized, you can force it with `-i base`
smtp_1                    | [APIv1] KEEPALIVE /api/v1/events
db_1                      | 2020-04-18 22:03:37.266 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:03:37.266 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
db_1                      | 2020-04-18 22:03:38.266 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:03:38.266 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
smtp_1                    | [APIv1] KEEPALIVE /api/v1/events
db_1                      | 2020-04-18 22:04:37.317 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:04:37.317 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
db_1                      | 2020-04-18 22:04:39.330 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:04:39.330 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
smtp_1                    | [APIv1] KEEPALIVE /api/v1/events
db_1                      | 2020-04-18 22:05:37.382 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:05:37.382 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
db_1                      | 2020-04-18 22:05:40.394 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:05:40.394 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
smtp_1                    | [APIv1] KEEPALIVE /api/v1/events
db_1                      | 2020-04-18 22:06:37.447 GMT [30] ERROR:  relation "ir_module_module" does not exist at character 28
db_1                      | 2020-04-18 22:06:37.447 GMT [30] STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'

On localhost:13069 I get this:


  File "/opt/odoo/custom/src/odoo/odoo/service/wsgi_server.py", line 142, in application
    return application_unproxied(environ, start_response)
  File "/opt/odoo/custom/src/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
    result = odoo.http.root(environ, start_response)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1287, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1257, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/local/lib/python3.7/site-packages/werkzeug/wsgi.py", line 766, in __call__
    return self.app(environ, start_response)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1441, in dispatch
    ir_http = request.registry['ir.http']
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 177, in __getitem__
    return self.models[model_name]
KeyError: 'ir.http'```
yajo commented 4 years ago

:man_facepalming: sorry wrong fix...

yajo commented 4 years ago

OK, #41 should be the definitive fix, to be released in v1.5.3 once it's merged.

In the mean time, please apply the workaround if your project was already hit by this problem: https://github.com/Tecnativa/doodba-copier-template/issues/36#issuecomment-615191432

hhgabelgaard commented 4 years ago

Thanks @Yajo

With #41 the ownership of odoo/auto seems right and the addons is symlinked

But it can't start: The devel database is created, but not initialized

Updating base fixes this:

docker-compose run --rm odoo -u base -d devel --stop-after-init

Did I expect too much here? This is with Odoo 13 Or did something go wrong? The admin users password turns out to be the default, and not the one I've entered to copier. odoo.conf in the container contaisn the default 'admin' password ./docker/odoo.env contains the right one (The one I've entered)