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

[14.0] edi_endpoint: cross worker fix #731

Merged
merged 2 commits into from
May 17, 2023

Conversation

simahawk
Copy link
Contributor

@simahawk simahawk commented Mar 1, 2023

Replaces #633

Former version of endpoint_route_handler had a major flaw:

routing rule registry was not properly shared across workers
forcing us to restart the instance to make sure all envs were inline w/ it.

This change adapts edi_endpoint_oca to the new version which contains
some refactoring.

Depends on:

@simahawk simahawk force-pushed the 14-endpoint-handler-cross-worker branch from 0d7cc81 to f22b493 Compare March 1, 2023 11:35
@simahawk simahawk force-pushed the 14-endpoint-handler-cross-worker branch 2 times, most recently from 909e2cc to 92c9606 Compare April 21, 2023 08:45
@simahawk simahawk force-pushed the 14-endpoint-handler-cross-worker branch from 1b05771 to 7225ab9 Compare May 11, 2023 16:35
@simahawk
Copy link
Contributor Author

I don't really understand WTF is going on here. I'll try to explain here (also to talk to my GH rubber duck 😁 ).
On HttpCase tests that run on github the mixins are not loaded properly. Works smoothly on local tests or real instance.
Here's the hierarchy:

  • edi.endpoint intherits from endpoint.mixin
  • endpoint.mixin intherits from endpoint.route.handler
  • endpoint.route.handler inherits from endpoint.route.sync.mixin

The error:

 2023-05-12 07:53:20,861 1792 ERROR odoo unittest.suite: ERROR: setUpClass (odoo.addons.edi_endpoint_oca.tests.test_edi_endpoint_controller.EDIEndpointHttpCase)
Traceback (most recent call last):
  File "/opt/odoo/odoo/tests/common.py", line 173, in _handleClassSetUp
    setUpClass()
  File "/__w/edi/edi/edi_endpoint_oca/tests/test_edi_endpoint_controller.py", line 23, in setUpClass
    cls.env["edi.endpoint"].search([])._handle_registry_sync()
AttributeError: 'edi.endpoint' object has no attribute '_handle_registry_sync'

_handle_registry_sync is a method of endpoint.route.sync.mixin so it should available on all inheriting models (edi.endpoint in this case).

It's like the model is not fully registered in the registry at that point.

Right now I added [a dummy test](test sync on GH) to call that method in a normal SavepointCase test

@simahawk
Copy link
Contributor Author

Right now I added [a dummy test](test sync on GH) to call that method in a normal SavepointCase test

Ok. it fails on SavepointCase too... at least some consistency... 😄

@simahawk
Copy link
Contributor Author

Ok, I can't believe it... now it passes 🤔

@simahawk simahawk force-pushed the 14-endpoint-handler-cross-worker branch from bd0eb11 to 3c80c9a Compare May 15, 2023 14:19
@simahawk
Copy link
Contributor Author

Ok, I can't believe it... now it passes thinking

I think I've found the reason: declaring again the dependency on the sync mixin messed up the inheritance.
No clue why only on GH and not locally 🤷

simahawk added 2 commits May 16, 2023 14:56
Former version of `endpoint_route_handler` had a major flaw:

routing rule registry was not properly shared across workers
forcing us to restart the instance to make sure all envs were inline w/
it.

This change adapts edi_endpoint_oca to the new version which contains
some refactoring.
@simahawk simahawk force-pushed the 14-endpoint-handler-cross-worker branch from 3c80c9a to 49f21dc Compare May 16, 2023 12:56
@simahawk
Copy link
Contributor Author

As the main PR has been merged this is required now to make edi_endpoint work. I tested everything again and it works smoothly on my side. I merge here but if anyone spots something wrong/weird just ping me :)

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 14.0-ocabot-merge-pr-731-by-simahawk-bump-nobump, awaiting test results.

@@ -18,7 +13,7 @@ class EDIEndpoint(models.Model):
"""

_name = "edi.endpoint"
_inherit = "endpoint.mixin"
_inherit = ["endpoint.mixin"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Your test issue was coming from there? Should it deserves a comment explaining this, someone that will migrate this later could remove these square brackets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no no, this is a left over / non necessary change. I added the sync mixin here 1st then I removed it ;)

@OCA-git-bot OCA-git-bot merged commit bd7d7f7 into OCA:14.0 May 17, 2023
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at b522ce3. 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.

3 participants