From 8c431e600b521c621a5dc42a3b3ff3ac8bacc14e Mon Sep 17 00:00:00 2001 From: "William A. Lynch" Date: Sun, 15 Dec 2019 13:24:17 -0600 Subject: [PATCH] Ignore ServiceUnavailableError for an all resource group search There are situations where a given api service unrelated to the requested resource is unavailable and an ServiceUnavailableError exception is thrown. The change in this PR will allow resources to be found if the resource being requested is unrelated to an api service that is unavailable. Resolves https://github.com/openshift/openshift-restclient-python/issues/349 --- openshift/dynamic/discovery.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openshift/dynamic/discovery.py b/openshift/dynamic/discovery.py index b7b069f9..a683d0a1 100644 --- a/openshift/dynamic/discovery.py +++ b/openshift/dynamic/discovery.py @@ -9,7 +9,7 @@ from urllib3.exceptions import ProtocolError, MaxRetryError from openshift import __version__ -from .exceptions import ResourceNotFoundError, ResourceNotUniqueError, ApiException +from .exceptions import ResourceNotFoundError, ResourceNotUniqueError, ApiException, ServiceUnavailableError from .resource import Resource, ResourceList @@ -182,7 +182,10 @@ def get_resources_for_api_version(self, prefix, group, version, preferred): subresources = {} path = '/'.join(filter(None, [prefix, group, version])) - resources_response = self.client.request('GET', path).resources or [] + try: + resources_response = self.client.request('GET', path).resources or [] + except ServiceUnavailableError: + resources_response = [] resources_raw = list(filter(lambda resource: '/' not in resource['name'], resources_response)) subresources_raw = list(filter(lambda resource: '/' in resource['name'], resources_response))