From 50fa8cd61d47e8a3e3ab4a670fc173a0cfba5bc3 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 22 Feb 2017 16:36:18 -0500 Subject: Attempt to handle router preparation errors. --- roles/lib_openshift/library/oc_adm_router.py | 11 ++++++++--- roles/lib_openshift/src/class/oc_adm_router.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'roles') diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py index 324b87f84..ef4483c3c 100644 --- a/roles/lib_openshift/library/oc_adm_router.py +++ b/roles/lib_openshift/library/oc_adm_router.py @@ -2501,8 +2501,11 @@ class Router(OpenShiftCLI): ''' property for the prepared router''' if self.__prepared_router is None: results = self._prepare_router() - if not results: - raise RouterException('Could not perform router preparation') + if not results or 'returncode' in results and results['returncode'] != 0: + if 'stderr' in results: + raise RouterException('Could not perform router preparation: %s' % results['stderr']) + + raise RouterException('Could not perform router preparation.') self.__prepared_router = results return self.__prepared_router @@ -2665,7 +2668,7 @@ class Router(OpenShiftCLI): results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json') # pylint: disable=no-member - if results['returncode'] != 0 and 'items' in results['results']: + if results['returncode'] != 0 or 'items' not in results['results']: return results oc_objects = {'DeploymentConfig': {'obj': None, 'path': None, 'update': False}, @@ -2705,9 +2708,11 @@ class Router(OpenShiftCLI): '''Create a deploymentconfig ''' results = [] + import time # pylint: disable=no-member for _, oc_data in self.prepared_router.items(): if oc_data['obj'] is not None: + time.sleep(1) results.append(self._create(oc_data['path'])) rval = 0 diff --git a/roles/lib_openshift/src/class/oc_adm_router.py b/roles/lib_openshift/src/class/oc_adm_router.py index ab7c96927..899456945 100644 --- a/roles/lib_openshift/src/class/oc_adm_router.py +++ b/roles/lib_openshift/src/class/oc_adm_router.py @@ -49,8 +49,11 @@ class Router(OpenShiftCLI): ''' property for the prepared router''' if self.__prepared_router is None: results = self._prepare_router() - if not results: - raise RouterException('Could not perform router preparation') + if not results or 'returncode' in results and results['returncode'] != 0: + if 'stderr' in results: + raise RouterException('Could not perform router preparation: %s' % results['stderr']) + + raise RouterException('Could not perform router preparation.') self.__prepared_router = results return self.__prepared_router @@ -213,7 +216,7 @@ class Router(OpenShiftCLI): results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json') # pylint: disable=no-member - if results['returncode'] != 0 and 'items' in results['results']: + if results['returncode'] != 0 or 'items' not in results['results']: return results oc_objects = {'DeploymentConfig': {'obj': None, 'path': None, 'update': False}, @@ -253,9 +256,11 @@ class Router(OpenShiftCLI): '''Create a deploymentconfig ''' results = [] + import time # pylint: disable=no-member for _, oc_data in self.prepared_router.items(): if oc_data['obj'] is not None: + time.sleep(1) results.append(self._create(oc_data['path'])) rval = 0 -- cgit v1.2.3 From 8bae101397360cdcc5e1d66d241c98b59f377633 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 22 Feb 2017 16:59:45 -0500 Subject: Updated for pylint. Fixed create doc. --- roles/lib_openshift/library/oc_adm_router.py | 16 ++++++++++++---- roles/lib_openshift/src/class/oc_adm_router.py | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'roles') diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py index ef4483c3c..445279ed1 100644 --- a/roles/lib_openshift/library/oc_adm_router.py +++ b/roles/lib_openshift/library/oc_adm_router.py @@ -2667,7 +2667,7 @@ class Router(OpenShiftCLI): results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json') - # pylint: disable=no-member + # pylint: disable=maybe-no-member if results['returncode'] != 0 or 'items' not in results['results']: return results @@ -2705,11 +2705,19 @@ class Router(OpenShiftCLI): return oc_objects def create(self): - '''Create a deploymentconfig ''' + '''Create a router + + This includes the different parts: + - deploymentconfig + - service + - serviceaccount + - secrets + - clusterrolebinding + ''' results = [] import time - # pylint: disable=no-member + # pylint: disable=maybe-no-member for _, oc_data in self.prepared_router.items(): if oc_data['obj'] is not None: time.sleep(1) @@ -2726,7 +2734,7 @@ class Router(OpenShiftCLI): '''run update for the router. This performs a replace''' results = [] - # pylint: disable=no-member + # pylint: disable=maybe-no-member for _, oc_data in self.prepared_router.items(): if oc_data['update']: results.append(self._replace(oc_data['path'])) diff --git a/roles/lib_openshift/src/class/oc_adm_router.py b/roles/lib_openshift/src/class/oc_adm_router.py index 899456945..66769e73b 100644 --- a/roles/lib_openshift/src/class/oc_adm_router.py +++ b/roles/lib_openshift/src/class/oc_adm_router.py @@ -215,7 +215,7 @@ class Router(OpenShiftCLI): results = self.openshift_cmd(cmd, oadm=True, output=True, output_type='json') - # pylint: disable=no-member + # pylint: disable=maybe-no-member if results['returncode'] != 0 or 'items' not in results['results']: return results @@ -253,11 +253,19 @@ class Router(OpenShiftCLI): return oc_objects def create(self): - '''Create a deploymentconfig ''' + '''Create a router + + This includes the different parts: + - deploymentconfig + - service + - serviceaccount + - secrets + - clusterrolebinding + ''' results = [] import time - # pylint: disable=no-member + # pylint: disable=maybe-no-member for _, oc_data in self.prepared_router.items(): if oc_data['obj'] is not None: time.sleep(1) @@ -274,7 +282,7 @@ class Router(OpenShiftCLI): '''run update for the router. This performs a replace''' results = [] - # pylint: disable=no-member + # pylint: disable=maybe-no-member for _, oc_data in self.prepared_router.items(): if oc_data['update']: results.append(self._replace(oc_data['path'])) -- cgit v1.2.3