Make auth_url lookup dynamic

If _get_auth_url() is run on heat-api startup, it can cause heat-api to crash
in situations where Keystone is not running, yet or temporarily unavailable.
This patch converts the auth_url attribute into a property method that is only
run when it is needed, thus preventing this race condition.

Change-Id: Ife6d9e51ea9647e4658105c016867efe769e5363
Closes-Bug: #1550284
This commit is contained in:
Johannes Grassler 2016-03-02 17:20:16 +01:00
parent 5b8085e1fb
commit fe92268987

View File

@ -27,7 +27,13 @@ class AuthUrlFilter(wsgi.Middleware):
def __init__(self, app, conf): def __init__(self, app, conf):
super(AuthUrlFilter, self).__init__(app) super(AuthUrlFilter, self).__init__(app)
self.conf = conf self.conf = conf
self.auth_url = self._get_auth_url() self._auth_url = None
@property
def auth_url(self):
if not self._auth_url:
self._auth_url = self._get_auth_url()
return self._auth_url
def _get_auth_url(self): def _get_auth_url(self):
if 'auth_uri' in self.conf: if 'auth_uri' in self.conf: