Set default TTL for memcache item expiration

Fixes: PROD-26960

Change-Id: I8880277c1c0fa3b6cbea1c26fcdf09d13b92a5e8
(cherry picked from commit 25b53070d6d625c58fb4a92728130b6122caae98)

Enable default TTL for memcache item expiration

Includes oslo_templates/files/queens/oslo/_cache.conf file
in the [cache] section of nova.conf

Change-Id: I7e6ed812cc95cb492b255171c12314d89a8343de
Related-Prod: PROD-26960
(cherry picked from commit 068f1534282f5f1d0a8be86c9425e6e5a20d48f4)
diff --git a/metadata/service/compute/cluster.yml b/metadata/service/compute/cluster.yml
index 9e6e485..8934022 100644
--- a/metadata/service/compute/cluster.yml
+++ b/metadata/service/compute/cluster.yml
@@ -64,6 +64,13 @@
         port: 9696
       cache:
         engine: memcached
+        # NOTE (dukov) Do not change this unless you 100% sure what you are doing
+        expiration_time: 600
+        backend_argument:
+          # NOTE (dukov) WARNING! This parameter depends on expiration_time.
+          # Value of 'memcached_expire_time' must be bigger than 'expiration_time'
+          memcached_expire_time:
+            value: 660
         members:
         - host: ${_param:cluster_node01_address}
           port: 11211
diff --git a/metadata/service/compute/kvm.yml b/metadata/service/compute/kvm.yml
index 0a1925b..4174b56 100644
--- a/metadata/service/compute/kvm.yml
+++ b/metadata/service/compute/kvm.yml
@@ -61,6 +61,13 @@
         port: 9696
       cache:
         engine: memcached
+        # NOTE (dukov) Do not change this unless you 100% sure what you are doing
+        expiration_time: 600
+        backend_argument:
+          # NOTE (dukov) WARNING! This parameter depends on expiration_time.
+          # Value of 'memcached_expire_time' must be bigger than 'expiration_time'
+          memcached_expire_time:
+            value: 660
         members:
         - host: ${_param:cluster_node01_address}
           port: 11211
diff --git a/metadata/service/control/cluster.yml b/metadata/service/control/cluster.yml
index 2e17d93..fa271ff 100644
--- a/metadata/service/control/cluster.yml
+++ b/metadata/service/control/cluster.yml
@@ -73,6 +73,13 @@
         password: metadataPass
       cache:
         engine: memcached
+        # NOTE (dukov) Do not change this unless you 100% sure what you are doing
+        expiration_time: 600
+        backend_argument:
+          # NOTE (dukov) WARNING! This parameter depends on expiration_time.
+          # Value of 'memcached_expire_time' must be bigger than 'expiration_time'
+          memcached_expire_time:
+            value: 660
         members:
         - host: ${_param:cluster_node01_address}
           port: 11211
diff --git a/metadata/service/control/single.yml b/metadata/service/control/single.yml
index c525974..5030462 100644
--- a/metadata/service/control/single.yml
+++ b/metadata/service/control/single.yml
@@ -74,6 +74,13 @@
         password: ${_param:metadata_password}
       cache:
         engine: memcached
+        # NOTE (dukov) Do not change this unless you 100% sure what you are doing
+        expiration_time: 600
+        backend_argument:
+          # NOTE (dukov) WARNING! This parameter depends on expiration_time.
+          # Value of 'memcached_expire_time' must be bigger than 'expiration_time'
+          memcached_expire_time:
+            value: 660
         members:
         - host: ${_param:single_address}
           port: 11211
diff --git a/nova/files/queens/nova-compute.conf.Debian b/nova/files/queens/nova-compute.conf.Debian
index 54dfd87..869bd94 100644
--- a/nova/files/queens/nova-compute.conf.Debian
+++ b/nova/files/queens/nova-compute.conf.Debian
@@ -3731,97 +3731,11 @@
 
 [cache]
 
-#
-# From nova.conf
-#
 {%- if compute.cache is defined %}
-backend = oslo_cache.memcache_pool
-enabled = true
-memcache_servers={%- for member in compute.cache.members %}{{ member.host }}:11211{% if not loop.last %},{% endif %}{%- endfor %}
+{%- set _data = compute.cache %}
+{%- include "oslo_templates/files/queens/oslo/_cache.conf" %}
 {%- endif %}
 
-# Prefix for building the configuration dictionary for the cache
-# region. This should not need to be changed unless there is another
-# dogpile.cache region with the same configuration name. (string
-# value)
-#config_prefix = cache.oslo
-
-# Default TTL, in seconds, for any cached item in the dogpile.cache
-# region. This applies to any cached method that doesn't have an
-# explicit cache expiration time defined for it. (integer value)
-#expiration_time = 600
-
-# Cache backend module. For eventlet-based or environments with
-# hundreds of threaded servers, Memcache with pooling
-# (oslo_cache.memcache_pool) is recommended. For environments with
-# less than 100 threaded servers, Memcached (dogpile.cache.memcached)
-# or Redis (dogpile.cache.redis) is recommended. Test environments
-# with a single instance of the server can use the
-# dogpile.cache.memory backend. (string value)
-# Possible values:
-# oslo_cache.memcache_pool - <No description provided>
-# oslo_cache.dict - <No description provided>
-# oslo_cache.mongo - <No description provided>
-# oslo_cache.etcd3gw - <No description provided>
-# dogpile.cache.memcached - <No description provided>
-# dogpile.cache.pylibmc - <No description provided>
-# dogpile.cache.bmemcached - <No description provided>
-# dogpile.cache.dbm - <No description provided>
-# dogpile.cache.redis - <No description provided>
-# dogpile.cache.memory - <No description provided>
-# dogpile.cache.memory_pickle - <No description provided>
-# dogpile.cache.null - <No description provided>
-#backend = dogpile.cache.null
-
-# Arguments supplied to the backend module. Specify this option once
-# per argument to be passed to the dogpile.cache backend. Example
-# format: "<argname>:<value>". (multi valued)
-#backend_argument =
-
-# Proxy classes to import that will affect the way the dogpile.cache
-# backend functions. See the dogpile.cache documentation on changing-
-# backend-behavior. (list value)
-#proxies =
-
-# Global toggle for caching. (boolean value)
-#enabled = false
-
-# Extra debugging from the cache backend (cache keys,
-# get/set/delete/etc calls). This is only really useful if you need to
-# see the specific cache-backend get/set/delete calls with the
-# keys/values.  Typically this should be left set to false. (boolean
-# value)
-#debug_cache_backend = false
-
-# Memcache servers in the format of "host:port".
-# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
-# (list value)
-#memcache_servers = localhost:11211
-
-# Number of seconds memcached server is considered dead before it is
-# tried again. (dogpile.cache.memcache and oslo_cache.memcache_pool
-# backends only). (integer value)
-#memcache_dead_retry = 300
-
-# Timeout in seconds for every call to a server.
-# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
-# (integer value)
-#memcache_socket_timeout = 3
-
-# Max total number of open connections to every memcached server.
-# (oslo_cache.memcache_pool backend only). (integer value)
-#memcache_pool_maxsize = 10
-
-# Number of seconds a connection to memcached is held unused in the
-# pool before it is closed. (oslo_cache.memcache_pool backend only).
-# (integer value)
-#memcache_pool_unused_timeout = 60
-
-# Number of seconds that an operation will wait to get a memcache
-# client connection. (integer value)
-#memcache_pool_connection_get_timeout = 10
-
-
 [cells]
 #
 # DEPRECATED: Cells options allow you to use cells v1 functionality in
diff --git a/nova/files/queens/nova-controller.conf.Debian b/nova/files/queens/nova-controller.conf.Debian
index fbf978b..c90b047 100644
--- a/nova/files/queens/nova-controller.conf.Debian
+++ b/nova/files/queens/nova-controller.conf.Debian
@@ -3729,96 +3729,11 @@
 
 [cache]
 
-#
-# From nova.conf
-#
 {%- if controller.cache is defined %}
-backend = oslo_cache.memcache_pool
-enabled = true
-memcache_servers={%- for member in controller.cache.members %}{{ member.host }}:11211{% if not loop.last %},{% endif %}{%- endfor %}
+{%- set _data = controller.cache %}
+{%- include "oslo_templates/files/queens/oslo/_cache.conf" %}
 {%- endif %}
 
-# Prefix for building the configuration dictionary for the cache
-# region. This should not need to be changed unless there is another
-# dogpile.cache region with the same configuration name. (string
-# value)
-#config_prefix = cache.oslo
-
-# Default TTL, in seconds, for any cached item in the dogpile.cache
-# region. This applies to any cached method that doesn't have an
-# explicit cache expiration time defined for it. (integer value)
-#expiration_time = 600
-
-# Cache backend module. For eventlet-based or environments with
-# hundreds of threaded servers, Memcache with pooling
-# (oslo_cache.memcache_pool) is recommended. For environments with
-# less than 100 threaded servers, Memcached (dogpile.cache.memcached)
-# or Redis (dogpile.cache.redis) is recommended. Test environments
-# with a single instance of the server can use the
-# dogpile.cache.memory backend. (string value)
-# Possible values:
-# oslo_cache.memcache_pool - <No description provided>
-# oslo_cache.dict - <No description provided>
-# oslo_cache.mongo - <No description provided>
-# oslo_cache.etcd3gw - <No description provided>
-# dogpile.cache.memcached - <No description provided>
-# dogpile.cache.pylibmc - <No description provided>
-# dogpile.cache.bmemcached - <No description provided>
-# dogpile.cache.dbm - <No description provided>
-# dogpile.cache.redis - <No description provided>
-# dogpile.cache.memory - <No description provided>
-# dogpile.cache.memory_pickle - <No description provided>
-# dogpile.cache.null - <No description provided>
-#backend = dogpile.cache.null
-
-# Arguments supplied to the backend module. Specify this option once
-# per argument to be passed to the dogpile.cache backend. Example
-# format: "<argname>:<value>". (multi valued)
-#backend_argument =
-
-# Proxy classes to import that will affect the way the dogpile.cache
-# backend functions. See the dogpile.cache documentation on changing-
-# backend-behavior. (list value)
-#proxies =
-
-# Global toggle for caching. (boolean value)
-#enabled = false
-
-# Extra debugging from the cache backend (cache keys,
-# get/set/delete/etc calls). This is only really useful if you need to
-# see the specific cache-backend get/set/delete calls with the
-# keys/values.  Typically this should be left set to false. (boolean
-# value)
-#debug_cache_backend = false
-
-# Memcache servers in the format of "host:port".
-# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
-# (list value)
-#memcache_servers = localhost:11211
-
-# Number of seconds memcached server is considered dead before it is
-# tried again. (dogpile.cache.memcache and oslo_cache.memcache_pool
-# backends only). (integer value)
-#memcache_dead_retry = 300
-
-# Timeout in seconds for every call to a server.
-# (dogpile.cache.memcache and oslo_cache.memcache_pool backends only).
-# (integer value)
-#memcache_socket_timeout = 3
-
-# Max total number of open connections to every memcached server.
-# (oslo_cache.memcache_pool backend only). (integer value)
-#memcache_pool_maxsize = 10
-
-# Number of seconds a connection to memcached is held unused in the
-# pool before it is closed. (oslo_cache.memcache_pool backend only).
-# (integer value)
-#memcache_pool_unused_timeout = 60
-
-# Number of seconds that an operation will wait to get a memcache
-# client connection. (integer value)
-#memcache_pool_connection_get_timeout = 10
-
 
 [cells]
 #
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index 4988c0b..67e871a 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -67,6 +67,10 @@
       password: metadata
     cache:
       engine: memcached
+      expiration_time: 600
+      backend_argument:
+        memcached_expire_time:
+          value: 660
       members:
       - host: 127.0.0.1
         port: 11211
diff --git a/tests/pillar/compute_cluster_vmware.sls b/tests/pillar/compute_cluster_vmware.sls
index 8953178..80954dd 100644
--- a/tests/pillar/compute_cluster_vmware.sls
+++ b/tests/pillar/compute_cluster_vmware.sls
@@ -56,6 +56,10 @@
       password: metadata
     cache:
       engine: memcached
+      expiration_time: 600
+      backend_argument:
+        memcached_expire_time:
+          value: 660
       members:
       - host: 127.0.0.1
         port: 11211
diff --git a/tests/pillar/compute_cluster_vmware_queens.sls b/tests/pillar/compute_cluster_vmware_queens.sls
index b704198..006dc1a 100644
--- a/tests/pillar/compute_cluster_vmware_queens.sls
+++ b/tests/pillar/compute_cluster_vmware_queens.sls
@@ -56,6 +56,10 @@
       password: metadata
     cache:
       engine: memcached
+      expiration_time: 600
+      backend_argument:
+        memcached_expire_time:
+          value: 660
       members:
       - host: 127.0.0.1
         port: 11211
diff --git a/tests/pillar/compute_single.sls b/tests/pillar/compute_single.sls
index c2b740a..f92fa3b 100644
--- a/tests/pillar/compute_single.sls
+++ b/tests/pillar/compute_single.sls
@@ -57,6 +57,10 @@
       password: password
     cache:
       engine: memcached
+      expiration_time: 600
+      backend_argument:
+        memcached_expire_time:
+          value: 660
       members:
       - host: 127.0.0.1
         port: 11211
diff --git a/tests/pillar/compute_single_config_drive_options.sls b/tests/pillar/compute_single_config_drive_options.sls
index 739f876..b64ea64 100644
--- a/tests/pillar/compute_single_config_drive_options.sls
+++ b/tests/pillar/compute_single_config_drive_options.sls
@@ -55,6 +55,10 @@
       password: password
     cache:
       engine: memcached
+      expiration_time: 600
+      backend_argument:
+        memcached_expire_time:
+          value: 660
       members:
       - host: 127.0.0.1
         port: 11211
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index 443e821..0872296 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -74,6 +74,10 @@
       password: password
     cache:
       engine: memcached
+      expiration_time: 600
+      backend_argument:
+        memcached_expire_time:
+          value: 660
       members:
       - host: 127.0.0.1
         port: 11211