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 ++++++- roles/lib_openshift/src/class/oc_obj.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'roles/lib_openshift') 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): ''' diff --git a/roles/lib_openshift/src/class/oc_obj.py b/roles/lib_openshift/src/class/oc_obj.py index d480bfaf0..5e423bea9 100644 --- a/roles/lib_openshift/src/class/oc_obj.py +++ b/roles/lib_openshift/src/class/oc_obj.py @@ -33,7 +33,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