Browse Source

Merge pull request #3671 from abutcher/router-nodes

Merged by openshift-bot
OpenShift Bot 8 years ago
parent
commit
bf69e6ac42
1 changed files with 10 additions and 3 deletions
  1. 10 3
      roles/openshift_hosted/filter_plugins/filters.py

+ 10 - 3
roles/openshift_hosted/filter_plugins/filters.py

@@ -21,14 +21,21 @@ class FilterModule(object):
         if replicas is not None:
             return replicas
 
+        replicas = 1
+
+        # Ignore boolean expression limit of 5.
+        # pylint: disable=too-many-boolean-expressions
         if (isinstance(router_nodes, dict) and
                 'results' in router_nodes and
                 'results' in router_nodes['results'] and
-                'items' in router_nodes['results']['results']):
+                isinstance(router_nodes['results']['results'], list) and
+                len(router_nodes['results']['results']) > 0 and
+                'items' in router_nodes['results']['results'][0]):
 
-            return len(router_nodes['results']['results'][0]['items'])
+            if len(router_nodes['results']['results'][0]['items']) > 0:
+                replicas = len(router_nodes['results']['results'][0]['items'])
 
-        return 1
+        return replicas
 
     def filters(self):
         ''' returns a mapping of filters to methods '''