-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: add 'worker_index' to WorkerRunner #2155
Conversation
b76118c
to
8925df2
Compare
Any idea why the |
I think the test is bad (fragile) because it assumes a msg with .data is not an ack |
Looks like a good start! Two questions: Is the lock really needed? There are no io calls so I dont see how another greenlet could start to run? Do we still need the old id:s or could this replace it? A number of places would be nicer if we used ordinal IDs instead of uuid:s (e.g. the logs) |
This needs some unit tests. |
Ok, will try to fix it.
I assumed so; but since
You mean the
Any suggestion? If we have one for ACKs then I would modify that one; and perhaps add another one for old masters (I already verified manually that new workers can connect to old masters, but a test would be best). |
cb22a86
to
85ac54e
Compare
Yes. We could do it later on but I kind of would like to do it now (rather than having two potentially breaking changes). Could be ok though.
no suggestions off hand (I’m on mobile atm). No need to validate backwards/forward compatibility, it looks reasonable. Just validate that the ID is available and incremented correctly. Check the existing tests for inspiration. |
The changes introduced in this PR are not breaking though.
Ok, I have added one; thanks! |
Sorry, I was unclear: what I meant was that the second PR would be a breaking one, as it would remove the I’d like to see it investigated at least. Doing it as a separate PR is fine if it becomes too complicated. (the important thing is really just not making a proper release before merging the second one) |
I am going to fix the tests and then add another commit which "promotes" the ordinal ID as the I will try to find the best approach to preserve this functionality. |
I have been thinking through it; I think removing the UUIDs is a bad idea because right now these are used for a sort of "weak" handshake: clients report their UUIDs and the messaging/events is based on that. I will make a commit that renames |
docs/api.rst
Outdated
@@ -133,7 +133,7 @@ Runner classes | |||
:members: register_message, send_message | |||
|
|||
.. autoclass:: locust.runners.WorkerRunner | |||
:members: register_message, send_message | |||
:members: register_message, send_message, client_uuid, worker_index |
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.
Please check whether this is desirable or not.
I see! Given that, I have changed my mind. I think it is preferable to keep client_id exactly as it is (including hostname), to promote backwards compatibility. Can you also add an "integration test" (maybe in test_main.py) that checks that is correct on that side? (maybe by printing self.runner.worker_index from inside a task). For convenience, how about adding worker_index to LocalRunner and just making it zero? |
MasterRunner.client_ordinals should probably be renamed worker_indexes instead (just to keep it consistent) |
55965d5
to
316d1ff
Compare
If there can never be more than 1 I have applied the other changes as well. Do the integration tests run as part of the CI? Edit: rebased on latest |
Master will provide on ACK an ordinal identifier to each connected worker; these are deterministic (same id for same client id) and guaranteed to not change as far as the Master is alive. LocalRunner has its worker_index always set to 0.
It looks really good now. Can you adjust test_worker_indexes so that it actually launches two workers? |
b835f92
to
b87ec00
Compare
@cyberw I have added another worker, but there was no other test using 2 workers so now I am incurring into some weird issue. Any idea why the master is returning a non-zero exit code? |
No particular ideas, but do a
first, and you might get a clearer message |
I think I fixed the test. Will merge once build clears... |
Meh. Build doesnt appear to care about my commit. I'll merge and fix it here (upstream) if necessary. |
I didn't have time today, I see you found the mistake. Thank you! |
I have do this in my project.and it is some different def release_index(self, index): |
Master will provide on ACK an ordinal identifier for each connected worker; these are deterministic (same id for same client_id).
This implementation is backward-compatible for older master nodes that do not provide the
index
in message payload for ACKs.Fixes #1601
I have attempted to change the documentation to automatically cover this field, please advise if there are better ways.
Thanks!