Browse Source

Fix storageclass setting for NFS

There's three settings for storageClass now:

* _storageclass set: setting storageClass in PVC
* kind='nfs': storageClass in PVC is set to ''
* kind='dynamic': storageClass is omitted
Vadim Rutkovsky 6 years ago
parent
commit
4f390fe5b5

+ 6 - 1
roles/lib_utils/action_plugins/generate_pv_pvcs_list.py

@@ -150,10 +150,15 @@ class ActionModule(ActionBase):
                     if kind != 'object' and create_pv and create_pvc:
                         volume, size, _, annotations, access_modes = self.build_common(varname=varname)
                         storageclass = self.task_vars.get(str(varname) + '_storageclass')
+                        # if storageclass is specified => use it
+                        # if kind is 'nfs' => set to empty
+                        # if any other kind => set to none
                         if storageclass:
                             storageclass = self._templar.template(storageclass)
-                        elif storageclass is None and kind != 'dynamic':
+                        elif kind == 'nfs':
                             storageclass = ''
+                        if kind == 'dynamic':
+                            storageclass = None
                         return dict(
                             name="{0}-claim".format(volume),
                             capacity=size,

+ 1 - 1
roles/openshift_persistent_volumes/templates/persistent-volume-claim.yml.j2

@@ -18,7 +18,7 @@ items:
     resources:
       requests:
         storage: "{{ claim.capacity }}"
-{% if claim.storageclass|length > 0 %}
+{% if claim.storageclass %}
     storageClassName: "{{ claim.storageclass }}"
 {% endif %}
 {% endfor %}