Browse Source

devstack-plugin-glusterfs: Adding checks for error conditions

This patch introduces a new configuration parameter (knob)
CONFIGURE_GLUSTERFS_CINDER to enable/disable glusterfs as a
backend for Cinder. And added below error conditions:

* glusterfs plugin enabled but CONFIGURE_GLUSTERFS_CINDER set to
False
* CONFIGURE_GLUSTERFS_CINDER set to True, but CINDER_ENABLED_BACKENDS
doesn't have at least one backend of type glusterfs.

Change-Id: Ic802a2f2bbbdc1af04fd1220d2055be1e853fef8
Bharat Kumar Kobagana 3 years ago
parent
commit
995c1ee62f
2 changed files with 32 additions and 1 deletions
  1. 3
    1
      devstack/gluster-functions.sh
  2. 29
    0
      devstack/plugin.sh

+ 3
- 1
devstack/gluster-functions.sh View File

@@ -87,7 +87,9 @@ function cleanup_glusterfs {
87 87
     local vol_name
88 88
 
89 89
     # Cleaning up Cinder GlusterFS shares
90
-    _delete_gluster_shares $CINDER_GLUSTERFS_SHARES
90
+    if [ "$CONFIGURE_GLUSTERFS_CINDER" = "True" ]; then
91
+        _delete_gluster_shares $CINDER_GLUSTERFS_SHARES
92
+    fi
91 93
 
92 94
     if [[ -e ${GLUSTERFS_DISK_IMAGE} ]]; then
93 95
         sudo rm -f ${GLUSTERFS_DISK_IMAGE}

+ 29
- 0
devstack/plugin.sh View File

@@ -19,6 +19,35 @@
19 19
 # Defaults
20 20
 # --------
21 21
 
22
+# Set CONFIGURE_GLUSTERFS_CINDER to true, to enable GlusterFS as a backend for Cinder.
23
+CONFIGURE_GLUSTERFS_CINDER=${CONFIGURE_GLUSTERFS_CINDER:-True}
24
+
25
+# Error out when devstack-plugin-glusterfs is enabled, but not selected as a backend for cinder.
26
+if [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ]; then
27
+    echo "GlusterFS plugin enabled but not selected as a backend for Cinder."
28
+    echo "Please set CONFIGURE_GLUSTERFS_CINDER to True in localrc."
29
+    exit 1
30
+fi
31
+
32
+# When CONFIGURE_GLUSTERFS_CINDER is true, CINDER_ENABLED_BACKENDS should have
33
+# at least one backend of type 'glusterfs', error out otherwise.
34
+local is_gluster_backend_configured=False
35
+for be in ${CINDER_ENABLED_BACKENDS//,/ }; do
36
+    if [ "${be%%:*}" = "glusterfs" ]; then
37
+        is_gluster_backend_configured=True
38
+        break
39
+    fi
40
+done
41
+if [ "$CONFIGURE_GLUSTERFS_CINDER" = "True" ] && [ "$is_gluster_backend_configured" = "False" ]; then
42
+    echo "CONFIGURE_GLUSTERFS_CINDER is set to True, to configure GlusterFS as a backend for Cinder."
43
+    echo "But, glusterfs backend type not present in CINDER_ENABLED_BACKENDS."
44
+    echo "Please enable at least one backend of type glusterfs in CINDER_ENABLED_BACKENDS."
45
+    exit 1
46
+elif [ "$CONFIGURE_GLUSTERFS_CINDER" = "False" ] && [ "$is_gluster_backend_configured" = "True" ]; then
47
+    echo "Configured Glusterfs as backend type in CINDER_ENABLED_BACKENDS. But CONFIGURE_GLUSTERFS_CINDER set to False."
48
+    exit 1
49
+fi
50
+
22 51
 # GLUSTERFS_PLUGIN_DIR contains the path to devstack-plugin-glusterfs/devstack directory
23 52
 GLUSTERFS_PLUGIN_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
24 53
 

Loading…
Cancel
Save