server-tools icon indicating copy to clipboard operation
server-tools copied to clipboard

[FIX] sentry: update sentry_sdk, variable names + add support for session_redis

Open yhaelopez opened this issue 2 years ago • 12 comments

  • This PR fixes 2 variables that were renamed in major upgrades of sentry_sdk. with_locals => include_local_variables request_bodies => max_request_body_size

  • We use session_redis from https://github.com/camptocamp/odoo-cloud-platform, so I added support for it, it keeps retro-compatibility, so it feels seamlessly whether you use session_redis or not.

yhaelopez avatar Oct 10 '23 02:10 yhaelopez

Hi @naglis, @barsi, @fernandahf, @versada, @moylop260, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar Oct 10 '23 02:10 OCA-git-bot

Hi @yhaelopez

When testing this proposal in odoo 16.0 I get the following message:

More details here: https://github.com/OCA/server-tools/pull/2650

cc @moylop260

2023-10-10 16:33:42,802 351 INFO odoo odoo.modules.loading: Loading module sentry (4/226) 
2023-10-10 16:33:42,918 351 INFO odoo odoo.addons.sentry.hooks: Initializing sentry... 
2023-10-10 16:33:42,918 351 CRITICAL odoo odoo.modules.module: Couldn't load module sentry 
2023-10-10 16:33:42,918 351 CRITICAL odoo odoo.modules.module: 'include_local_variables' 
2023-10-10 16:33:42,925 351 WARNING odoo odoo.modules.loading: Transient module states were reset 
2023-10-10 16:33:42,925 351 ERROR odoo odoo.modules.registry: Failed to load registry 
Traceback (most recent call last):
  File "/home/odoo/instance/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 488, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 188, in load_module_graph
    load_openerp_module(package.name)
  File "/home/odoo/instance/odoo/odoo/modules/module.py", line 475, in load_openerp_module
    getattr(sys.modules['odoo.addons.' + module_name], info['post_load'])()
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 155, in post_load
    initialize_sentry(odoo_config)
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 101, in initialize_sentry
    for option in const.get_sentry_options():
  File "/home/odoo/instance/extra_addons/server-tools/sentry/const.py", line 81, in get_sentry_options
    "include_local_variables", DEFAULT_OPTIONS["include_local_variables"], None
KeyError: 'include_local_variables'
2023-10-10 16:33:42,925 351 CRITICAL odoo odoo.service.server: Failed to initialize database `odoo`. 
Traceback (most recent call last):
  File "/home/odoo/instance/odoo/odoo/service/server.py", line 1299, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/home/odoo/instance/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/home/odoo/instance/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 488, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 188, in load_module_graph
    load_openerp_module(package.name)
  File "/home/odoo/instance/odoo/odoo/modules/module.py", line 475, in load_openerp_module
    getattr(sys.modules['odoo.addons.' + module_name], info['post_load'])()
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 155, in post_load
    initialize_sentry(odoo_config)
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 101, in initialize_sentry
    for option in const.get_sentry_options():
  File "/home/odoo/instance/extra_addons/server-tools/sentry/const.py", line 81, in get_sentry_options
    "include_local_variables", DEFAULT_OPTIONS["include_local_variables"], None
KeyError: 'include_local_variables'
2023-10-10 16:33:42,926 351 INFO odoo odoo.service.server: Initiating shutdown 
2023-10-10 16:33:42,926 351 INFO odoo odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown. 
2023-10-10 16:33:43,284 351 INFO odoo odoo.sql_db: ConnectionPool(used=0/count=0/max=64): Closed 2 connections

deivislaya avatar Oct 10 '23 16:10 deivislaya

Hi @yhaelopez

When testing this proposal in odoo 16.0 I get the following message:

More details here: #2650

cc @moylop260

2023-10-10 16:33:42,802 351 INFO odoo odoo.modules.loading: Loading module sentry (4/226) 
2023-10-10 16:33:42,918 351 INFO odoo odoo.addons.sentry.hooks: Initializing sentry... 
2023-10-10 16:33:42,918 351 CRITICAL odoo odoo.modules.module: Couldn't load module sentry 
2023-10-10 16:33:42,918 351 CRITICAL odoo odoo.modules.module: 'include_local_variables' 
2023-10-10 16:33:42,925 351 WARNING odoo odoo.modules.loading: Transient module states were reset 
2023-10-10 16:33:42,925 351 ERROR odoo odoo.modules.registry: Failed to load registry 
Traceback (most recent call last):
  File "/home/odoo/instance/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 488, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 188, in load_module_graph
    load_openerp_module(package.name)
  File "/home/odoo/instance/odoo/odoo/modules/module.py", line 475, in load_openerp_module
    getattr(sys.modules['odoo.addons.' + module_name], info['post_load'])()
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 155, in post_load
    initialize_sentry(odoo_config)
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 101, in initialize_sentry
    for option in const.get_sentry_options():
  File "/home/odoo/instance/extra_addons/server-tools/sentry/const.py", line 81, in get_sentry_options
    "include_local_variables", DEFAULT_OPTIONS["include_local_variables"], None
KeyError: 'include_local_variables'
2023-10-10 16:33:42,925 351 CRITICAL odoo odoo.service.server: Failed to initialize database `odoo`. 
Traceback (most recent call last):
  File "/home/odoo/instance/odoo/odoo/service/server.py", line 1299, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/home/odoo/instance/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/home/odoo/instance/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 488, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/odoo/instance/odoo/odoo/modules/loading.py", line 188, in load_module_graph
    load_openerp_module(package.name)
  File "/home/odoo/instance/odoo/odoo/modules/module.py", line 475, in load_openerp_module
    getattr(sys.modules['odoo.addons.' + module_name], info['post_load'])()
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 155, in post_load
    initialize_sentry(odoo_config)
  File "/home/odoo/instance/extra_addons/server-tools/sentry/hooks.py", line 101, in initialize_sentry
    for option in const.get_sentry_options():
  File "/home/odoo/instance/extra_addons/server-tools/sentry/const.py", line 81, in get_sentry_options
    "include_local_variables", DEFAULT_OPTIONS["include_local_variables"], None
KeyError: 'include_local_variables'
2023-10-10 16:33:42,926 351 INFO odoo odoo.service.server: Initiating shutdown 
2023-10-10 16:33:42,926 351 INFO odoo odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown. 
2023-10-10 16:33:43,284 351 INFO odoo odoo.sql_db: ConnectionPool(used=0/count=0/max=64): Closed 2 connections

@deivislaya

Which version of sentry_sdk are you using? I'm using the latest with Odoo 16.0 from Docker Hub (which is: https://github.com/odoo/docker + https://hub.docker.com/_/odoo/) and it gets official upgrades every week at least once (here I'm not having any issues with versions of urllib3).

The issue you mentioned here: https://github.com/OCA/server-tools/pull/2650 is no longer a thing, as long as you update your packages.

I highly suggest you to see how we are implementing some modules this and other packages here:

https://github.com/odoocker/odoocker/tree/develop

Specially: https://github.com/odoocker/odoocker/blob/develop/odoo/third-party-addons.sh

yhaelopez avatar Oct 10 '23 16:10 yhaelopez

@yhaelopez

It is sentry-sdk == 1.9.0 version
https://github.com/getsentry/sentry-python/blob/1cf1bbb4eeb8dad70cab72eebba6f78f0eb3fc0b/setup.py#L40

That satisfies the odoo requirement with the library urllib3 == 1.26.5 https://github.com/odoo/odoo/blob/e0feda462961ae612cacc36d1a75d56c5594fd22/requirements.txt#L56

sentry-sdk > 1.9.0 required urllib3 >= 1.26.11 https://github.com/getsentry/sentry-python/blob/4f1f782fbedc9adcf1dfcd2092bb328443f09e8c/setup.py#L43

deivislaya avatar Oct 10 '23 19:10 deivislaya

@deivislaya

Is Odoo=16.0 compatible with urllib3 >= 1.26.11?

Is sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

moylop260 avatar Oct 10 '23 20:10 moylop260

@deivislaya

Is Odoo=16.0 compatible with urllib3 >= 1.26.11?

Is sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

@deivislaya @moylop260

This is my current working setup:

image

yhaelopez avatar Oct 10 '23 21:10 yhaelopez

@moylop260 @yhaelopez

@deivislaya

Is Odoo=16.0 compatible with urllib3 >= 1.26.11?

Is sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

Is Odoo=16.0 compatible with urllib3 >= 1.26.11?

yes, is compatible with version urllib3 >= 1.26.11

Is sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

No, is incompatible sentry-sdk>=1.9.1 requires urllib3>=1.26.11

However:

With this configuration, I started odoo without any problems with the proposal of this PR:

Screenshot-from-2023-10-10-16-21-02

deivislaya avatar Oct 10 '23 22:10 deivislaya

@moylop260 @yhaelopez

@deivislaya Is Odoo=16.0 compatible with urllib3 >= 1.26.11? Is sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

Is Odoo=16.0 compatible with urllib3 >= 1.26.11?

yes, is compatible with version urllib3 >= 1.26.11

Is sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

No, is incompatible sentry-sdk>=1.9.1 requires urllib3>=1.26.11

However:

With this configuration, I started odoo without any problems with the proposal of this PR:

Screenshot-from-2023-10-10-16-21-02

@deivislaya @moylop260

You're right, I didn't consider: sentry-sdk>1.9.0 compatible with urllib3 == 1.26.5?

But, you are now using it with the latest sentry_sdk = 1.31.0 and I am running it with urllib3 = 1.26.17 without any issues. You tested with urllib3 = 1.26.11 I think the issue of urllib3 is just gone.

I also dug into sentry_sdk https://github.com/getsentry/sentry-python and couldn't find any reference to urllib3>=1.26.11 or urllib3=1.26.17 (in my case) that conflicts or requires it.

If everything is correct, I can post PRs for older versions (14 and 15).

yhaelopez avatar Oct 11 '23 02:10 yhaelopez

Please, don't merge this yet. I found a strange behavior with the Redis package, I'm on it.

yhaelopez avatar Oct 18 '23 01:10 yhaelopez

Please resolve conflicts, squash commits into the two feature commits (I would prefer separate PRs myself to be honest) and apply the conventional commit names, e.g. [IMP] sentry: compatibility with sentry_sdk > 1.9.0 . (see https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#71commit-message)

StefanRijnhart avatar Dec 01 '23 13:12 StefanRijnhart

Is it not possible to move the session_redis part to another module? This feels weird to have hack her to support something that is not even in OCA.

sbidoul avatar Jan 09 '24 18:01 sbidoul

@yhaelopez if it is interesting, I made a fix into our forked 17.0 migration branch of session_redis for this: https://github.com/avoinsystems/odoo-cloud-platform/commit/a09a8136d5e79a4f00b7a5645e87e677ada4ed1e

aisopuro avatar Mar 22 '24 08:03 aisopuro