summaryrefslogtreecommitdiffstats
path: root/roles
diff options
context:
space:
mode:
authorRussell Teague <rteague@redhat.com>2017-02-23 07:35:28 -0500
committerGitHub <noreply@github.com>2017-02-23 07:35:28 -0500
commita395b2b4d6cfd65e1a2fb45a75d72a0c1d9c65bc (patch)
tree9e75faf82e244ba47ea2d0b1ba1c474d4dfa40e9 /roles
parentf0a32af0548eb309b9bb3bb2c366d35bdfab1847 (diff)
parent8bae101397360cdcc5e1d66d241c98b59f377633 (diff)
downloadopenshift-a395b2b4d6cfd65e1a2fb45a75d72a0c1d9c65bc.tar.gz
openshift-a395b2b4d6cfd65e1a2fb45a75d72a0c1d9c65bc.tar.bz2
openshift-a395b2b4d6cfd65e1a2fb45a75d72a0c1d9c65bc.tar.xz
openshift-a395b2b4d6cfd65e1a2fb45a75d72a0c1d9c65bc.zip
Merge pull request #3460 from kwoodson/handle_router_prep
Handle router preparation errors. Also added a second sleep timer for creating openshift objects.
Diffstat (limited to 'roles')
-rw-r--r--roles/lib_openshift/library/oc_adm_router.py27
-rw-r--r--roles/lib_openshift/src/class/oc_adm_router.py27
2 files changed, 40 insertions, 14 deletions
diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py
index 324b87f84..445279ed1 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
@@ -2664,8 +2667,8 @@ 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']:
+ # pylint: disable=maybe-no-member
+ if results['returncode'] != 0 or 'items' not in results['results']:
return results
oc_objects = {'DeploymentConfig': {'obj': None, 'path': None, 'update': False},
@@ -2702,12 +2705,22 @@ 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 = []
- # pylint: disable=no-member
+ import time
+ # pylint: disable=maybe-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
@@ -2721,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 ab7c96927..66769e73b 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
@@ -212,8 +215,8 @@ 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']:
+ # pylint: disable=maybe-no-member
+ if results['returncode'] != 0 or 'items' not in results['results']:
return results
oc_objects = {'DeploymentConfig': {'obj': None, 'path': None, 'update': False},
@@ -250,12 +253,22 @@ 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 = []
- # pylint: disable=no-member
+ import time
+ # pylint: disable=maybe-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
@@ -269,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']))