-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix worker IP update to use one single DB session #858
Conversation
bc3391d
to
ff11212
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this implementation neither.
First refreshable_constant
does noting. It simply returns what is passed. This is confusing and should be avoided.
You may want to look at functools.partial I think.
Next is this faux-dynamic refresh of environ. It's not possible to change the environment of a running process so this brings additional confusion and only works in your tests because pytest fires processes.
Testing should mostly adapt to codebase or require refactoring but here it's a detrimental change of codebase to accomodate tests.
Another thing is I think we wont write the IP to the DB should the policy update fail (it's possible, it's a remote call). Are we OK with this? Maybe a comment would be helpful.
dispatcher/backend/src/tests/integration/routes/workers/test_worker.py
Outdated
Show resolved
Hide resolved
dispatcher/backend/src/tests/integration/routes/workers/test_worker.py
Outdated
Show resolved
Hide resolved
I honestly don't know how to fix code to match your expectations. As stated, existing code architecture prevented me to find a clean and simple way to run tests. And I didn't knew about the impossibility to update a process environment, my bad. The only solution I see to move forward would be to delete the tests, since it looks they are detrimental to code quality. It makes me very sad because I really prefer working and tested code to clean code. But that's life and I don't have time to refactor the Zimfarm codebase, at least I'm not supposed to do it as far as I've understood. I agree about the fact that we wont write the IP to the DB should the policy update fail. Was already the case before, still the case now. Rather than a comment, I think we should try/catch the remote IP update to ensure data is persisted or commit the transaction before making the remote IP update. Feel free to take over this PR and finish the work if it is simpler. |
Can you describe the problem/issue? Maybe we can think of a better way to solve it |
This is my issue (only for one test):
|
Any idea about how to move this forward? |
#863 should probably be tackled at the same time |
ff11212
to
45b05ee
Compare
I almost completely rewrote the tests + added a short-term fix to persist IP changes asap in DB, before we can tackle #863 which is indeed not straightforward) Changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like my two comments from previous revision to be addressed ; either in discussion or in code.
a638fc2
to
ddead22
Compare
5f0dc29
to
2ddee9b
Compare
I rebased the commits on latest I fixed the last comment which wasn't yet fixed, the code was dead indeed, I just forgot to remove it from the tests ... my bad, sorry again. AFAIK the other comment has already been fixed, I hope I'm not mistaken. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Rationale
Fix #857
Changes (original ones, see below for updated list)
USES_WORKERS_IPS_WHITELIST
dynamically so that it can be manipulated in testsRemarks
USES_WORKERS_IPS_WHITELIST
but this is the less intrusive change I found to keep this inconstants.py
since this file is useful to have the list of available environment variablesIpUpdater
class ; this should not be done like this, we should have a cleaner code architecture + use a mocking library, but again, this is not a small change