Skip to content

Conversation

@nguyenminhchien
Copy link
Contributor

@nguyenminhchien nguyenminhchien commented Jan 2, 2024

Ref: BSRD-746

simahawk and others added 30 commits December 27, 2023 14:58
When an endpoint is archived it must be dropped.
When it's unarchive it must be restored.
Routing maps are generated **per env**
which means that every new env will have its own routing map
attached to `ir.http` registry class.

This is not desired (as per core Odoo comment)
but it's like this today :/

Hence, before this change, the routing map could be mis-aligned
across different envs leading to random responses for custom endpoints.

This refactoring simplifies a lot the handling of the rules
leaving to std `_generate_routing_rules` the duty to yield rules
and to `routing_map` to generate them for the new route map.

EndpointRegistry memory consumption is improved too
thanks to smaller data to store and to the usage of __slots__.
To avoid multiple invalidation of all envs on each edit or create
of persistent records, a new flag is introduced: 'registry_sync'.

This flag delays the sync of the rule registry till manual action
occurs. Records in the UI are decorated accordingly to notify users of
the need to reflect changes on ther registry to make them effective.

The sync happens in a post commit hook to ensure all values are in place
for the affected records.
Depending on your modules inheritance and upgrade order
when you introduce this mixin on an existing model
it might happen that
gets called before the model's table is ready
(eg: another odoo service loading the env before the upgrade happens).
Let if fail gracefully since the hook will be called again later.
As routes are registered automatically in the db after sync
there's no reason to look for non registered routes at boot.
Furthermore, this is causing access conflicts on the table
when multiple instances w/ multiple workers are spawned.
@nguyenminhchien nguyenminhchien marked this pull request as ready for review January 2, 2024 07:56
@nguyenminhchien nguyenminhchien mentioned this pull request Jan 2, 2024
4 tasks
@nguyenminhchien nguyenminhchien changed the title [17.0][MIG[ endpoint_route_handler: Migration to 17.0 [17.0][MIG] endpoint_route_handler: Migration to 17.0 Jan 4, 2024
@gurneyalex gurneyalex requested a review from simahawk January 5, 2024 17:15
@gurneyalex
Copy link
Member

/ocabot merge endpoint_route_handler

@OCA-git-bot
Copy link
Contributor

Hi @gurneyalex. Your command failed:

Invalid options for command merge: endpoint_route_handler.

Ocabot commands

  • ocabot merge major|minor|patch|nobump
  • ocabot rebase
  • ocabot migration {MODULE_NAME}

More information

Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some things that could be cleaned up in the roadmap but no blocking points

@simahawk
Copy link
Contributor

simahawk commented Jan 8, 2024

/ocabot migration endpoint_route_handler

@OCA-git-bot OCA-git-bot added this to the 17.0 milestone Jan 8, 2024
@simahawk
Copy link
Contributor

simahawk commented Jan 8, 2024

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 17.0-ocabot-merge-pr-31-by-simahawk-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit c577463 into OCA:17.0 Jan 8, 2024
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 7905e44. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants