)]}'
{"neutron/agent/metadata/agent.py":[{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"304dab5686c35946bd134de3981211ae7639d559","unresolved":false,"context_lines":[{"line_number":228,"context_line":"        else:"},{"line_number":229,"context_line":"            os.makedirs(dirname, 0o755)"},{"line_number":230,"context_line":""},{"line_number":231,"context_line":"        self.context \u003d context.get_admin_context_without_session()"},{"line_number":232,"context_line":"        self.state_rpc \u003d agent_rpc.PluginReportStateAPI(topics.PLUGIN)"},{"line_number":233,"context_line":"        self.agent_state \u003d {"},{"line_number":234,"context_line":"            \u0027binary\u0027: \u0027neutron-metadata-agent\u0027,"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAATn%2F%2B%2BfI%3D","line":231,"updated":"2013-11-17 07:20:27.000000000","message":"I recognize that this patch is inspired by existing implementations in the dhcp and l3 agents, but I\u0027d like to see state reporting init moved into a separate function called from init, (e.g. self.init_state_reporting()).","commit_id":"ed4de8a3818a623d51a2ba73dfb8bbefb0291f68"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"8066ce28bca2be3aaae14f58afaf7ea474682c49","unresolved":false,"context_lines":[{"line_number":228,"context_line":"        else:"},{"line_number":229,"context_line":"            os.makedirs(dirname, 0o755)"},{"line_number":230,"context_line":""},{"line_number":231,"context_line":"        self.context \u003d context.get_admin_context_without_session()"},{"line_number":232,"context_line":"        self.state_rpc \u003d agent_rpc.PluginReportStateAPI(topics.PLUGIN)"},{"line_number":233,"context_line":"        self.agent_state \u003d {"},{"line_number":234,"context_line":"            \u0027binary\u0027: \u0027neutron-metadata-agent\u0027,"}],"source_content_type":"text/x-python","patch_set":1,"id":"AAAATn%2F%2B8mc%3D","line":231,"in_reply_to":"AAAATn%2F%2B%2BfI%3D","updated":"2013-11-18 11:03:43.000000000","message":"Done","commit_id":"ed4de8a3818a623d51a2ba73dfb8bbefb0291f68"},{"author":{"_account_id":748,"name":"Armando Migliaccio","email":"armamig@gmail.com","username":"armando-migliaccio"},"change_message_id":"32d7f7c0beff49aeee73e341ae529bc5a76109b6","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2Bzv4%3D","line":258,"updated":"2013-11-19 21:31:04.000000000","message":"The practice of catching and logging Exception should be avoided where possible. Catch and handle what you care about, everything else is a bug.","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"45116beeae6050b155fbc431960b80eb2e247014","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2Bs3I%3D","line":258,"in_reply_to":"AAAATn%2F%2BwFc%3D","updated":"2013-11-21 11:22:13.000000000","message":"I\u0027ll catch AttributeError instead of Exception and treat everything else as bugs.","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"5a4d62b0ce77e36578fca2a2a1a2595dad22ff87","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2Bvqg%3D","line":258,"in_reply_to":"AAAATn%2F%2BwFc%3D","updated":"2013-11-20 19:33:10.000000000","message":"The suggestion wasn\u0027t to move from catching Exception to AttributeError.   The state reporting examples I\u0027ve seen (e.g. dhcp and l3 agents) have the same Exception block as you see here as well as an additional (and likely unused) block for AttributeError.","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"5a4d62b0ce77e36578fca2a2a1a2595dad22ff87","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2BvsQ%3D","line":258,"in_reply_to":"AAAATn%2F%2BwJI%3D","updated":"2013-11-20 19:33:10.000000000","message":"All good ideas.  Would you be willing to capture your thoughts in bug(s)/blueprint(s) so that the issue could be addressed globally?","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"9773bd53192a4c8c82d8eb4801aa09a47da3117d","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2BwFc%3D","line":258,"in_reply_to":"AAAATn%2F%2BwJI%3D","updated":"2013-11-20 17:21:40.000000000","message":"I think that moving from except Exception to except AttributeError is not going to cost Oleg a lot, and will make the except clause a lot less broad.","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":748,"name":"Armando Migliaccio","email":"armamig@gmail.com","username":"armando-migliaccio"},"change_message_id":"128afbb007aedc379330cb7cab74610886970270","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2BwJI%3D","line":258,"in_reply_to":"AAAATn%2F%2BycA%3D","updated":"2013-11-20 17:03:49.000000000","message":"This is not something that affects just the agents. There are way too many places where Exception is caught and logged. This is not about cleaning up existing code, is about advocating for a good coding practice during the review process. If we never start, we\u0027ll never eradicate it.\n\nHaving a follow-up patch that cleans all the \u0027except Exception\u0027 is pretty tough and difficult to achieve effectively without a context of the potential failures that a particular code may face.\n\nBesides the this code is prone to the introduction of other bugs that might go undetected because of the catch-all. This would be a lot better if we, for instance, would just catch for RemoteError: an error that is expected during the communication between the server and the agent. In this case the log level may even be considered \u0027error\u0027 here because the important stacktrace would be in the server; here we don\u0027t need to pollute the log, because nothing more will learn from it.\n\nSo in a nutshell: no, I think it makes sense to fix it here.","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"0bf0f946b561f52704298bec2c1382f8309c8256","unresolved":false,"context_lines":[{"line_number":255,"context_line":"            self.state_rpc.report_state(self.context,"},{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2BycA%3D","line":258,"in_reply_to":"AAAATn%2F%2Bzv4%3D","updated":"2013-11-20 07:12:25.000000000","message":"A quick survey of various agents shows that just about every one of them use this same pattern of logging exceptions.  The only deviation would appear to be that some agents look for AttributeError as an indication that the server doesn\u0027t support state reporting.\n\nAs reasonable as your request is, then, the pervasive nature of the problem suggests that it not be fixed piecemeal starting with this change.  Would you be willing to file a bug that ensures your concerns are addressed?","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":261,"name":"Salvatore Orlando","email":"salv.orlando@gmail.com","username":"salvatore-orlando"},"change_message_id":"9773bd53192a4c8c82d8eb4801aa09a47da3117d","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"},{"line_number":262,"context_line":"        server \u003d UnixDomainWSGIServer(\u0027neutron-metadata-agent\u0027)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2BwEY%3D","line":259,"updated":"2013-11-20 17:21:40.000000000","message":"How should be interpreted the condition in which a process fails to report the state?\nLOG.exception gives us the traceback - but if this is a true error condition, perhaps you might want a LOG.error here too - also consider the tempest initiative for failing jobs with ERROR in logs, which should allow for catching dormant bugs more easily","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"45116beeae6050b155fbc431960b80eb2e247014","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"},{"line_number":262,"context_line":"        server \u003d UnixDomainWSGIServer(\u0027neutron-metadata-agent\u0027)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2Bs24%3D","line":259,"in_reply_to":"AAAATn%2F%2BvqE%3D","updated":"2013-11-21 11:22:13.000000000","message":"Since going to catch only AttributeError (server just does not support state reports) I believe warning level is enough","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"5a4d62b0ce77e36578fca2a2a1a2595dad22ff87","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                                        self.agent_state)"},{"line_number":257,"context_line":"            self.agent_state.pop(\u0027start_flag\u0027, None)"},{"line_number":258,"context_line":"        except Exception:"},{"line_number":259,"context_line":"            LOG.exception(_(\"Failed reporting state!\"))"},{"line_number":260,"context_line":""},{"line_number":261,"context_line":"    def run(self):"},{"line_number":262,"context_line":"        server \u003d UnixDomainWSGIServer(\u0027neutron-metadata-agent\u0027)"}],"source_content_type":"text/x-python","patch_set":3,"id":"AAAATn%2F%2BvqE%3D","line":259,"in_reply_to":"AAAATn%2F%2BwEY%3D","updated":"2013-11-20 19:33:10.000000000","message":"LOG.exception logs at the ERROR level already:\n\nhttp://docs.python.org/2/library/logging.html#logging.Logger.exception","commit_id":"d6e855b7d2332b2f1108ee2a32f56b83be4d1f32"},{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"0d098be78139f8d3a531977e16da95e0c6e966f5","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                self.context,"},{"line_number":257,"context_line":"                self.agent_state,"},{"line_number":258,"context_line":"                use_call\u003dself.agent_state.get(\u0027start_flag\u0027))"},{"line_number":259,"context_line":"        except AttributeError:"},{"line_number":260,"context_line":"            # This means the server does not support report_state"},{"line_number":261,"context_line":"            LOG.warn(_(\u0027Neutron server does not support state report.\u0027"},{"line_number":262,"context_line":"                       \u0027 State report for this agent will be disabled.\u0027))"}],"source_content_type":"text/x-python","patch_set":5,"id":"AAAATn%2F%2Bqog%3D","line":259,"updated":"2013-11-21 20:12:18.000000000","message":"The suggestion was that a trap for AttributeError be added, not that the catch-all for Exception be lost.  As written, any exception (however temporal) in the rpc call will cause the state reporting greenthead to exit permanently.\n\nSee: https://github.com/openstack/neutron/blob/master/neutron/openstack/common/loopingcall.py#L90","commit_id":"280d30a2219f3c2891ebdd3d6236ca002f16a3cf"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"4de32110a9f2bb7d16ba4adbdcd11805f1ea6897","unresolved":false,"context_lines":[{"line_number":256,"context_line":"                self.context,"},{"line_number":257,"context_line":"                self.agent_state,"},{"line_number":258,"context_line":"                use_call\u003dself.agent_state.get(\u0027start_flag\u0027))"},{"line_number":259,"context_line":"        except AttributeError:"},{"line_number":260,"context_line":"            # This means the server does not support report_state"},{"line_number":261,"context_line":"            LOG.warn(_(\u0027Neutron server does not support state report.\u0027"},{"line_number":262,"context_line":"                       \u0027 State report for this agent will be disabled.\u0027))"}],"source_content_type":"text/x-python","patch_set":5,"id":"AAAATn%2F%2Bowc%3D","line":259,"in_reply_to":"AAAATn%2F%2Bqog%3D","updated":"2013-11-22 06:37:24.000000000","message":"Done","commit_id":"280d30a2219f3c2891ebdd3d6236ca002f16a3cf"}],"neutron/tests/unit/test_metadata_agent.py":[{"author":{"_account_id":2035,"name":"Maru Newby","email":"marun@redhat.com","username":"maru"},"change_message_id":"0e052ba1cbf068134021b4cb52a1da1439252261","unresolved":false,"context_lines":[{"line_number":382,"context_line":"                                mock.call().run()]"},{"line_number":383,"context_line":"                            )"},{"line_number":384,"context_line":""},{"line_number":385,"context_line":"    def test_state_reporting(self):"},{"line_number":386,"context_line":"        with mock.patch(\u0027neutron.agent.rpc.PluginReportStateAPI\u0027) as state_api:"},{"line_number":387,"context_line":"            with mock.patch(\u0027neutron.openstack.common.loopingcall.\u0027"},{"line_number":388,"context_line":"                            \u0027FixedIntervalLoopingCall\u0027) as loop_call:"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAATn%2F%2B7sU%3D","line":385,"updated":"2013-11-18 12:42:03.000000000","message":"Since everything is getting mocked out anyway, please separate testing of setup from testing of state reporting.","commit_id":"3f92ec0905cd9766032160ea9ea7374c152422bb"},{"author":{"_account_id":5948,"name":"Oleg Bondarev","email":"obondarev@mirantis.com","username":"obondarev"},"change_message_id":"96fcc100307f294f80ea85693f25f76269753cd4","unresolved":false,"context_lines":[{"line_number":382,"context_line":"                                mock.call().run()]"},{"line_number":383,"context_line":"                            )"},{"line_number":384,"context_line":""},{"line_number":385,"context_line":"    def test_state_reporting(self):"},{"line_number":386,"context_line":"        with mock.patch(\u0027neutron.agent.rpc.PluginReportStateAPI\u0027) as state_api:"},{"line_number":387,"context_line":"            with mock.patch(\u0027neutron.openstack.common.loopingcall.\u0027"},{"line_number":388,"context_line":"                            \u0027FixedIntervalLoopingCall\u0027) as loop_call:"}],"source_content_type":"text/x-python","patch_set":2,"id":"AAAATn%2F%2B7pg%3D","line":385,"in_reply_to":"AAAATn%2F%2B7sU%3D","updated":"2013-11-18 13:00:57.000000000","message":"sure, no problem","commit_id":"3f92ec0905cd9766032160ea9ea7374c152422bb"}]}
