From 4674b03661d3b80c5e9591a9f068b4da57b23643 Mon Sep 17 00:00:00 2001
From: Cedric Hnyda <cedric.hnyda@itera.io>
Date: Tue, 1 Jun 2021 16:10:27 +0200
Subject: [PATCH] Add cinder_csi_ignore_volume_az (#7624)

Signed-off-by: Cedric Hnyda <cedric.hnyda@itera.io>
---
 docs/openstack.md                                           | 6 ++++++
 .../csi_driver/cinder/templates/cinder-csi-cloud-config.j2  | 5 ++++-
 roles/kubespray-defaults/defaults/main.yaml                 | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/docs/openstack.md b/docs/openstack.md
index d15a3ef9c..3145eaab0 100644
--- a/docs/openstack.md
+++ b/docs/openstack.md
@@ -104,6 +104,12 @@ The new cloud provider is configured to have Octavia by default in Kubespray.
   cinder_topology: true
   ```
 
+- Enabling `cinder_csi_ignore_volume_az: true`, ignores volumeAZ and schedules on any of the available node AZ.
+
+  ```yaml
+  cinder_csi_ignore_volume_az: true
+  ```
+
 - If you are using OpenStack loadbalancer(s) replace the `openstack_lbaas_subnet_id` with the new `external_openstack_lbaas_subnet_id`. **Note** The new cloud provider is using Octavia instead of Neutron LBaaS by default!
 - Enable 3 feature gates to allow migration of all volumes and storage classes (if you have any feature gates already set just add the 3 listed below):
 
diff --git a/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2 b/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2
index c595bb694..025a5144a 100644
--- a/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2
+++ b/roles/kubernetes-apps/csi_driver/cinder/templates/cinder-csi-cloud-config.j2
@@ -22,6 +22,9 @@ ca-file="{{ kube_config_dir }}/cinder-cacert.pem"
 {% if cinder_blockstorage_version is defined %}
 bs-version={{ cinder_blockstorage_version }}
 {% endif %}
+{% if cinder_csi_ignore_volume_az is defined %}
+ignore-volume-az={{ cinder_csi_ignore_volume_az | bool }}
+{% endif %}
 {% if node_volume_attach_limit is defined and node_volume_attach_limit != "" %}
 node-volume-attach-limit="{{ node_volume_attach_limit }}"
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml
index b7ab8a95d..8a62b51c9 100644
--- a/roles/kubespray-defaults/defaults/main.yaml
+++ b/roles/kubespray-defaults/defaults/main.yaml
@@ -375,6 +375,7 @@ openstack_blockstorage_ignore_volume_az: "{{ volume_cross_zone_attachment | defa
 # Set Cinder topology zones (can be multiple zones, default not set)
 # cinder_topology_zones:
 #   - nova
+cinder_csi_ignore_volume_az: "{{ volume_cross_zone_attachment | default('false') }}"
 
 ## When OpenStack is used, if LBaaSv2 is available you can enable it with the following 2 variables.
 openstack_lbaas_enabled: false
-- 
GitLab