diff options
author | Johannes Grassler <johannes.grassler@suse.com> | 2016-03-02 17:20:16 +0100 |
---|---|---|
committer | Johannes Grassler <johannes.grassler@suse.com> | 2016-03-08 09:40:56 +0100 |
commit | 73969be4141088936e9fb2dff7d7a59c08d3f9ea (patch) | |
tree | bb436602db8de948c4c29870d6a8ef65a03bb278 | |
parent | 7e49be5fb7ae4a8f32c04f03f5af3f23ef8f147a (diff) | |
download | heat-73969be4141088936e9fb2dff7d7a59c08d3f9ea.tar.gz |
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 fe9226898772c4ff909f9c3f0cb05c271333b73a)
-rw-r--r-- | heat/common/auth_url.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/heat/common/auth_url.py b/heat/common/auth_url.py index 5a10280e8..877e212cd 100644 --- a/heat/common/auth_url.py +++ b/heat/common/auth_url.py @@ -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: |