)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":11809,"name":"Craig Bryant","email":"craig.bryant@hpe.com","username":"craig-bryant"},"change_message_id":"f7dd44e58dd7e80ef6d753ae06f54e57291d7fbe","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add a random wait time between requests for a new token"},{"line_number":10,"context_line":"Continue attempting to send metrics while waiting."},{"line_number":11,"context_line":"Luanchpad bug: https://bugs.launchpad.net/monasca/+bug/1454432"},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"Change-Id: Ifd2e4891c24dbb0a53ad7d074f5842893ce4eedc"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"7a016987_8d27cc11","line":11,"updated":"2015-05-16 16:33:46.000000000","message":"If you add the line below, it will automatically change the state of your bug based on the review state:\n\nCloses-Bug: #1454432","commit_id":"84112b7f361316979b1f69484c1d9bb0a9b7d9a3"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"891279d7163958a4b52cf5b82c9f08546b72acf4","unresolved":false,"context_lines":[{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Add a random wait time between requests for a new token"},{"line_number":10,"context_line":"Continue attempting to send metrics while waiting."},{"line_number":11,"context_line":"Luanchpad bug: https://bugs.launchpad.net/monasca/+bug/1454432"},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"Change-Id: Ifd2e4891c24dbb0a53ad7d074f5842893ce4eedc"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"7a016987_bd4f3ebc","line":11,"in_reply_to":"7a016987_8d27cc11","updated":"2015-05-18 17:41:09.000000000","message":"Didn\u0027t know that, thanks","commit_id":"84112b7f361316979b1f69484c1d9bb0a9b7d9a3"}],"monasca_agent/forwarder/api/mon.py":[{"author":{"_account_id":11094,"name":"Tim Kuhlman","email":"timothy.kuhlman@canonical.com","username":"kuhlmant"},"change_message_id":"f222c0849e92c1f3e4540fe9c63ce572c12905b2","unresolved":false,"context_lines":[{"line_number":147,"context_line":"        except monascaclient.exc.HTTPException as he:"},{"line_number":148,"context_line":"            if he.code \u003d\u003d 401:"},{"line_number":149,"context_line":"                wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":150,"context_line":"                log.info(\"Invalid token detected. Waiting {} seconds before requesting new token.\".format(wait_time))"},{"line_number":151,"context_line":"                self._failure_reason \u003d \u0027Invalid token detected. Waiting to get new token from Keystone\u0027"},{"line_number":152,"context_line":"                self.resume_time \u003d time.time() + wait_time"},{"line_number":153,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":1,"id":"7a016987_8221e44f","line":150,"updated":"2015-05-15 19:33:01.000000000","message":"There is one consumer who still uses python 2.6 and for 2.6 you can\u0027t use an empty {} make it {0}","commit_id":"8fabfb0700b8fb7df371442010bad051e751b361"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"2b5a594a041279389af1c69f1ff067b2349790ff","unresolved":false,"context_lines":[{"line_number":147,"context_line":"        except monascaclient.exc.HTTPException as he:"},{"line_number":148,"context_line":"            if he.code \u003d\u003d 401:"},{"line_number":149,"context_line":"                wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":150,"context_line":"                log.info(\"Invalid token detected. Waiting {} seconds before requesting new token.\".format(wait_time))"},{"line_number":151,"context_line":"                self._failure_reason \u003d \u0027Invalid token detected. Waiting to get new token from Keystone\u0027"},{"line_number":152,"context_line":"                self.resume_time \u003d time.time() + wait_time"},{"line_number":153,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":1,"id":"7a016987_02897426","line":150,"in_reply_to":"7a016987_8221e44f","updated":"2015-05-15 19:34:57.000000000","message":"Oops, forgot about the 2.6 requirement. Done","commit_id":"8fabfb0700b8fb7df371442010bad051e751b361"},{"author":{"_account_id":11809,"name":"Craig Bryant","email":"craig.bryant@hpe.com","username":"craig-bryant"},"change_message_id":"f7dd44e58dd7e80ef6d753ae06f54e57291d7fbe","unresolved":false,"context_lines":[{"line_number":143,"context_line":"            return True"},{"line_number":144,"context_line":"        except monascaclient.exc.HTTPException as he:"},{"line_number":145,"context_line":"            if he.code \u003d\u003d 401:"},{"line_number":146,"context_line":"                self._failure_reason \u003d \u0027Invalid token detected. Waiting to get new token from Keystone\u0027"},{"line_number":147,"context_line":"                if not self.resume_time:"},{"line_number":148,"context_line":"                    wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":149,"context_line":"                    log.info(\"Invalid token detected. Waiting {0} seconds before requesting new token.\".format(wait_time))"}],"source_content_type":"text/x-python","patch_set":3,"id":"7a016987_0d64fc1f","line":146,"updated":"2015-05-16 16:33:46.000000000","message":"I don\u0027t think this is quite right. Usually the tokens expire after four hours or so and in that case we want to immediately get a new one. We don\u0027t want the metrics to stop flowing for up to a minute. So, it is really on the second failure in a row that it should back off. Maybe you need to add in something like: if the last token worked and we just replaced it, retry self.mon_client.metrics.create(**kwargs). If that fails or the last token didn\u0027t work, then wait\n\nPersonally, I don\u0027t like the fact the old code would wait to send the metrics on a valid token expiration","commit_id":"84112b7f361316979b1f69484c1d9bb0a9b7d9a3"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"891279d7163958a4b52cf5b82c9f08546b72acf4","unresolved":false,"context_lines":[{"line_number":143,"context_line":"            return True"},{"line_number":144,"context_line":"        except monascaclient.exc.HTTPException as he:"},{"line_number":145,"context_line":"            if he.code \u003d\u003d 401:"},{"line_number":146,"context_line":"                self._failure_reason \u003d \u0027Invalid token detected. Waiting to get new token from Keystone\u0027"},{"line_number":147,"context_line":"                if not self.resume_time:"},{"line_number":148,"context_line":"                    wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":149,"context_line":"                    log.info(\"Invalid token detected. Waiting {0} seconds before requesting new token.\".format(wait_time))"}],"source_content_type":"text/x-python","patch_set":3,"id":"7a016987_ddac3a37","line":146,"in_reply_to":"7a016987_0d64fc1f","updated":"2015-05-18 17:41:09.000000000","message":"Agreed, I\u0027ll change this to retry at least once before waiting","commit_id":"84112b7f361316979b1f69484c1d9bb0a9b7d9a3"},{"author":{"_account_id":11809,"name":"Craig Bryant","email":"craig.bryant@hpe.com","username":"craig-bryant"},"change_message_id":"6575340f1d2ff463bbee30d63edd4d3a323b96d2","unresolved":false,"context_lines":[{"line_number":148,"context_line":"                    wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":149,"context_line":"                    self.resume_time \u003d time.time() + wait_time"},{"line_number":150,"context_line":"                    # Retry once. If this fails for any reason, assume the token is bad"},{"line_number":151,"context_line":"                    if self._send_message(**kwargs):"},{"line_number":152,"context_line":"                        return True"},{"line_number":153,"context_line":"                    log.info(\"Invalid token detected. Waiting %d seconds before getting new token.\", wait_time)"},{"line_number":154,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":4,"id":"7a016987_d1a89379","line":151,"updated":"2015-05-19 13:56:59.000000000","message":"This doesn\u0027t address the most common case of the token timing out. It will still be the old token which will still return a 401. You need to get a new token before retrying the _send_message if the token timed out","commit_id":"222005a15aa64dcde44d7da0c50ae8903fdf371b"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"fc94831e44b56f426bcc52d1abf562024021d45d","unresolved":false,"context_lines":[{"line_number":148,"context_line":"                    wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":149,"context_line":"                    self.resume_time \u003d time.time() + wait_time"},{"line_number":150,"context_line":"                    # Retry once. If this fails for any reason, assume the token is bad"},{"line_number":151,"context_line":"                    if self._send_message(**kwargs):"},{"line_number":152,"context_line":"                        return True"},{"line_number":153,"context_line":"                    log.info(\"Invalid token detected. Waiting %d seconds before getting new token.\", wait_time)"},{"line_number":154,"context_line":"            else:"}],"source_content_type":"text/x-python","patch_set":4,"id":"7a016987_6ce6a4b1","line":151,"in_reply_to":"7a016987_d1a89379","updated":"2015-05-19 14:57:26.000000000","message":"Oops, forgot this","commit_id":"222005a15aa64dcde44d7da0c50ae8903fdf371b"},{"author":{"_account_id":11809,"name":"Craig Bryant","email":"craig.bryant@hpe.com","username":"craig-bryant"},"change_message_id":"6575340f1d2ff463bbee30d63edd4d3a323b96d2","unresolved":false,"context_lines":[{"line_number":149,"context_line":"                    self.resume_time \u003d time.time() + wait_time"},{"line_number":150,"context_line":"                    # Retry once. If this fails for any reason, assume the token is bad"},{"line_number":151,"context_line":"                    if self._send_message(**kwargs):"},{"line_number":152,"context_line":"                        return True"},{"line_number":153,"context_line":"                    log.info(\"Invalid token detected. Waiting %d seconds before getting new token.\", wait_time)"},{"line_number":154,"context_line":"            else:"},{"line_number":155,"context_line":"                log.debug(\"Error sending message to monasca-api. Error is {0}.\""}],"source_content_type":"text/x-python","patch_set":4,"id":"7a016987_d171b345","line":152,"updated":"2015-05-19 13:56:59.000000000","message":"At this point you have already set resume_time so even if it succeeds it will still wait and get a new token","commit_id":"222005a15aa64dcde44d7da0c50ae8903fdf371b"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"fc94831e44b56f426bcc52d1abf562024021d45d","unresolved":false,"context_lines":[{"line_number":149,"context_line":"                    self.resume_time \u003d time.time() + wait_time"},{"line_number":150,"context_line":"                    # Retry once. If this fails for any reason, assume the token is bad"},{"line_number":151,"context_line":"                    if self._send_message(**kwargs):"},{"line_number":152,"context_line":"                        return True"},{"line_number":153,"context_line":"                    log.info(\"Invalid token detected. Waiting %d seconds before getting new token.\", wait_time)"},{"line_number":154,"context_line":"            else:"},{"line_number":155,"context_line":"                log.debug(\"Error sending message to monasca-api. Error is {0}.\""}],"source_content_type":"text/x-python","patch_set":4,"id":"7a016987_0cdbb0ed","line":152,"in_reply_to":"7a016987_d171b345","updated":"2015-05-19 14:57:26.000000000","message":"if _send_message succeeds it sets resume_time to None in the try block","commit_id":"222005a15aa64dcde44d7da0c50ae8903fdf371b"},{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"42c18a958e7b5bf11980cecbd079a2b7a3fff19d","unresolved":false,"context_lines":[{"line_number":10,"context_line":"log \u003d logging.getLogger(__name__)"},{"line_number":11,"context_line":""},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"class MonAPI(object):"},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"    \"\"\"Sends measurements to MonAPI"},{"line_number":16,"context_line":"        Any errors should raise an exception so the transaction calling"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_2f9645f0","line":13,"updated":"2015-05-29 14:14:04.000000000","message":"Potential rename as MonascaApi. This is just old cruft that is hanging around.","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"563affe8e790c4baa36bb1789e40fbe87ceac0ef","unresolved":false,"context_lines":[{"line_number":10,"context_line":"log \u003d logging.getLogger(__name__)"},{"line_number":11,"context_line":""},{"line_number":12,"context_line":""},{"line_number":13,"context_line":"class MonAPI(object):"},{"line_number":14,"context_line":""},{"line_number":15,"context_line":"    \"\"\"Sends measurements to MonAPI"},{"line_number":16,"context_line":"        Any errors should raise an exception so the transaction calling"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_d72bc780","line":13,"in_reply_to":"7a016987_2f9645f0","updated":"2015-05-29 15:09:27.000000000","message":"Done","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"42c18a958e7b5bf11980cecbd079a2b7a3fff19d","unresolved":false,"context_lines":[{"line_number":31,"context_line":"        self.keystone \u003d keystone.Keystone(config)"},{"line_number":32,"context_line":"        self.mon_client \u003d None"},{"line_number":33,"context_line":"        self._failure_reason \u003d None"},{"line_number":34,"context_line":"        self.resume_time \u003d None"},{"line_number":35,"context_line":"        self.max_buffer_size \u003d int(config[\u0027max_buffer_size\u0027])"},{"line_number":36,"context_line":"        self.backlog_send_rate \u003d int(config[\u0027backlog_send_rate\u0027])"},{"line_number":37,"context_line":"        self.message_queue \u003d collections.deque(maxlen\u003dself.max_buffer_size)"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_0f1ee96f","line":34,"updated":"2015-05-29 14:14:04.000000000","message":"Are we following a convention for private vars with a leading _?","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"563affe8e790c4baa36bb1789e40fbe87ceac0ef","unresolved":false,"context_lines":[{"line_number":31,"context_line":"        self.keystone \u003d keystone.Keystone(config)"},{"line_number":32,"context_line":"        self.mon_client \u003d None"},{"line_number":33,"context_line":"        self._failure_reason \u003d None"},{"line_number":34,"context_line":"        self.resume_time \u003d None"},{"line_number":35,"context_line":"        self.max_buffer_size \u003d int(config[\u0027max_buffer_size\u0027])"},{"line_number":36,"context_line":"        self.backlog_send_rate \u003d int(config[\u0027backlog_send_rate\u0027])"},{"line_number":37,"context_line":"        self.message_queue \u003d collections.deque(maxlen\u003dself.max_buffer_size)"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_773bf3d1","line":34,"in_reply_to":"7a016987_0f1ee96f","updated":"2015-05-29 15:09:27.000000000","message":"Done","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"42c18a958e7b5bf11980cecbd079a2b7a3fff19d","unresolved":false,"context_lines":[{"line_number":135,"context_line":"        if self.resume_time:"},{"line_number":136,"context_line":"            if time.time() \u003e self.resume_time:"},{"line_number":137,"context_line":"                self.resume_time \u003d None"},{"line_number":138,"context_line":"                log.info(\"Getting new token...\")"},{"line_number":139,"context_line":"                # Get a new keystone client and token"},{"line_number":140,"context_line":"                if self.keystone.refresh_token():"},{"line_number":141,"context_line":"                    self.mon_client.replace_token(self.keystone.get_token())"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_6f031d11","line":138,"updated":"2015-05-29 14:14:04.000000000","message":"I wouldn\u0027t use a log info statement here. Maybe a log debug or log trace. This is not general info that I want to see in my log file.","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"563affe8e790c4baa36bb1789e40fbe87ceac0ef","unresolved":false,"context_lines":[{"line_number":135,"context_line":"        if self.resume_time:"},{"line_number":136,"context_line":"            if time.time() \u003e self.resume_time:"},{"line_number":137,"context_line":"                self.resume_time \u003d None"},{"line_number":138,"context_line":"                log.info(\"Getting new token...\")"},{"line_number":139,"context_line":"                # Get a new keystone client and token"},{"line_number":140,"context_line":"                if self.keystone.refresh_token():"},{"line_number":141,"context_line":"                    self.mon_client.replace_token(self.keystone.get_token())"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_7769b3bd","line":138,"in_reply_to":"7a016987_6f031d11","updated":"2015-05-29 15:09:27.000000000","message":"Done","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"42c18a958e7b5bf11980cecbd079a2b7a3fff19d","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            self.mon_client.metrics.create(**kwargs)"},{"line_number":147,"context_line":"            self.resume_time \u003d None"},{"line_number":148,"context_line":"            return True"},{"line_number":149,"context_line":"        except monascaclient.exc.HTTPException as he:"},{"line_number":150,"context_line":"            if he.code \u003d\u003d 401:"},{"line_number":151,"context_line":"                # monasca client should already have retried once with a new token before returning this exception"},{"line_number":152,"context_line":"                self._failure_reason \u003d \u0027Invalid token detected. Waiting to get new token from Keystone\u0027"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_616691ee","line":149,"updated":"2015-05-29 14:14:04.000000000","message":"Would prefer just using \"ex\" which is sort of a convention. No need to introduce a variable called \"he\"","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"563affe8e790c4baa36bb1789e40fbe87ceac0ef","unresolved":false,"context_lines":[{"line_number":146,"context_line":"            self.mon_client.metrics.create(**kwargs)"},{"line_number":147,"context_line":"            self.resume_time \u003d None"},{"line_number":148,"context_line":"            return True"},{"line_number":149,"context_line":"        except monascaclient.exc.HTTPException as he:"},{"line_number":150,"context_line":"            if he.code \u003d\u003d 401:"},{"line_number":151,"context_line":"                # monasca client should already have retried once with a new token before returning this exception"},{"line_number":152,"context_line":"                self._failure_reason \u003d \u0027Invalid token detected. Waiting to get new token from Keystone\u0027"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_172eff8b","line":149,"in_reply_to":"7a016987_616691ee","updated":"2015-05-29 15:09:27.000000000","message":"Done","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":2419,"name":"Roland Hochmuth","email":"roland.hochmuth@hpe.com","username":"roland-hochmuth-s"},"change_message_id":"42c18a958e7b5bf11980cecbd079a2b7a3fff19d","unresolved":false,"context_lines":[{"line_number":153,"context_line":"                if not self.resume_time:"},{"line_number":154,"context_line":"                    wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":155,"context_line":"                    self.resume_time \u003d time.time() + wait_time"},{"line_number":156,"context_line":"                    log.info(\"Invalid token detected. Waiting %d seconds before getting new token.\", wait_time)"},{"line_number":157,"context_line":"            else:"},{"line_number":158,"context_line":"                log.debug(\"Error sending message to monasca-api. Error is {0}.\""},{"line_number":159,"context_line":"                          .format(str(he.message)))"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_01d11d57","line":156,"updated":"2015-05-29 14:14:04.000000000","message":"IMHO, this shouldn\u0027t be a log.info statement. Probably an error in this case. You are attempting to get a new token and that has failed, possibly multiple times. That is unexpected and an error, right?","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"},{"author":{"_account_id":14517,"name":"Ryan Brandt","email":"ryan.brandt@hpe.com","username":"ryan-brandt"},"change_message_id":"563affe8e790c4baa36bb1789e40fbe87ceac0ef","unresolved":false,"context_lines":[{"line_number":153,"context_line":"                if not self.resume_time:"},{"line_number":154,"context_line":"                    wait_time \u003d random.randint(MonAPI.MIN_BACKOFF, MonAPI.MAX_BACKOFF + 1)"},{"line_number":155,"context_line":"                    self.resume_time \u003d time.time() + wait_time"},{"line_number":156,"context_line":"                    log.info(\"Invalid token detected. Waiting %d seconds before getting new token.\", wait_time)"},{"line_number":157,"context_line":"            else:"},{"line_number":158,"context_line":"                log.debug(\"Error sending message to monasca-api. Error is {0}.\""},{"line_number":159,"context_line":"                          .format(str(he.message)))"}],"source_content_type":"text/x-python","patch_set":6,"id":"7a016987_d7798794","line":156,"in_reply_to":"7a016987_01d11d57","updated":"2015-05-29 15:09:27.000000000","message":"Done","commit_id":"d9d2865a72484c6480aabd5fdf673daa2560fdba"}]}
