diff --git a/config.yaml b/config.yaml index 9e9465d2..67adf593 100644 --- a/config.yaml +++ b/config.yaml @@ -102,6 +102,10 @@ options: type: int default: 3600 description: Amount of time (in seconds) a token should remain valid. + catalog-cache-expiration: + type: int + default: 60 + description: Amount of time (in seconds) the catalog should be cached for. fernet-max-active-keys: type: int default: 3 diff --git a/hooks/keystone_context.py b/hooks/keystone_context.py index 71d385bf..61d1c653 100644 --- a/hooks/keystone_context.py +++ b/hooks/keystone_context.py @@ -201,6 +201,7 @@ class KeystoneContext(context.OSContextGenerator): ctxt['debug'] = config('debug') ctxt['verbose'] = config('verbose') ctxt['token_expiration'] = config('token-expiration') + ctxt['catalog_cache_expiration'] = config('catalog-cache-expiration') ctxt['identity_backend'] = config('identity-backend') ctxt['assignment_backend'] = config('assignment-backend') diff --git a/hooks/keystone_utils.py b/hooks/keystone_utils.py index 002cf78c..a975cd88 100644 --- a/hooks/keystone_utils.py +++ b/hooks/keystone_utils.py @@ -2211,6 +2211,7 @@ def send_id_service_notifications(data): relation_set( relation_id=rid, relation_settings={ + 'catalog_ttl': config('catalog-cache-expiration'), 'ep_changed': json.dumps(changed, sort_keys=True)}) diff --git a/templates/mitaka/keystone.conf b/templates/mitaka/keystone.conf index f6b46ed5..d5e5489e 100644 --- a/templates/mitaka/keystone.conf +++ b/templates/mitaka/keystone.conf @@ -38,6 +38,7 @@ driver = sql [os_inherit] [catalog] +cache_time = {{ catalog_cache_expiration }} driver = sql [endpoint_filter] diff --git a/templates/ocata/keystone.conf b/templates/ocata/keystone.conf index bef9e835..79134b99 100644 --- a/templates/ocata/keystone.conf +++ b/templates/ocata/keystone.conf @@ -38,6 +38,7 @@ driver = sql [os_inherit] [catalog] +cache_time = {{ catalog_cache_expiration }} driver = sql [endpoint_filter] diff --git a/templates/queens/keystone.conf b/templates/queens/keystone.conf index 748178c3..8fe8e02e 100644 --- a/templates/queens/keystone.conf +++ b/templates/queens/keystone.conf @@ -38,6 +38,7 @@ driver = sql [os_inherit] [catalog] +cache_time = {{ catalog_cache_expiration }} driver = sql [endpoint_filter] diff --git a/templates/rocky/keystone.conf b/templates/rocky/keystone.conf index 54651e20..82a5a65c 100644 --- a/templates/rocky/keystone.conf +++ b/templates/rocky/keystone.conf @@ -36,6 +36,7 @@ driver = sql driver = sql [catalog] +cache_time = {{ catalog_cache_expiration }} driver = sql [endpoint_filter] diff --git a/unit_tests/test_keystone_utils.py b/unit_tests/test_keystone_utils.py index 6a6005bf..c048ea65 100644 --- a/unit_tests/test_keystone_utils.py +++ b/unit_tests/test_keystone_utils.py @@ -924,6 +924,7 @@ class TestKeystoneUtils(CharmTestCase): call( relation_id='identity-service:1', relation_settings={ + 'catalog_ttl': 60, 'ep_changed': ('{"neutron": {"internal": ' '"http://neutron.demo.com:9696"}}') @@ -932,6 +933,7 @@ class TestKeystoneUtils(CharmTestCase): call( relation_id='identity-service:2', relation_settings={ + 'catalog_ttl': 60, 'ep_changed': ('{"neutron": {"internal": ' '"http://neutron.demo.com:9696"},' @@ -948,6 +950,7 @@ class TestKeystoneUtils(CharmTestCase): call( relation_id='identity-service:1', relation_settings={ + 'catalog_ttl': 60, 'ep_changed': '{"neutron": {"internal": "http://demo.com"}}' } @@ -955,6 +958,7 @@ class TestKeystoneUtils(CharmTestCase): call( relation_id='identity-service:2', relation_settings={ + 'catalog_ttl': 60, 'ep_changed': '{"neutron": {"internal": "http://demo.com"}}' } @@ -973,6 +977,7 @@ class TestKeystoneUtils(CharmTestCase): call( relation_id='identity-service:1', relation_settings={ + 'catalog_ttl': 60, 'ep_changed': '{"neutron": {"internal": "http://demo.com"}}' } @@ -980,6 +985,7 @@ class TestKeystoneUtils(CharmTestCase): call( relation_id='identity-service:2', relation_settings={ + 'catalog_ttl': 60, 'ep_changed': ( '{"neutron": {"internal": "http://demo.com"}, ' '"placement": {"internal": "http://demo.com"}}'