)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":1131,"name":"Brian Haley","email":"haleyb.dev@gmail.com","username":"brian-haley"},"change_message_id":"3fa79439f9171c0d372fe048f296126c82a78899","unresolved":false,"context_lines":[{"line_number":10,"context_line":"as a result of duplicate start for PerodicWorker."},{"line_number":11,"context_line":""},{"line_number":12,"context_line":"Change-Id: Ic462af66e77892b9ddce3d7828df144b9d9a1376"},{"line_number":13,"context_line":"Close-bug: #1809823"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":11,"id":"9fdfeff1_2eefe7b1","line":13,"range":{"start_line":13,"start_character":0,"end_line":13,"end_character":5},"updated":"2019-02-25 14:20:34.000000000","message":"s/Closes","commit_id":"be180c6e131610ad2773b6c33d1b0f1db854a6a0"}],"neutron/service.py":[{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"e3973a9ba617b7f1dbf67c7cd292ae2270971559","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_551c4ec0","line":221,"updated":"2019-02-11 08:48:09.000000000","message":"sorry but I don\u0027t understand a bit: why wait() instead of reset() needs to be called here?","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":27288,"name":"Ahmed Zaid","email":"ahmed.zaid.ext@nokia.com","username":"ZaidA"},"change_message_id":"c37eca36a1440d478cd2156f4e99bd7cf723462f","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_b57ac8b7","line":221,"in_reply_to":"9fdfeff1_12e40ae0","updated":"2019-02-18 16:57:13.000000000","message":"Yes we can go with this change by making PeriodicWorker safe to repetitive calls, but this does not mean repetitive actions  is right in AllServiceNeutronNetwork class. My suggestion  is to have both fixes, making PeriodicWorker safe to repetitive calls and avoid this in AllServiceNeutronNetwork class.","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"754c5d6b14be806b6f4912c4fcdfc1ca091b6d7a","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_12e40ae0","line":221,"in_reply_to":"9fdfeff1_203c9dc6","updated":"2019-02-18 16:33:38.000000000","message":"I still don\u0027t understand this change.\n\nAllServicesNeutronWorker() reset has the following call list:\n- AllServicesNeutronWorker.reset()\n  -\u003e common_service.Launcher.restart()\n    -\u003e Services.restart()\n      -\u003e For each service, stop()\n         For each service, restart()\n\nThere we have the problem you spotted out: we can call PeriodicWorker.stop() and PeriodicWorker.start() several times. What we need to do is to make stop() and start() idempotent functions.\n\nPeriodicWorker will start a FixedIntervalLoopingCall loop, what is a greenthread running periodically.\n\nWhen PeriodicWorker.stop() is called, LoopingCallBase._abort is set. If stop is called twice, LoopingCallBase will check if this event is set. In affirmative case, _abort.set() won\u0027t be called. This function, PeriodicWorker.stop(), is safe.\n\nIn the other side, PeriodicWorker.start() should be modified. The first time is called it will create FixedIntervalLoopingCall() object and then it will call FixedIntervalLoopingCall.start() --\u003e LoopingCallBase._start(). We can implement in FixedIntervalLoopingCall the LoopingCallBase._running property but public, to let PeriodicWorker know if the loop is running. In case PeriodicWorker.start() is called and self._loop is not None, we can check if the loop is already working or not. If the loop is running, we\u0027ll avoid calling .start() again.\n\nWith this change, we\u0027ll make PeriodicWorker safe to repetitive calls.","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":27288,"name":"Ahmed Zaid","email":"ahmed.zaid.ext@nokia.com","username":"ZaidA"},"change_message_id":"9d89388f0116ff29bf482e6658272f684e134164","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_64cbe252","line":221,"in_reply_to":"9fdfeff1_551c4ec0","updated":"2019-02-11 14:33:21.000000000","message":"For this service the reset() function  do a stop() then wait() then start(). Stop already done in the (/usr/lib/python2.7/site-packages/neutron/service.py  Services class restart function) and start already done because AllServicesNeutronWorker start at the end (After get a SIGHUB) . So we just need wait()  ( start() the service twice is the root cause for the issue)","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"b9feb4f855771bc5ae5bffaab687f81bcc3b2057","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_889846c0","line":221,"in_reply_to":"9fdfeff1_64cbe252","updated":"2019-02-12 08:45:47.000000000","message":"ok, but can\u0027t we change implementation of neutron.worker.PeriodicWorker class that it will not call start if worker is already started?\nMaybe I still don\u0027t understand something here but it looks for me a bit like workaround of the problem instead of \"real\" fix.","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":27288,"name":"Ahmed Zaid","email":"ahmed.zaid.ext@nokia.com","username":"ZaidA"},"change_message_id":"7c7360610cf46bbf0098c01bd815e6ba2a9b11b6","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_a81f4a06","line":221,"in_reply_to":"9fdfeff1_889846c0","updated":"2019-02-12 09:07:21.000000000","message":"The problem is only in this class AllServicesNeutronWorker. In reset , the class called the launcher reset which start all the service individually then called the start function in this class. We can not check if the Periodic worker started or not( two different classes do a start ).Also we can not change  Periodic worker because it works right when it get a SIGHUB). This is what we conclude as a fix. Please advice if you have a better approach.","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":27288,"name":"Ahmed Zaid","email":"ahmed.zaid.ext@nokia.com","username":"ZaidA"},"change_message_id":"b3219f2e8b45bdb26bcb9ef45badd07f3b92a2e4","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_c5ee0321","line":221,"in_reply_to":"9fdfeff1_a81f4a06","updated":"2019-02-14 08:19:05.000000000","message":"More details about the fix:\n1- The issue happens only in AllServicesNeutronWorker Service which contains different services like: PeriodicWorker and RPCWorker.\n\n2- If you  send a SIGHUP for services like: PeriodicWorker and RPCWorker , it will work fine (  No errors appear because they do one stop , wait and one start).\n\n3- We can not know if the services is already started or stopped to avoid double staring/stopping.\n\n4- The starting/stopping for a service happens first in sub service ( PeriodicWorker ) then in the main service ( AllServicesNeutronWorker ).","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"0ed35919d49e5ca2dd2d92fcc8e08f2981c09489","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_be8b8566","line":221,"in_reply_to":"9fdfeff1_b57ac8b7","updated":"2019-02-18 18:20:45.000000000","message":"We should try to make those classes independent. This \"if\" branch is difficult to understand if you don\u0027t know the code and we are adding an \"exception\" because we didn\u0027t design the worker classes (in particular PeriodicWorker) correctly. These kind of \"exceptions\" make the code more difficult to read.\n\nAllServicesNeutronWorker should communicate with the workers only through the Launcher interface, and Launcher should communicate with those workers only through the Services interface.\n\nWith this modification you are \"drilling a hole\" across two classes.\n\nIf PeriodicWorker stop() and start() are well implemented, there is no issue.","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"},{"author":{"_account_id":11975,"name":"Slawek Kaplonski","email":"skaplons@redhat.com","username":"slaweq"},"change_message_id":"47ac2b75d8c7a85d5b64a48933dc09a928c65fb6","unresolved":false,"context_lines":[{"line_number":218,"context_line":"    def reset(self):"},{"line_number":219,"context_line":"        for srv in self._services:"},{"line_number":220,"context_line":"            if isinstance(srv, n_worker.PeriodicWorker):"},{"line_number":221,"context_line":"                srv.wait()"},{"line_number":222,"context_line":"                continue"},{"line_number":223,"context_line":"            srv.reset()"},{"line_number":224,"context_line":""}],"source_content_type":"text/x-python","patch_set":6,"id":"9fdfeff1_203c9dc6","line":221,"in_reply_to":"9fdfeff1_c5ee0321","updated":"2019-02-14 09:06:16.000000000","message":"Thx for explanation. I think that this makes sense now.","commit_id":"3c282d1e1d25be7eaa12c6f0a8b10e936ce4e7e3"}],"neutron/worker.py":[{"author":{"_account_id":16688,"name":"Rodolfo Alonso","email":"ralonsoh@redhat.com","username":"rodolfo-alonso-hernandez"},"change_message_id":"6d59822613279b514fb67f6ac31852fc1945e427","unresolved":false,"context_lines":[{"line_number":29,"context_line":"        super(PeriodicWorker, self).start()"},{"line_number":30,"context_line":"        if self._loop is None:"},{"line_number":31,"context_line":"            self._loop \u003d loopingcall.FixedIntervalLoopingCall(self._check_func)"},{"line_number":32,"context_line":"        if not self._loop._running:"},{"line_number":33,"context_line":"           self._loop.start(interval\u003dself._interval,"},{"line_number":34,"context_line":"                            initial_delay\u003dself._initial_delay)"},{"line_number":35,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"9fdfeff1_2f250a0b","line":32,"range":{"start_line":32,"start_character":26,"end_line":32,"end_character":34},"updated":"2019-02-19 18:31:23.000000000","message":"I would suggest to implement \"running\" in FixedIntervalLoopingCall as a property to avoid pep8 complains about using a class private member.","commit_id":"be180c6e131610ad2773b6c33d1b0f1db854a6a0"}]}
