Logging cleanup
Change-Id: Iebd3928ed0b483770d1c47b66e26eb8be249d720
This commit is contained in:
@@ -393,7 +393,7 @@ def exception_handler():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, exceptions.HTTPException):
|
if isinstance(e, exceptions.HTTPException):
|
||||||
raise # ignore Flask exceptions
|
raise # ignore Flask exceptions
|
||||||
LOG.exception(e)
|
LOG.error(e, exc_info=True)
|
||||||
flask.abort(404)
|
flask.abort(404)
|
||||||
|
|
||||||
return exception_handler_decorated_function
|
return exception_handler_decorated_function
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ def get_vault():
|
|||||||
|
|
||||||
flask.current_app.stackalytics_vault = vault
|
flask.current_app.stackalytics_vault = vault
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.critical('Failed to initialize application: %s', e)
|
LOG.critical('Failed to initialize application: %s', e,
|
||||||
LOG.exception(e)
|
exc_info=True)
|
||||||
flask.abort(500)
|
flask.abort(500)
|
||||||
|
|
||||||
if not getattr(flask.request, 'stackalytics_updated', None):
|
if not getattr(flask.request, 'stackalytics_updated', None):
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ class Gerrit(Rcs):
|
|||||||
except RcsException:
|
except RcsException:
|
||||||
self.error_count += 1
|
self.error_count += 1
|
||||||
|
|
||||||
raise RcsException('Too many SSH errors, aborting')
|
raise RcsException('Too many SSH errors, aborting. Consider '
|
||||||
|
'increasing "gerrit_retry" value')
|
||||||
|
|
||||||
def _poll_reviews(self, project_organization, module, branch,
|
def _poll_reviews(self, project_organization, module, branch,
|
||||||
last_retrieval_time, status=None, grab_comments=False):
|
last_retrieval_time, status=None, grab_comments=False):
|
||||||
|
|||||||
@@ -174,13 +174,13 @@ class RecordProcessor(object):
|
|||||||
lp_ids = set(u.get('launchpad_id') for u in user_profiles
|
lp_ids = set(u.get('launchpad_id') for u in user_profiles
|
||||||
if u.get('launchpad_id'))
|
if u.get('launchpad_id'))
|
||||||
if len(lp_ids) > 1:
|
if len(lp_ids) > 1:
|
||||||
LOG.info('Ambiguous launchpad ids: %s on profiles: %s',
|
LOG.debug('Ambiguous launchpad ids: %s on profiles: %s',
|
||||||
lp_ids, user_profiles)
|
lp_ids, user_profiles)
|
||||||
g_ids = set(u.get('gerrit_id') for u in user_profiles
|
g_ids = set(u.get('gerrit_id') for u in user_profiles
|
||||||
if u.get('gerrit_id'))
|
if u.get('gerrit_id'))
|
||||||
if len(g_ids) > 1:
|
if len(g_ids) > 1:
|
||||||
LOG.info('Ambiguous gerrit ids: %s on profiles: %s',
|
LOG.debug('Ambiguous gerrit ids: %s on profiles: %s',
|
||||||
g_ids, user_profiles)
|
g_ids, user_profiles)
|
||||||
|
|
||||||
merged_user = {} # merged user profile
|
merged_user = {} # merged user profile
|
||||||
|
|
||||||
|
|||||||
@@ -99,11 +99,11 @@ class Git(Vcs):
|
|||||||
sh.git('reset', '--hard')
|
sh.git('reset', '--hard')
|
||||||
sh.git('checkout', 'origin/' + branch)
|
sh.git('checkout', 'origin/' + branch)
|
||||||
return True
|
return True
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to checkout branch %(branch)s from repo '
|
LOG.error('Unable to checkout branch %(branch)s from repo '
|
||||||
'%(uri)s. Ignore it',
|
'%(uri)s. Ignore it',
|
||||||
{'branch': branch, 'uri': self.repo['uri']})
|
{'branch': branch, 'uri': self.repo['uri']},
|
||||||
LOG.exception(e)
|
exc_info=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def fetch(self):
|
def fetch(self):
|
||||||
@@ -114,10 +114,9 @@ class Git(Vcs):
|
|||||||
try:
|
try:
|
||||||
uri = str(
|
uri = str(
|
||||||
sh.git('config', '--get', 'remote.origin.url')).strip()
|
sh.git('config', '--get', 'remote.origin.url')).strip()
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to get config for git repo %s. Ignore it',
|
LOG.error('Unable to get config for git repo %s. Ignore it',
|
||||||
self.repo['uri'])
|
self.repo['uri'], exc_info=True)
|
||||||
LOG.exception(e)
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
if uri != self.repo['uri']:
|
if uri != self.repo['uri']:
|
||||||
@@ -131,18 +130,16 @@ class Git(Vcs):
|
|||||||
try:
|
try:
|
||||||
sh.git('clone', self.repo['uri'])
|
sh.git('clone', self.repo['uri'])
|
||||||
os.chdir(self.folder)
|
os.chdir(self.folder)
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to clone git repo %s. Ignore it',
|
LOG.error('Unable to clone git repo %s. Ignore it',
|
||||||
self.repo['uri'])
|
self.repo['uri'], exc_info=True)
|
||||||
LOG.exception(e)
|
|
||||||
else:
|
else:
|
||||||
os.chdir(self.folder)
|
os.chdir(self.folder)
|
||||||
try:
|
try:
|
||||||
sh.git('fetch')
|
sh.git('fetch')
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to fetch git repo %s. Ignore it',
|
LOG.error('Unable to fetch git repo %s. Ignore it',
|
||||||
self.repo['uri'])
|
self.repo['uri'], exc_info=True)
|
||||||
LOG.exception(e)
|
|
||||||
|
|
||||||
return self._get_release_index()
|
return self._get_release_index()
|
||||||
|
|
||||||
@@ -173,10 +170,9 @@ class Git(Vcs):
|
|||||||
_tty_out=False)
|
_tty_out=False)
|
||||||
for commit_id in git_log_iterator:
|
for commit_id in git_log_iterator:
|
||||||
self.release_index[commit_id.strip()] = release_name
|
self.release_index[commit_id.strip()] = release_name
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to get log of git repo %s. Ignore it',
|
LOG.error('Unable to get log of git repo %s. Ignore it',
|
||||||
self.repo['uri'])
|
self.repo['uri'], exc_info=True)
|
||||||
LOG.exception(e)
|
|
||||||
return self.release_index
|
return self.release_index
|
||||||
|
|
||||||
def log(self, branch, head_commit_id):
|
def log(self, branch, head_commit_id):
|
||||||
@@ -194,10 +190,9 @@ class Git(Vcs):
|
|||||||
output = sh.git('log', '--pretty=' + GIT_LOG_FORMAT, '--shortstat',
|
output = sh.git('log', '--pretty=' + GIT_LOG_FORMAT, '--shortstat',
|
||||||
'-M', '--no-merges', commit_range, _tty_out=False,
|
'-M', '--no-merges', commit_range, _tty_out=False,
|
||||||
_decode_errors='ignore', _encoding='utf8')
|
_decode_errors='ignore', _encoding='utf8')
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to get log of git repo %s. Ignore it',
|
LOG.error('Unable to get log of git repo %s. Ignore it',
|
||||||
self.repo['uri'])
|
self.repo['uri'], exc_info=True)
|
||||||
LOG.exception(e)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
for rec in re.finditer(GIT_LOG_PATTERN, six.text_type(output)):
|
for rec in re.finditer(GIT_LOG_PATTERN, six.text_type(output)):
|
||||||
@@ -286,10 +281,9 @@ class Git(Vcs):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return str(sh.git('rev-parse', 'HEAD')).strip()
|
return str(sh.git('rev-parse', 'HEAD')).strip()
|
||||||
except sh.ErrorReturnCode as e:
|
except sh.ErrorReturnCode:
|
||||||
LOG.error('Unable to get HEAD for git repo %s. Ignore it',
|
LOG.error('Unable to get HEAD for git repo %s. Ignore it',
|
||||||
self.repo['uri'])
|
self.repo['uri'], exc_info=True)
|
||||||
LOG.exception(e)
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user