Browse Source

fix: k8s api 500 (#10209)

Co-authored-by: feng <1304903146@qq.com>
pull/10210/head
fit2bot 2 years ago committed by GitHub
parent
commit
e0f077b054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      apps/assets/utils/k8s.py

9
apps/assets/utils/k8s.py

@ -4,6 +4,7 @@ from urllib.parse import urlencode
from kubernetes import client
from kubernetes.client import api_client
from kubernetes.client.api import core_v1_api
from kubernetes.client.exceptions import ApiException
from common.utils import get_logger
from ..const import CloudTypes, Category
@ -65,9 +66,13 @@ class KubernetesClient:
proxy_url = cls.get_proxy_url(asset)
k8s = cls(k8s_url, secret, proxy=proxy_url)
func_name = f'get_{tp}s'
data = []
if hasattr(k8s, func_name):
return getattr(k8s, func_name)(*args)
return []
try:
data = getattr(k8s, func_name)(*args)
except ApiException as e:
logger.error(e.reason)
return data
class KubernetesTree:

Loading…
Cancel
Save