-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add incoming/indexer/storage information to V1 API's status endpoint #995
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# -*- coding:Utf-8 -*- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add license header (copy paste from any file) |
||
from __future__ import unicode_literals | ||
|
||
from collections import OrderedDict | ||
import six | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file has a bunch of Ceph, Redis, etc specific stuff so I'm not comforable having that here. There's already a |
||
def get_ceph_health_status(driver): | ||
""" | ||
Return ceph status. | ||
Include ceph stats. | ||
""" | ||
response = OrderedDict([ | ||
('name', driver.__class__.__name__) | ||
]) | ||
try: | ||
stats = driver.rados.get_cluster_stats() | ||
except Exception as e: | ||
response['is_available'] = False | ||
response['error'] = six.text_type(e) | ||
else: | ||
response['is_available'] = True | ||
response['stats'] = stats | ||
return response | ||
|
||
|
||
def get_file_health_status(driver): | ||
""" | ||
Return file status. | ||
""" | ||
return OrderedDict([ | ||
('name', driver.__class__.__name__), | ||
('is_available', True) | ||
]) | ||
|
||
|
||
def get_redis_health_status(driver): | ||
""" | ||
Return redis status. | ||
Include redis info. | ||
""" | ||
response = OrderedDict([ | ||
('name', driver.__class__.__name__) | ||
]) | ||
try: | ||
info = driver._client.info() | ||
except Exception as e: | ||
response['is_available'] = False | ||
response['error'] = six.text_type(e) | ||
else: | ||
response['is_available'] = True | ||
response['info'] = info | ||
return response | ||
|
||
|
||
def get_s3_health_status(driver): | ||
""" | ||
Return s3 status. | ||
""" | ||
response = OrderedDict([ | ||
('name', driver.__class__.__name__) | ||
]) | ||
try: | ||
driver.s3.list_objects_v2( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this is an heavy operation with a lot of data that can be returned. Maybe something lighter? or setting a limit of just returning 1 object? |
||
Bucket=driver._bucket_name_measures, Prefix='/') | ||
except Exception as e: | ||
response['is_available'] = False | ||
response['error'] = six.text_type(e) | ||
else: | ||
response['is_available'] = True | ||
return response | ||
|
||
|
||
def get_sqlalchemy_health_status(driver): | ||
""" | ||
Return sqlalchemy status. | ||
""" | ||
response = OrderedDict([ | ||
('name', driver.__class__.__name__) | ||
]) | ||
try: | ||
with driver.facade.independent_reader() as session: | ||
session.execute('SELECT 1') | ||
except Exception as e: | ||
response['is_available'] = False | ||
response['error'] = six.text_type(e) | ||
else: | ||
response['is_available'] = True | ||
return response | ||
|
||
|
||
def get_swift_health_status(driver): | ||
""" | ||
Return swift status. | ||
Include swift account info. | ||
""" | ||
response = OrderedDict([ | ||
('name', driver.__class__.__name__) | ||
]) | ||
try: | ||
info = driver.swift.head_account() | ||
except Exception as e: | ||
response['is_available'] = False | ||
response['error'] = six.text_type(e) | ||
else: | ||
response['is_available'] = True | ||
response['info'] = info | ||
return response |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just go with
get_health_status = get_ceph_health_status
I guess?