From ef0deee5b0094c7af7519ed2ffea6ffc156f68a2 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Fri, 23 Feb 2024 12:14:10 +0100 Subject: [PATCH] cinder: Add prechecks and docs for HA/clustering Change-Id: I33a3ec11b0cdef94b08cd7551008284755824cb7 --- ansible/roles/cinder/defaults/main.yml | 6 +++++ ansible/roles/cinder/tasks/precheck.yml | 25 +++++++++++++++++++ ansible/roles/cinder/templates/cinder.conf.j2 | 4 +++ doc/source/reference/storage/cinder-guide.rst | 17 +++++++++++++ .../cinder-ha-precheck-ca93901f1362ac0d.yaml | 16 ++++++++++++ tests/templates/globals-default.j2 | 1 + 6 files changed, 69 insertions(+) create mode 100644 releasenotes/notes/cinder-ha-precheck-ca93901f1362ac0d.yaml diff --git a/ansible/roles/cinder/defaults/main.yml b/ansible/roles/cinder/defaults/main.yml index 1894a37b2b..298d1c6ca6 100644 --- a/ansible/roles/cinder/defaults/main.yml +++ b/ansible/roles/cinder/defaults/main.yml @@ -356,3 +356,9 @@ cinder_ks_user_roles: # TLS #################### cinder_enable_tls_backend: "{{ kolla_enable_tls_backend }}" + +############ +# Clustering +############ +cinder_cluster_name: "" +cinder_cluster_skip_precheck: false diff --git a/ansible/roles/cinder/tasks/precheck.yml b/ansible/roles/cinder/tasks/precheck.yml index c29ab8f885..3cedd91631 100644 --- a/ansible/roles/cinder/tasks/precheck.yml +++ b/ansible/roles/cinder/tasks/precheck.yml @@ -68,3 +68,28 @@ - cinder_backup_s3_access_key - cinder_backup_s3_secret_key when: cinder_backup_driver == "s3" + +- name: Check if cinder_cluster_name is configured for HA configurations + assert: + that: + - cinder_cluster_name != "" + msg: | + Multiple cinder-volume instances detected but cinder_cluster_name is not set- please see + https://docs.openstack.org/kolla-ansible/latest/reference/storage/cinder-guide.html#ha + for guidance. + when: + - not cinder_cluster_skip_precheck + - groups['cinder-volume'] | length > 1 + +- name: Check if cinder_cluster_name is configured and configuration is non-HA + assert: + that: + - cinder_cluster_name == "" + msg: | + Single cinder-volume instance detected but cinder_cluster_name is set (cluster + configuration will not be applied) - please see + https://docs.openstack.org/kolla-ansible/latest/reference/storage/cinder-guide.html#ha + for guidance. + when: + - not cinder_cluster_skip_precheck + - groups['cinder-volume'] | length == 1 diff --git a/ansible/roles/cinder/templates/cinder.conf.j2 b/ansible/roles/cinder/templates/cinder.conf.j2 index 6cde7a94e2..f5eaa9db18 100644 --- a/ansible/roles/cinder/templates/cinder.conf.j2 +++ b/ansible/roles/cinder/templates/cinder.conf.j2 @@ -20,6 +20,10 @@ glance_api_servers = {{ glance_internal_endpoint }} glance_num_retries = {{ groups['glance-api'] | length }} glance_ca_certificates_file = {{ openstack_cacert }} +{% if service_name == "cinder-volume" and cinder_cluster_name != "" %} +cluster = {{ cinder_cluster_name }} +{% endif %} + {% if cinder_enabled_backends %} enabled_backends = {{ cinder_enabled_backends|map(attribute='name')|join(',') }} {% endif %} diff --git a/doc/source/reference/storage/cinder-guide.rst b/doc/source/reference/storage/cinder-guide.rst index 55fc9f7d2e..578cde284f 100644 --- a/doc/source/reference/storage/cinder-guide.rst +++ b/doc/source/reference/storage/cinder-guide.rst @@ -16,6 +16,23 @@ backends: * lvm * nfs +HA +~~ + +When using cinder-volume in an HA configuration (more than one host in +cinder-volume/storage group): + +- Make sure that the driver you are using supports `Active/Active High Availability ` + configuration +- Add ``cinder_cluster_name: example_cluster_name`` to your ``globals.yml`` (or + host_vars for advanced multi-cluster configuration) + +.. note:: + + In case of non-standard configurations (e.g. mixed HA and non-HA Cinder backends), + you can skip the prechecks by setting ``cinder_cluster_skip_precheck`` to + ``true``. + LVM ~~~ diff --git a/releasenotes/notes/cinder-ha-precheck-ca93901f1362ac0d.yaml b/releasenotes/notes/cinder-ha-precheck-ca93901f1362ac0d.yaml new file mode 100644 index 0000000000..6b1fb6cfab --- /dev/null +++ b/releasenotes/notes/cinder-ha-precheck-ca93901f1362ac0d.yaml @@ -0,0 +1,16 @@ +--- +upgrade: + - | + A precheck for running Cinder HA has been introduced, which checks + for multiple cinder-volume instances and fails when ``cinder_cluster_name`` + is unset. For details on configuration guidelines please check the + `HA section of Cinder guide `_. + To disable the precheck please set ``cinder_cluster_skip_precheck`` to + ``true``. +features: + - | + A new variable ``cinder_cluster_name`` which controls the name of + cinder-volume High Availability cluster (for those backend drivers + that support it). + It replaces possible user-defined config overrides that already may have + implemented this feature. diff --git a/tests/templates/globals-default.j2 b/tests/templates/globals-default.j2 index c34f1ed9f1..896b43619c 100644 --- a/tests/templates/globals-default.j2 +++ b/tests/templates/globals-default.j2 @@ -141,6 +141,7 @@ enable_rabbitmq: "no" {% if scenario == "cephadm" %} # kolla-ansible vars enable_cinder: "yes" +cinder_cluster_name: "kolla_ceph" # External Ceph glance_backend_ceph: "yes" cinder_backend_ceph: "yes"