Skip to content

Commit

Permalink
Merge pull request #848 from HubSpot/logfetch_decom_err
Browse files Browse the repository at this point in the history
(logfetch) don't print 404 errors for slaves where directory isn't available
  • Loading branch information
ssalinas committed Jan 19, 2016
2 parents 7a5602c + 907213d commit 53134a2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scripts/logfetch/live_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ def task_still_running(args, task, history):

def files_json(args, task):
uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task)
return get_json_response(uri, args)
return get_json_response(uri, args, {}, True)

def logs_folder_files(args, task):
uri = BROWSE_FOLDER_FORMAT.format(logfetch_base.base_uri(args), task)
files_json = get_json_response(uri, args, {'path' : '{0}/logs'.format(task)})
files_json = get_json_response(uri, args, {'path' : '{0}/logs'.format(task)}, True)
if 'files' in files_json:
files = files_json['files']
return [f['name'] for f in files if logfetch_base.is_in_date_range(args, f['mtime'])]
Expand Down
9 changes: 5 additions & 4 deletions scripts/logfetch/singularity_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

ERROR_STATUS_FORMAT = 'Singularity responded with an invalid status code ({0})'

def get_json_response(uri, args, params={}):
def get_json_response(uri, args, params={}, skip404ErrMessage=False):
singularity_response = requests.get(uri, params=params, headers=args.headers)
if singularity_response.status_code < 199 or singularity_response.status_code > 299:
if not args.silent:
if not args.silent and not (skip404ErrMessage and singularity_response.status_code == 404):
sys.stderr.write('{0} params:{1}\n'.format(uri, str(params)))
sys.stderr.write(colored(ERROR_STATUS_FORMAT.format(singularity_response.status_code), 'red') + '\n')
if not args.silent:
if not (skip404ErrMessage and singularity_response.status_code == 404):
sys.stderr.write(colored(ERROR_STATUS_FORMAT.format(singularity_response.status_code), 'red') + '\n')
if not args.silent and not (skip404ErrMessage and singularity_response.status_code == 404):
sys.stderr.write(colored(singularity_response.text, 'red') + '\n')
return {}
return singularity_response.json()
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='singularity-logfetch',
version='0.22.0',
version='0.22.1',
description='Singularity log fetching and searching',
author="HubSpot",
author_email='[email protected]',
Expand Down

0 comments on commit 53134a2

Please sign in to comment.