fix: better logging if health check fails for providers
Change-Id: I542df9a83589744dae603a595777aa4ef1765d9e
This commit is contained in:
parent
628c7ea743
commit
68b8d96a9c
|
@ -21,9 +21,13 @@ from akamai import edgegrid
|
|||
from oslo.config import cfg
|
||||
import requests
|
||||
|
||||
from poppy.openstack.common import log
|
||||
from poppy.provider.akamai import controllers
|
||||
from poppy.provider import base
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
AKAMAI_OPTIONS = [
|
||||
# credentials && base URL for policy API
|
||||
cfg.StrOpt(
|
||||
|
@ -155,6 +159,9 @@ class CDNProvider(base.Driver):
|
|||
if resp.ok:
|
||||
return True
|
||||
else:
|
||||
LOG.warn("Akamai Health Check Failed")
|
||||
LOG.warn("Response Status Code : {0}".format(resp.status_code))
|
||||
LOG.warn("Response Text : {0}".format(resp.text))
|
||||
return False
|
||||
|
||||
@property
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
edgegrid-python
|
||||
pyOpenSSL
|
||||
edgegrid-python==1.0.6
|
||||
pyOpenSSL
|
||||
|
|
|
@ -89,13 +89,23 @@ AKAMAI_OPTIONS = [
|
|||
|
||||
class Response(object):
|
||||
|
||||
def __init__(self, resp_status):
|
||||
def __init__(self, status_code, text, resp_status):
|
||||
self._status_code = status_code
|
||||
self._text = text
|
||||
self.resp_status = resp_status
|
||||
|
||||
@property
|
||||
def ok(self):
|
||||
return self.resp_status
|
||||
|
||||
@property
|
||||
def status_code(self):
|
||||
return self._status_code
|
||||
|
||||
@property
|
||||
def text(self):
|
||||
return self._text
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestDriver(base.TestCase):
|
||||
|
@ -136,7 +146,7 @@ class TestDriver(base.TestCase):
|
|||
status_code, text, health_status = details
|
||||
provider = driver.CDNProvider(self.conf)
|
||||
mock_api_client = provider.service_controller.driver.policy_api_client
|
||||
resp = Response(health_status)
|
||||
resp = Response(status_code, text, health_status)
|
||||
with mock.patch.object(mock_api_client, 'put',
|
||||
return_value=resp):
|
||||
self.assertEqual(health_status, provider.is_alive())
|
||||
|
|
Loading…
Reference in New Issue