Ignore Failed Clusters #98

Open
opened 2 years ago by zoidyzoidzoid · 2 comments

I had a deleted minikube cluster in my .kube/config which lead to this:

zoid # docker run -it -p 8080:8080 -u $(id -u) -v $HOME/.kube:/.kube hjacobs/kube-web-view
INFO:kube_web.main:Kubernetes Web View v19.9.6 started with cluster_auth_token_path=None, cluster_auth_use_session_token=False, cluster_label_selector=None, cluster_registry_oauth2_bearer_token_path=None, cluster_registry_url=None, clusters=None, debug=False, default_custom_columns={}, default_hidden_columns={}, default_label_columns={}, default_theme=default, exclude_namespaces=None, include_namespaces=None, kubeconfig_contexts=None, kubeconfig_path=None, label_links=None, oauth2_authorized_hook=None, object_links=None, port=8080, preferred_api_versions={}, search_default_resource_types=None, search_max_concurrency=100, search_offered_resource_types=None, show_container_logs=False, show_secrets=False, sidebar_resource_types=None, static_assets_path=None, templates_path=None, theme_options=[]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/kube_web/__main__.py", line 3, in <module>
    main()
  File "/kube_web/main.py", line 246, in main
    args.preferred_api_versions,
  File "/kube_web/cluster_manager.py", line 35, in __init__
    self.reload()
  File "/kube_web/cluster_manager.py", line 39, in reload
    for cluster in self.discoverer.get_clusters():
  File "/kube_web/cluster_discovery.py", line 144, in get_clusters
    client = HTTPClient(context_config)
  File "/usr/local/lib/python3.7/site-packages/pykube/http.py", line 172, in __init__
    self.url = self.config.cluster["server"]
  File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 201, in cluster
    return self.clusters[self.contexts[self.current_context]["cluster"]]
  File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 164, in clusters
    BytesOrFile.maybe_set(c, "certificate-authority")
  File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 247, in maybe_set
    d[file_key] = cls(filename=d[file_key])
  File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 263, in __init__
    raise exceptions.PyKubeError("'{}' file does not exist".format(filename))
pykube.exceptions.PyKubeError: '$HOME/.minikube/ca.crt' file does not exist

Also that path wasn't mounted into my Docker image so we could potentially skip it and give a better warning/error message.

I had a deleted minikube cluster in my `.kube/config` which lead to this: ``` zoid # docker run -it -p 8080:8080 -u $(id -u) -v $HOME/.kube:/.kube hjacobs/kube-web-view INFO:kube_web.main:Kubernetes Web View v19.9.6 started with cluster_auth_token_path=None, cluster_auth_use_session_token=False, cluster_label_selector=None, cluster_registry_oauth2_bearer_token_path=None, cluster_registry_url=None, clusters=None, debug=False, default_custom_columns={}, default_hidden_columns={}, default_label_columns={}, default_theme=default, exclude_namespaces=None, include_namespaces=None, kubeconfig_contexts=None, kubeconfig_path=None, label_links=None, oauth2_authorized_hook=None, object_links=None, port=8080, preferred_api_versions={}, search_default_resource_types=None, search_max_concurrency=100, search_offered_resource_types=None, show_container_logs=False, show_secrets=False, sidebar_resource_types=None, static_assets_path=None, templates_path=None, theme_options=[] Traceback (most recent call last): File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/kube_web/__main__.py", line 3, in <module> main() File "/kube_web/main.py", line 246, in main args.preferred_api_versions, File "/kube_web/cluster_manager.py", line 35, in __init__ self.reload() File "/kube_web/cluster_manager.py", line 39, in reload for cluster in self.discoverer.get_clusters(): File "/kube_web/cluster_discovery.py", line 144, in get_clusters client = HTTPClient(context_config) File "/usr/local/lib/python3.7/site-packages/pykube/http.py", line 172, in __init__ self.url = self.config.cluster["server"] File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 201, in cluster return self.clusters[self.contexts[self.current_context]["cluster"]] File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 164, in clusters BytesOrFile.maybe_set(c, "certificate-authority") File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 247, in maybe_set d[file_key] = cls(filename=d[file_key]) File "/usr/local/lib/python3.7/site-packages/pykube/config.py", line 263, in __init__ raise exceptions.PyKubeError("'{}' file does not exist".format(filename)) pykube.exceptions.PyKubeError: '$HOME/.minikube/ca.crt' file does not exist ``` Also that path wasn't mounted into my Docker image so we could potentially skip it and give a better warning/error message.
Owner

Sounds good, thanks for reporting!

Sounds good, thanks for reporting!
hjacobs self-assigned this 2 years ago
Owner

I tried to fix this, but it's a bit more complicated as Pykube currently loads all files (even if only the current context is used).

I tried to fix this, but it's a bit more complicated as Pykube currently loads all files (even if only the current context is used).
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.