)]}'
{"watcher/common/exception.py":[{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"de985e81d3795cd4d7f7d57d592ff83bd701f2f1","unresolved":false,"context_lines":[{"line_number":421,"context_line":""},{"line_number":422,"context_line":"class NoSuchMetric(WatcherException):"},{"line_number":423,"context_line":"    \"\"\"Indicate that the specified metric is not configured / exists\"\"\""},{"line_number":424,"context_line":"    msg_fmt \u003d _(\u0027No such metric: %(metric)s\u0027)"},{"line_number":425,"context_line":""},{"line_number":426,"context_line":""},{"line_number":427,"context_line":"class NoSuchMetricForHost(WatcherException):"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_eaf31a09","line":424,"updated":"2019-05-09 16:43:27.000000000","message":"nit: you could update the test_get_backend_wrong_metric test to assert the message is what you\u0027d expect, e.g.:\n\nex \u003d self.assertRaises(exception.NoSuchMetric, ...)\nself.assertIn(\u0027No such metric: instance_cpu_usage\u0027, six.text_type(ex))","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":29911,"name":"Dantali0n","email":"info@dantalion.nl","username":"Dantali0n"},"change_message_id":"bee2fc79e356d806011bad80a21fa2a8addc892a","unresolved":false,"context_lines":[{"line_number":424,"context_line":"    msg_fmt \u003d _(\u0027Metric: %(metric)s not available\u0027)"},{"line_number":425,"context_line":""},{"line_number":426,"context_line":""},{"line_number":427,"context_line":"class NoDatasourceAvailable(WatcherException):"},{"line_number":428,"context_line":"    \"\"\"No datasources have been configured\"\"\""},{"line_number":429,"context_line":"    msg_fmt \u003d _(\u0027No datasources available\u0027)"},{"line_number":430,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"dfbec78f_055ea1e5","line":427,"updated":"2019-05-09 17:56:00.000000000","message":"This exception is pretty close in name to DataSourceNotAvailable that particular exception is only used by the Monasca datasource when the dimensions parameter is not supplied to its methods.\n\nThis is an outdated parameter and the recently passed spec https://specs.openstack.org/openstack/watcher-specs/specs/train/approved/formal-datasource-interface.html specifies that these and other parameters will be deprecated and as a result this exception will also be removed.","commit_id":"ea101bb1521eb17f45394e046d8b268799ee3600"}],"watcher/datasource/manager.py":[{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"df843b96fe5cf10af15dd6e8ef516daa602a99eb","unresolved":false,"context_lines":[{"line_number":74,"context_line":"                        break"},{"line_number":75,"context_line":"            if not no_metric:"},{"line_number":76,"context_line":"                return getattr(self, datasource)"},{"line_number":77,"context_line":"        raise exception.NoSuchMetric(metric\u003dmetric)"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_8a5ffe0c","line":77,"range":{"start_line":77,"start_character":44,"end_line":77,"end_character":50},"updated":"2019-05-09 16:39:48.000000000","message":"Technically this could be an UnboundLocalError if self.datasources is empty, is that possible?\n\nAlso, this is just one of multiple metrics, right? I\u0027m not really sure how that works - this code is kind of confusing and isn\u0027t documented at all. It looks like it returns the value of the metric from the first datasource that has the metric, and raises if no datasources have the metric, but since metrics is plural it\u0027s confusing. Does anything call this with a list?","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"06fe0749f55807ee73b47a6779150688730c917d","unresolved":false,"context_lines":[{"line_number":74,"context_line":"                        break"},{"line_number":75,"context_line":"            if not no_metric:"},{"line_number":76,"context_line":"                return getattr(self, datasource)"},{"line_number":77,"context_line":"        raise exception.NoSuchMetric(metric\u003dmetric)"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_aacc426a","line":77,"range":{"start_line":77,"start_character":44,"end_line":77,"end_character":50},"in_reply_to":"dfbec78f_0ad0ee4f","updated":"2019-05-09 17:02:01.000000000","message":"\u003e self.datasources could be an empty list that is correct.\n \u003e \n\nOK so you could hit an UnboundLocalError with this change since the \u0027metric\u0027 variable is only from the inner for loop so both datasources and metrics have to be non-empty. -1 since you need to guard against that.\n\n \u003e The exception NoSuchMetric when there are no datasources configured\n \u003e makes little sense to me tbh.\n\nYeah I was thinking the same thing, it\u0027s definitely confusing. I\u0027m not sure who this helps - does it get caught and logged somewhere? Maybe it would be better to log something in here which has context before raising.\n\nAlternatively, pass metrics (the list) to NoSuchMetric and change the error message to be like \"No such metric(s): %(metrics)s\". Just a thought.","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":29911,"name":"Dantali0n","email":"info@dantalion.nl","username":"Dantali0n"},"change_message_id":"6c06d6b2eb963110e70e21660fc5d4e0a2ce764d","unresolved":false,"context_lines":[{"line_number":74,"context_line":"                        break"},{"line_number":75,"context_line":"            if not no_metric:"},{"line_number":76,"context_line":"                return getattr(self, datasource)"},{"line_number":77,"context_line":"        raise exception.NoSuchMetric(metric\u003dmetric)"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_6ac08a7c","line":77,"range":{"start_line":77,"start_character":44,"end_line":77,"end_character":50},"in_reply_to":"dfbec78f_4a882670","updated":"2019-05-09 16:49:15.000000000","message":"Yes this is how the datasource order from the configuration is honored.","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"1e2d53e6187133a5671936b0571f6f664bd42906","unresolved":false,"context_lines":[{"line_number":74,"context_line":"                        break"},{"line_number":75,"context_line":"            if not no_metric:"},{"line_number":76,"context_line":"                return getattr(self, datasource)"},{"line_number":77,"context_line":"        raise exception.NoSuchMetric(metric\u003dmetric)"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_4a882670","line":77,"range":{"start_line":77,"start_character":44,"end_line":77,"end_character":50},"in_reply_to":"dfbec78f_8a5ffe0c","updated":"2019-05-09 16:42:02.000000000","message":"I guess this method returns the first datasource that supports any of the given metrics, is that the idea?","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":29911,"name":"Dantali0n","email":"info@dantalion.nl","username":"Dantali0n"},"change_message_id":"6c06d6b2eb963110e70e21660fc5d4e0a2ce764d","unresolved":false,"context_lines":[{"line_number":74,"context_line":"                        break"},{"line_number":75,"context_line":"            if not no_metric:"},{"line_number":76,"context_line":"                return getattr(self, datasource)"},{"line_number":77,"context_line":"        raise exception.NoSuchMetric(metric\u003dmetric)"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_0ad0ee4f","line":77,"range":{"start_line":77,"start_character":44,"end_line":77,"end_character":50},"in_reply_to":"dfbec78f_8a5ffe0c","updated":"2019-05-09 16:49:15.000000000","message":"self.datasources could be an empty list that is correct.\n\nMetrics is almost always a list of multiple metrics but it could be a list with a single metric.\n\nThe exception NoSuchMetric when there are no datasources configured makes little sense to me tbh.","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":29911,"name":"Dantali0n","email":"info@dantalion.nl","username":"Dantali0n"},"change_message_id":"46aba1b0359ecafbd297a1966287c1b6b69630c5","unresolved":false,"context_lines":[{"line_number":74,"context_line":"                        break"},{"line_number":75,"context_line":"            if not no_metric:"},{"line_number":76,"context_line":"                return getattr(self, datasource)"},{"line_number":77,"context_line":"        raise exception.NoSuchMetric(metric\u003dmetric)"}],"source_content_type":"text/x-python","patch_set":2,"id":"dfbec78f_cad656c4","line":77,"range":{"start_line":77,"start_character":44,"end_line":77,"end_character":50},"in_reply_to":"dfbec78f_aacc426a","updated":"2019-05-09 17:18:36.000000000","message":"\u003e OK so you could hit an UnboundLocalError with this change since the\n \u003e \u0027metric\u0027 variable is only from the inner for loop so both\n \u003e datasources and metrics have to be non-empty. -1 since you need to\n \u003e guard against that.\n\nSeems fair.\n\n \u003e Yeah I was thinking the same thing, it\u0027s definitely confusing. I\u0027m\n \u003e not sure who this helps - does it get caught and logged somewhere?\n \u003e Maybe it would be better to log something in here which has context\n \u003e before raising.\n\nexceptions are logged the same way LOG statements are logged. Maybe we could keep NoSuchMetric as is and just log info instead. \n\nIn general the exceptions need cleaning it is pretty hard to determine which exception should indicate what error and there are quite some unused exceptions.\n\n \u003e Alternatively, pass metrics (the list) to NoSuchMetric and change\n \u003e the error message to be like \"No such metric(s): %(metrics)s\". Just\n \u003e a thought.\n\nSome of these metrics from the list might actually be available to the datasource so that might be confusing.","commit_id":"4c9d19d67b261527e64e948b10cdc6ffe6e70239"},{"author":{"_account_id":21692,"name":"licanwei","email":"li.canwei2@zte.com.cn","username":"licanwei"},"change_message_id":"8a26bedd849b7f2fda49bdcc788b78e18112d221","unresolved":false,"context_lines":[{"line_number":81,"context_line":""},{"line_number":82,"context_line":"        for datasource in self.datasources:"},{"line_number":83,"context_line":"            no_metric \u003d False"},{"line_number":84,"context_line":"            for metric in metrics:"},{"line_number":85,"context_line":"                if (metric not in self.metric_map[datasource] or"},{"line_number":86,"context_line":"                   self.metric_map[datasource].get(metric) is None):"},{"line_number":87,"context_line":"                        no_metric \u003d True"}],"source_content_type":"text/x-python","patch_set":3,"id":"bfb3d3c7_dd268717","line":84,"range":{"start_line":84,"start_character":26,"end_line":84,"end_character":33},"updated":"2019-05-17 05:32:54.000000000","message":"If len(metrics) is 0, metric is not defined. then line93 will throw a NameError exception.\nI think we should check metrics, just like self.datasources.","commit_id":"ea101bb1521eb17f45394e046d8b268799ee3600"},{"author":{"_account_id":29911,"name":"Dantali0n","email":"info@dantalion.nl","username":"Dantali0n"},"change_message_id":"ef87c0b8874d3cf162af5d91c154454d499095b6","unresolved":false,"context_lines":[{"line_number":81,"context_line":""},{"line_number":82,"context_line":"        for datasource in self.datasources:"},{"line_number":83,"context_line":"            no_metric \u003d False"},{"line_number":84,"context_line":"            for metric in metrics:"},{"line_number":85,"context_line":"                if (metric not in self.metric_map[datasource] or"},{"line_number":86,"context_line":"                   self.metric_map[datasource].get(metric) is None):"},{"line_number":87,"context_line":"                        no_metric \u003d True"}],"source_content_type":"text/x-python","patch_set":3,"id":"bfb3d3c7_af4efabe","line":84,"range":{"start_line":84,"start_character":26,"end_line":84,"end_character":33},"in_reply_to":"bfb3d3c7_dd268717","updated":"2019-05-17 06:07:18.000000000","message":"Done","commit_id":"ea101bb1521eb17f45394e046d8b268799ee3600"},{"author":{"_account_id":29911,"name":"Dantali0n","email":"info@dantalion.nl","username":"Dantali0n"},"change_message_id":"6a3fd80c3db9b10f06b1f902982f6736ccd2844f","unresolved":false,"context_lines":[{"line_number":81,"context_line":""},{"line_number":82,"context_line":"        for datasource in self.datasources:"},{"line_number":83,"context_line":"            no_metric \u003d False"},{"line_number":84,"context_line":"            for metric in metrics:"},{"line_number":85,"context_line":"                if (metric not in self.metric_map[datasource] or"},{"line_number":86,"context_line":"                   self.metric_map[datasource].get(metric) is None):"},{"line_number":87,"context_line":"                        no_metric \u003d True"}],"source_content_type":"text/x-python","patch_set":3,"id":"bfb3d3c7_6f2a42e8","line":84,"range":{"start_line":84,"start_character":26,"end_line":84,"end_character":33},"in_reply_to":"bfb3d3c7_dd268717","updated":"2019-05-17 05:50:43.000000000","message":"It should never happen because that would require a strategy calling get_backend while specifying that it requires no metrics from the backend. I will update just in case.","commit_id":"ea101bb1521eb17f45394e046d8b268799ee3600"}]}
