From f51e0082fe17f14aec5e14facc143986f47cf260 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Fri, 14 Jul 2017 08:59:02 -0400 Subject: Fixing needs_update comparison. Added a small pause for race conditions. Fixed doc. Fix kind to storageclass --- roles/lib_openshift/src/class/oc_storageclass.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'roles/lib_openshift/src/class') diff --git a/roles/lib_openshift/src/class/oc_storageclass.py b/roles/lib_openshift/src/class/oc_storageclass.py index 6c62c7bd8..ece684c56 100644 --- a/roles/lib_openshift/src/class/oc_storageclass.py +++ b/roles/lib_openshift/src/class/oc_storageclass.py @@ -4,7 +4,7 @@ # pylint: disable=too-many-instance-attributes class OCStorageClass(OpenShiftCLI): ''' Class to wrap the oc command line tools ''' - kind = 'sc' + kind = 'storageclass' # pylint allows 5 # pylint: disable=too-many-arguments @@ -46,15 +46,22 @@ class OCStorageClass(OpenShiftCLI): '''update the object''' # parameters are currently unable to be updated. need to delete and recreate self.delete() + # pause here and attempt to wait for delete. + # Better option would be to poll + time.sleep(5) return self.create() def needs_update(self): ''' verify an update is needed ''' # check if params have updated - if self.storage_class.get_parameters() == self.config.parameters: - return False + if self.storage_class.get_parameters() != self.config.parameters: + return True + + for anno_key, anno_value in self.storage_class.get_annotations().items(): + if 'is-default-class' in anno_key and anno_value != self.config.default_storage_class: + return True - return True + return False @staticmethod # pylint: disable=too-many-return-statements,too-many-branches @@ -67,7 +74,7 @@ class OCStorageClass(OpenShiftCLI): parameters=params['parameters'], annotations=params['annotations'], api_version="storage.k8s.io/{}".format(params['api_version']), - default_sc=params['default_storage_class'], + default_storage_class=params.get('default_storage_class', 'false'), kubeconfig=params['kubeconfig'], ) -- cgit v1.2.3