Repository navigation
20.0 mig session_redis - #538
Merged
Merged
Conversation
The default expiration of sessions is 7 days. With healthchecks run every few seconds, we quickly have millions of anonymous sessions in Redis. Allow to define a custom expiration for some sessions and set a very short one for the monitoring requests.
In several places, odoo sets a datetime object directly in the session. It works with the default session handler of odoo which uses pickle. But datetime and date are not json serializable by default. Add custom encoder / decoder to handle them (from https://github.com/OCA/queue/blob/dc12a6a20ecfd15c5b90f9b089c9a64cf9d8bbe4/queue_job/fields.py#L57-L99) See the discussion raised by @PCatinean on #176
The main goal is to be able to easily do grep and sed when we do mass update on them
Co-authored-by: Hugo Santos <hugo.santos@factorlibre.com>
Use copier template from oca/oca-addons-repo-template Apply linting
`Session.vacuum` method contains extra arguments since this PR odoo/odoo#122888 accept parameters to adapter this change
``session_redis`` is not compatible with ``auth_session_timeout``. ``session_redis`` overrides property ``odoo.http.Application.session_store`` by returning a ``RedisSessionStore`` object instead of a ``odoo.http.FilesystemSessionStore`` object. ``auth_session_timeout`` expects ``odoo.http.Application.session_store`` object to define method ``get_session_filename()``, which does not exist for ``RedisSessionStore`` objects. This results in an ``AttributeError`` that prevents user authentication, and Odoo becomes inaccessible.
* lazy_property is deprecated * Since odoo/odoo@cea66be, Session must be used as a dictionary when setting custom values * Session default lifetime is now defined in odoo.http, so we can just reuse that * Handle new session rotation logic (sessions must be findable by the first 42 chars of they key) * Handle new session key generation for rotation (keys must be longer than 42 chars to handle devices)
…ot an integer or is zero.
Co-authored-by: Florent Xicluna <142113+florentx@users.noreply.github.com>
On the cloud platform of Camptocamp, a shared redis is used to store the sessions of the different projects -> the number of keys is huge, and using an iterative match kills the performance because of the networking overhead. We switch to using redis.key(pattern), and since the pattern typically has a leading string which will allow redis to find the correct bucket, the performance should be good.
- odoo.http is now a package: the session store is the odoo.http.session.SessionStore class, instantiated by the cached odoo.http.session.session_store() factory which is imported by name everywhere. Replace the class it instantiates and clear its cache instead of patching the removed Application.session_store. - RedisSessionStore inherits from the new core SessionStore (generate_key, is_valid_session_id, new and rotate are reused) and follows its API (session_cls, get(sid, keep_sid=...)). - Fix the key pattern of get_missing_session_identifiers, which never matched and reported every device session as revoked. - Ignore malformed identifiers in delete_from_identifiers like core. - ruff fixes: ValueError for the configuration error, str env defaults.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BSTOOLS-29