Browse code

Add options to configure cache in nova

This patch adds new options:
* CACHE_BACKEND - with default "dogpile.cache.memcached"
* MEMCACHE_SERVERS - with default "localhost:1121"

to add possibility to configure various backends as cache in
Nova and Keystone.
It also adds options:
* KEYSTONE_ENABLE_CACHE - True by default
* NOVA_ENABLE_CACHE - True by default

To make possibility to enable and disable cache in those projects'
config files.

Default values configured there are the same as before were
hardcoded for Keystone config.

Nova has also enabled this cache by default.

Change-Id: I9082be077b59acd3a39910fa64e29147cb5c2dd7
Closes-Bug: #1836642

Slawek Kaplonski authored on 2019/08/01 21:58:37
Showing 3 changed files
... ...
@@ -131,6 +131,9 @@ KEYSTONE_UNIQUE_LAST_PASSWORD_COUNT=${KEYSTONE_UNIQUE_LAST_PASSWORD_COUNT:-2}
131 131
 # however may not be suitable for real production.
132 132
 KEYSTONE_PASSWORD_HASH_ROUNDS=${KEYSTONE_PASSWORD_HASH_ROUNDS:-4}
133 133
 
134
+# Cache settings
135
+KEYSTONE_ENABLE_CACHE=${KEYSTONE_ENABLE_CACHE:-True}
136
+
134 137
 # Functions
135 138
 # ---------
136 139
 
... ...
@@ -213,9 +216,9 @@ function configure_keystone {
213 213
     iniset $KEYSTONE_CONF resource driver "$KEYSTONE_RESOURCE_BACKEND"
214 214
 
215 215
     # Enable caching
216
-    iniset $KEYSTONE_CONF cache enabled "True"
217
-    iniset $KEYSTONE_CONF cache backend "dogpile.cache.memcached"
218
-    iniset $KEYSTONE_CONF cache memcache_servers localhost:11211
216
+    iniset $KEYSTONE_CONF cache enabled $KEYSTONE_ENABLE_CACHE
217
+    iniset $KEYSTONE_CONF cache backend $CACHE_BACKEND
218
+    iniset $KEYSTONE_CONF cache memcache_servers $MEMCACHE_SERVERS
219 219
 
220 220
     iniset_rpc_backend keystone $KEYSTONE_CONF oslo_messaging_notifications
221 221
 
... ...
@@ -91,6 +91,7 @@ NOVA_SERVICE_PROTOCOL=${NOVA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
91 91
 NOVA_SERVICE_LOCAL_HOST=${NOVA_SERVICE_LOCAL_HOST:-$SERVICE_LOCAL_HOST}
92 92
 NOVA_SERVICE_LISTEN_ADDRESS=${NOVA_SERVICE_LISTEN_ADDRESS:-$(ipv6_unquote $SERVICE_LISTEN_ADDRESS)}
93 93
 METADATA_SERVICE_PORT=${METADATA_SERVICE_PORT:-8775}
94
+NOVA_ENABLE_CACHE=${NOVA_ENABLE_CACHE:-True}
94 95
 
95 96
 # Option to enable/disable config drive
96 97
 # NOTE: Set ``FORCE_CONFIG_DRIVE="False"`` to turn OFF config drive
... ...
@@ -416,8 +417,8 @@ function create_nova_conf {
416 416
         iniset $NOVA_CONF DEFAULT bindir "/usr/bin"
417 417
     fi
418 418
 
419
-    # only setup database connections if there are services that
420
-    # require them running on the host. The ensures that n-cpu doesn't
419
+    # only setup database connections and cache backend if there are services
420
+    # that require them running on the host. The ensures that n-cpu doesn't
421 421
     # leak a need to use the db in a multinode scenario.
422 422
     if is_service_enabled n-api n-cond n-sched; then
423 423
         # If we're in multi-tier cells mode, we want our control services pointing
... ...
@@ -434,6 +435,13 @@ function create_nova_conf {
434 434
 
435 435
         iniset $NOVA_CONF database connection `database_connection_url $db`
436 436
         iniset $NOVA_CONF api_database connection `database_connection_url nova_api`
437
+
438
+        # Cache related settings
439
+        # Those settings aren't really needed in n-cpu thus it is configured
440
+        # only on nodes which runs controller services
441
+        iniset $NOVA_CONF cache enabled $NOVA_ENABLE_CACHE
442
+        iniset $NOVA_CONF cache backend $CACHE_BACKEND
443
+        iniset $NOVA_CONF cache memcache_servers $MEMCACHE_SERVERS
437 444
     fi
438 445
 
439 446
     if is_service_enabled n-api; then
... ...
@@ -770,6 +770,10 @@ ETCD_DOWNLOAD_LOCATION=$ETCD_DOWNLOAD_URL/$ETCD_VERSION/$ETCD_DOWNLOAD_FILE
770 770
 # etcd is always required, so place it into list of pre-cached downloads
771 771
 EXTRA_CACHE_URLS+=",$ETCD_DOWNLOAD_LOCATION"
772 772
 
773
+# Cache settings
774
+CACHE_BACKEND=${CACHE_BACKEND:-"dogpile.cache.memcached"}
775
+MEMCACHE_SERVERS=${MEMCACHE_SERVERS:-"localhost:11211"}
776
+
773 777
 # Detect duplicate values in IMAGE_URLS
774 778
 for image_url in ${IMAGE_URLS//,/ }; do
775 779
     if [ $(echo "$IMAGE_URLS" | grep -o -F "$image_url" | wc -l) -gt 1 ]; then