From e089f74edc79a31117a49d3f84519974787f31f0 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Tue, 6 Jun 2017 00:39:35 -0500 Subject: oc_obj: only check 'items' if exists in delete Signed-off-by: Jose A. Rivera --- roles/lib_openshift/library/oc_obj.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'roles/lib_openshift/library') diff --git a/roles/lib_openshift/library/oc_obj.py b/roles/lib_openshift/library/oc_obj.py index 215723cc8..c63441aa3 100644 --- a/roles/lib_openshift/library/oc_obj.py +++ b/roles/lib_openshift/library/oc_obj.py @@ -1557,7 +1557,8 @@ class OCObject(OpenShiftCLI): if state == 'absent': # verify its not in our results if (params['name'] is not None or params['selector'] is not None) and \ - (len(api_rval['results']) == 0 or len(api_rval['results'][0].get('items', [])) == 0): + (len(api_rval['results']) == 0 or \ + ('items' in api_rval['results'][0] and len(api_rval['results'][0]['items']) == 0)): return {'changed': False, 'state': state} if check_mode: -- cgit v1.2.3 From 3aea760737835070b761114f2909649795d6f6e9 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Sat, 3 Jun 2017 11:02:39 -0500 Subject: oc_obj: set _delete() rc to 0 if err is 'not found' When deleting multiple objects, allow for some resources to already be absent. Signed-off-by: Jose A. Rivera --- roles/lib_openshift/library/oc_obj.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'roles/lib_openshift/library') diff --git a/roles/lib_openshift/library/oc_obj.py b/roles/lib_openshift/library/oc_obj.py index c63441aa3..5b1039385 100644 --- a/roles/lib_openshift/library/oc_obj.py +++ b/roles/lib_openshift/library/oc_obj.py @@ -1473,7 +1473,12 @@ class OCObject(OpenShiftCLI): def delete(self): '''delete the object''' - return self._delete(self.kind, name=self.name, selector=self.selector) + results = self._delete(self.kind, name=self.name, selector=self.selector) + if (results['returncode'] != 0 and 'stderr' in results and + '\"{}\" not found'.format(self.name) in results['stderr']): + results['returncode'] = 0 + + return results def create(self, files=None, content=None): ''' -- cgit v1.2.3