)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"1515df308c06532086f2a66ec7806e13b5cd584a","unresolved":false,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"\"keepalived_state_change\" needs to use threading to send arping"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"df33271e_3a42f1ab","line":9,"range":{"start_line":9,"start_character":33,"end_line":9,"end_character":55},"updated":"2020-04-02 13:37:16.000000000","message":"Monitor imports module which uses eventlet. Can you please clarify what means \"monitor does not use eventlet\"? I\u0027m a bit confused. What needs to be done to enable monitor to use it?","commit_id":"9d1d7661734a6296975981e379097432af46adbf"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"fe2a715fd44016198220893120d48435321846a3","unresolved":false,"context_lines":[{"line_number":6,"context_line":""},{"line_number":7,"context_line":"\"keepalived_state_change\" needs to use threading to send arping"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":1,"id":"df33271e_4e51f635","line":9,"range":{"start_line":9,"start_character":33,"end_line":9,"end_character":55},"in_reply_to":"df33271e_3a42f1ab","updated":"2020-04-02 14:13:53.000000000","message":"\"keepalived_state_change\" is an independent process spawned by the L3 agent. This process uses threading instead of eventlet because:\n- The number of threads created is very small\n- We don\u0027t need to deal with the problem of thread starvation if the thread explicitly do not release the GIL. We just rely on the Python thread preemption to swap between them.","commit_id":"9d1d7661734a6296975981e379097432af46adbf"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"9b4ba10bd7b2ff2565488b53554c80c0583c974a","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_c7704975","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"updated":"2020-04-02 15:35:23.000000000","message":"Not sure I understand why this is not working.\n\"Eventlet is thread-safe and can be used in conjunction with normal Python threads\" - https://eventlet.net/doc/threading.html","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"6af11e8271469c8510479db2b5aa44d1f46fa31c","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_b0ca866b","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_7570f0dd","updated":"2020-04-03 15:31:49.000000000","message":"Always a pleasure.","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"74c4dce33f554e2ddcb3d63024473fb5ecc88a47","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_7570f0dd","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_a1451e18","updated":"2020-04-03 15:11:03.000000000","message":"Fair enough, thanks for detailed answer! Sorry for bothering you so much, just wanted to get to the root of this eventlet issue, as you said it might not be the only place where it happens..","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"735df73f8a47841df393f73b4bd48ebbff766f0f","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_a1451e18","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_c6b83912","updated":"2020-04-03 12:49:25.000000000","message":"Could be another option but I never tested it. Because of how the monitor is implemented, I prefer threading rather than eventlets. The cost of using threading is minimal for one single short thread (arping is executed 3 times, that means more or less 3 seconds).","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"a59900b64970b7d127928e04cc9b3923a636432a","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_d52745c6","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_c7704975","updated":"2020-04-03 09:03:28.000000000","message":"For sure, evenlet can be used with threads.\n\nThe problem we have here is that, when the eventlet thread is created [1], remains halted until the eventlet \"main\" thread (there is no such concept, this is the caller thread only) returns the GIL and the eventlet executor starts running it.\n\nBut this never happens because the main thread never returns the GIL, for example, by calling eventlet.sleep. You can see that executing the modified functional test locally and changing the log file to a static one, for example \"/tmp/log_arping\". Tail this file while executing the test case and change the execution mode (eventlet or threads). You\u0027ll see in the second case how the arping is sent and logged in the file.\n\neventlets are very useful but very \"frail\" if the code implementation is not correct. Seeing this problem I\u0027m wondering if this problem is happening in other sections of the code.\n\n[1]https://github.com/openstack/neutron/blob/b56815113dbf60671ce8eefdd329230b393a8652/neutron/agent/linux/ip_lib.py#L1070","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"735df73f8a47841df393f73b4bd48ebbff766f0f","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_413532a8","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_cb7962c5","updated":"2020-04-03 12:49:25.000000000","message":"\"keepalived_state_change\" has two blocking threads running in \"parallel\": the one monitoring any IP change and the other one reading the queue populated by the monitor.\n\nThe first one uses a blocking method from Pyroute:\n\n_ip \u003d privileged.get_iproute(namespace\n_ip.bind(async_cache\u003dTrue)\n_ip.get() \u003c-- this method does not return until there is a change\n\nBecause of this, we can\u0027t use eventlets in \"keepalived_state_change\", because when this thread never releases the GIL.\n\nWe need to have this _ip.get() in an endless loop because any event happened outside the execution of this method is skipped (we can miss an IP change).\n\nThat means the second thread in the monitor, the one reading the IP addresses stored in the queue by the first thread, needs somehow to be executed apart from the first one. That\u0027s why I implemented the \"keepalived_state_change\" using threading instead of eventlets, because Python threads are preemptive and will allow the second thread to be executed. Because the second thread is most of the time idle, it will return quickly the GIL to the first one.","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"3089fab5342645fd3ef5c4252957e483f8c35553","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_c6b83912","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_cb7962c5","updated":"2020-04-03 10:53:41.000000000","message":"And probably doing sleep(0) after spawning the greenthread :)","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"941fad90c4aa24b01ba62021a5fd089dce7249cb","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"\"keepalived_state_change\" monitor does not use eventlet but normal"},{"line_number":10,"context_line":"Python threads. When \"send_ip_addr_adv_notif\" is called from inside"},{"line_number":11,"context_line":"the monitor, the arping command is never sent because the eventlet"},{"line_number":12,"context_line":"thread does not start. In order to be able to be called from this"},{"line_number":13,"context_line":"process, this method should also have an alternative implementation"},{"line_number":14,"context_line":"using \"threading\"."},{"line_number":15,"context_line":""}],"source_content_type":"text/x-gerrit-commit-message","patch_set":2,"id":"df33271e_cb7962c5","line":12,"range":{"start_line":11,"start_character":46,"end_line":12,"end_character":21},"in_reply_to":"df33271e_d52745c6","updated":"2020-04-03 10:36:54.000000000","message":"Ah, got it, thanks very much for the clarification.\nSo another option would be to follow https://docs.openstack.org/neutron/latest/contributor/internals/services_and_agents.html#interacting-with-eventlet for state_change_monitor, right (since it\u0027s a \"service using eventlet\")?","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"}],"neutron/agent/linux/ip_lib.py":[{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"1a806d38e54f4ecad2d0912345f15f43944d78d1","unresolved":false,"context_lines":[{"line_number":1074,"context_line":"        if use_eventlet:"},{"line_number":1075,"context_line":"            eventlet.spawn_n(arping)"},{"line_number":1076,"context_line":"        else:"},{"line_number":1077,"context_line":"            thread_arping \u003d threading.Thread(target\u003darping)"},{"line_number":1078,"context_line":"            thread_arping.start()"},{"line_number":1079,"context_line":""},{"line_number":1080,"context_line":""},{"line_number":1081,"context_line":"def sysctl(cmd, namespace\u003dNone, log_fail_as_error\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":1,"id":"df33271e_1a3e0dc0","line":1078,"range":{"start_line":1077,"start_character":12,"end_line":1078,"end_character":33},"updated":"2020-04-02 13:26:39.000000000","message":"nit: why not just threading.Thread(target\u003darping).start()","commit_id":"9d1d7661734a6296975981e379097432af46adbf"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"fe2a715fd44016198220893120d48435321846a3","unresolved":false,"context_lines":[{"line_number":1074,"context_line":"        if use_eventlet:"},{"line_number":1075,"context_line":"            eventlet.spawn_n(arping)"},{"line_number":1076,"context_line":"        else:"},{"line_number":1077,"context_line":"            thread_arping \u003d threading.Thread(target\u003darping)"},{"line_number":1078,"context_line":"            thread_arping.start()"},{"line_number":1079,"context_line":""},{"line_number":1080,"context_line":""},{"line_number":1081,"context_line":"def sysctl(cmd, namespace\u003dNone, log_fail_as_error\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":1,"id":"df33271e_aeb402f3","line":1078,"range":{"start_line":1077,"start_character":12,"end_line":1078,"end_character":33},"in_reply_to":"df33271e_1a3e0dc0","updated":"2020-04-02 14:13:53.000000000","message":"right, I don\u0027t need to create this variable","commit_id":"9d1d7661734a6296975981e379097432af46adbf"}],"neutron/tests/functional/agent/l3/test_keepalived_state_change.py":[{"author":{"_account_id":22348,"name":"Zuul","username":"zuul","tags":["SERVICE_USER"]},"tag":"autogenerated:zuul:check","change_message_id":"684d674763c6e32879643d2c1c825a7f8f752045","unresolved":false,"context_lines":[{"line_number":153,"context_line":"        self._search_in_file(self.log_file, msg)"},{"line_number":154,"context_line":""},{"line_number":155,"context_line":""},{"line_number":156,"context_line":"    def test_read_queue_change_state(self):"},{"line_number":157,"context_line":"        self._run_monitor()"},{"line_number":158,"context_line":"        msg \u003d \u0027Wrote router %s state %s\u0027"},{"line_number":159,"context_line":"        self.router.port.addr.add(self.cidr)"}],"source_content_type":"text/x-python","patch_set":2,"id":"df33271e_33b7b73c","line":156,"updated":"2020-04-02 18:23:23.000000000","message":"pep8: E303 too many blank lines (2)","commit_id":"71676820d7c7ca67f6d7b8ec11d38a4aea890d01"}]}
