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
(cherry picked from commit fe92268987)
This commit is contained in:
Johannes Grassler 2016-03-02 17:20:16 +01:00
parent 7e49be5fb7
commit 73969be414
1 changed files with 7 additions and 1 deletions

View File

@ -28,7 +28,13 @@ class AuthUrlFilter(wsgi.Middleware):
def __init__(self, app, conf):
super(AuthUrlFilter, self).__init__(app)
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):
if 'auth_uri' in self.conf: