diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2017-07-14 08:59:02 -0400 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2017-07-14 09:03:23 -0400 |
commit | f51e0082fe17f14aec5e14facc143986f47cf260 (patch) | |
tree | d8951d26f4f0242a92faa859cf1e6a339ae99c47 /roles/lib_openshift/library | |
parent | d3cd981326c98984117ae6fd768d63c39257de69 (diff) | |
download | openshift-f51e0082fe17f14aec5e14facc143986f47cf260.tar.gz openshift-f51e0082fe17f14aec5e14facc143986f47cf260.tar.bz2 openshift-f51e0082fe17f14aec5e14facc143986f47cf260.tar.xz openshift-f51e0082fe17f14aec5e14facc143986f47cf260.zip |
Fixing needs_update comparison. Added a small pause for race conditions. Fixed doc. Fix kind to storageclass
Diffstat (limited to 'roles/lib_openshift/library')
-rw-r--r-- | roles/lib_openshift/library/oc_storageclass.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/roles/lib_openshift/library/oc_storageclass.py b/roles/lib_openshift/library/oc_storageclass.py index fa5a1ab15..5ca2e23a7 100644 --- a/roles/lib_openshift/library/oc_storageclass.py +++ b/roles/lib_openshift/library/oc_storageclass.py @@ -130,7 +130,7 @@ EXAMPLES = ''' encrypted: 'true' kmsKeyId: '<full kms key arn>' provisioner: aws-ebs - default_sc: False + default_storage_class: False register: sc_out notify: - restart openshift master services @@ -1430,7 +1430,7 @@ class StorageClassConfig(object): provisioner=None, parameters=None, annotations=None, - default_sc="false", + default_storage_class="false", api_version='v1', kubeconfig='/etc/origin/master/admin.kubeconfig'): ''' constructor for handling storageclass options ''' @@ -1439,7 +1439,7 @@ class StorageClassConfig(object): self.annotations = annotations self.provisioner = provisioner self.api_version = api_version - self.default_sc = default_sc + self.default_storage_class = str(default_storage_class).lower() self.kubeconfig = kubeconfig self.data = {} @@ -1453,7 +1453,10 @@ class StorageClassConfig(object): self.data['metadata']['name'] = self.name self.data['metadata']['annotations'] = {} - self.data['metadata']['annotations']['storageclass.beta.kubernetes.io/is-default-class'] = self.default_sc + if self.annotations is not None: + self.data['metadata']['annotations'] = self.annotations + + self.data['metadata']['annotations']['storageclass.beta.kubernetes.io/is-default-class'] = self.default_storage_class if self.provisioner is None: self.data['provisioner'] = 'kubernetes.io/aws-ebs' @@ -1497,7 +1500,7 @@ class StorageClass(Yedit): # 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 @@ -1539,15 +1542,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 - 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 False @staticmethod # pylint: disable=too-many-return-statements,too-many-branches @@ -1560,7 +1570,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'], ) |