diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index c6c94284b5..e2e5c9a5f4 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -672,6 +672,7 @@ openstack_auth: glance_backend_file: "{{ not (glance_backend_ceph | bool or glance_backend_swift | bool or glance_backend_vmware | bool) }}" glance_backend_ceph: "{{ enable_ceph }}" glance_backend_vmware: "no" +enable_glance_image_cache: "no" # ceph backend has priority over swift in all-ceph clusters glance_backend_swift: "{{ not (enable_ceph | bool) and enable_swift | bool }}" glance_file_datadir_volume: "glance" diff --git a/ansible/roles/glance/defaults/main.yml b/ansible/roles/glance/defaults/main.yml index 8f1764a43f..2e87802c0a 100644 --- a/ansible/roles/glance/defaults/main.yml +++ b/ansible/roles/glance/defaults/main.yml @@ -151,7 +151,7 @@ openstack_glance_auth: "{{ openstack_auth }}" ################### # Kolla -#################### +################### glance_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}" glance_dev_repos_pull: "{{ kolla_dev_repos_pull }}" glance_dev_mode: "{{ kolla_dev_mode }}" @@ -162,3 +162,9 @@ glance_source_version: "{{ kolla_source_version }}" ################################################ vmware_vcenter_name: vmware_datastore_name: + +################### +# Glance cache +################### +# Default maximum size of 10Gb +glance_cache_max_size: "10737418240" diff --git a/ansible/roles/glance/handlers/main.yml b/ansible/roles/glance/handlers/main.yml index ff367fe997..96f66a638b 100644 --- a/ansible/roles/glance/handlers/main.yml +++ b/ansible/roles/glance/handlers/main.yml @@ -21,6 +21,7 @@ - inventory_hostname in glance_api_hosts - service.enabled | bool - config_json.changed | bool + or glance_cache_conf.changed | bool or glance_conf.changed | bool or glance_swift_conf.changed | bool or policy_overwriting.changed | bool diff --git a/ansible/roles/glance/tasks/config.yml b/ansible/roles/glance/tasks/config.yml index e7c459555f..5e1050fdd3 100644 --- a/ansible/roles/glance/tasks/config.yml +++ b/ansible/roles/glance/tasks/config.yml @@ -76,6 +76,26 @@ - Restart glance-api container - Restart glance-registry container +- name: Copying over glance-cache.conf for glance_api + vars: + glance_api: "{{ glance_services['glance-api'] }}" + merge_configs: + sources: + - "{{ role_path }}/templates/glance-cache.conf.j2" + - "{{ node_custom_config }}/glance-cache.conf" + - "{{ node_custom_config }}/glance/glance-cache.conf" + - "{{ node_custom_config }}/glance/{{ inventory_hostname }}/glance-cache.conf" + dest: "{{ node_config_directory }}/glance-api/glance-cache.conf" + mode: "0660" + become: true + register: glance_cache_conf + when: + - glance_api.enabled | bool + - inventory_hostname in groups[glance_api.group] + - enable_glance_image_cache | bool + notify: + - Restart glance-api container + - name: Copying over glance-swift.conf for glance_api vars: glance_api: "{{ glance_services['glance-api'] }}" diff --git a/ansible/roles/glance/templates/glance-api.conf.j2 b/ansible/roles/glance/templates/glance-api.conf.j2 index 5608c39106..ec5cd0fb97 100644 --- a/ansible/roles/glance/templates/glance-api.conf.j2 +++ b/ansible/roles/glance/templates/glance-api.conf.j2 @@ -19,6 +19,11 @@ cinder_catalog_info = volume:cinder:internalURL transport_url = {{ rpc_transport_url }} +{% if enable_glance_image_cache | bool %} +image_cache_max_size = {{ glance_cache_max_size }} +image_cache_dir = /var/lib/glance/image-cache +{% endif %} + [database] connection = mysql+pymysql://{{ glance_database_user }}:{{ glance_database_password }}@{{ glance_database_address }}/{{ glance_database_name }} max_retries = -1 @@ -38,7 +43,7 @@ memcache_secret_key = {{ memcache_secret_key }} memcached_servers = {% for host in groups['memcached'] %}{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }}:{{ memcached_port }}{% if not loop.last %},{% endif %}{% endfor %} [paste_deploy] -flavor = keystone +flavor = {% if enable_glance_image_cache | bool %}keystone+cachemanagement{% else %}keystone{% endif %} [glance_store] {% if glance_backend_vmware | bool %} diff --git a/ansible/roles/glance/templates/glance-api.json.j2 b/ansible/roles/glance/templates/glance-api.json.j2 index 89f330ae23..fd2bd70d62 100644 --- a/ansible/roles/glance/templates/glance-api.json.j2 +++ b/ansible/roles/glance/templates/glance-api.json.j2 @@ -24,6 +24,12 @@ "dest": "/etc/glance/glance-swift.conf", "owner": "glance", "perm": "0600" + }{% endif %}{% if enable_glance_image_cache | bool %}, + { + "source": "{{ container_config_directory }}/glance-cache.conf", + "dest": "/etc/glance/glance-cache.conf", + "owner": "glance", + "perm": "0600" }{% endif %} ], "permissions": [ diff --git a/ansible/roles/glance/templates/glance-cache.conf.j2 b/ansible/roles/glance/templates/glance-cache.conf.j2 new file mode 100644 index 0000000000..66aef9b590 --- /dev/null +++ b/ansible/roles/glance/templates/glance-cache.conf.j2 @@ -0,0 +1,19 @@ +[DEFAULT] + +debug = {{ glance_logging_debug }} +log_file = /var/log/kolla/glance/glance-cache.log + +image_cache_max_size = {{ glance_cache_max_size }} +image_cache_dir = /var/lib/glance/image-cache + +auth_url = {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }} +admin_password = {{ glance_keystone_password }} +admin_user = {{ glance_keystone_user }} +admin_tenant_name = {{ default_project_domain_id }} + +registry_host = {{ api_interface_address }} +registry_port = {{ glance_registry_port }} + +{% if glance_backend_file | bool %} +filesystem_store_datadir = /var/lib/glance/images/ +{% endif %} diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 8244143758..d159b45e07 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -346,6 +346,7 @@ kolla_internal_vip_address: "10.10.10.254" #glance_backend_file: "yes" #glance_backend_swift: "no" #glance_backend_vmware: "no" +#enable_glance_image_cache: "no" # Configure glance upgrade option, due to this feature is experimental # in glance, so default value should be set to "no". glance_enable_rolling_upgrade: "no" diff --git a/releasenotes/notes/glance-cache-ecf950ba3e9136b1.yaml b/releasenotes/notes/glance-cache-ecf950ba3e9136b1.yaml new file mode 100644 index 0000000000..190e2169f5 --- /dev/null +++ b/releasenotes/notes/glance-cache-ecf950ba3e9136b1.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Add support to configure glance-cache, enabled with + ``enable_glance_image_cache`` and configure cache size + with ``glance_cache_max_size``.