Skip to content

Commit

Permalink
Handle error in Kubernetes proxy __del__
Browse files Browse the repository at this point in the history
  • Loading branch information
Aflynn50 committed Apr 18, 2024
1 parent e017bd2 commit 7002122
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion juju/client/proxy/kubernetes/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
# Licensed under the Apache V2, see LICENCE file for details.
import os
import tempfile
import logging

from juju.client.proxy.proxy import Proxy, ProxyNotConnectedError
from kubernetes import client
from kubernetes.stream import portforward

log = logging.getLogger('juju.client.connection')


class KubernetesProxy(Proxy):
def __init__(
Expand Down Expand Up @@ -60,7 +63,10 @@ def connect(self):

def __del__(self):
self.close()
os.unlink(self.temp_ca_file.name)
try:
os.unlink(self.temp_ca_file.name)
except FileNotFoundError:
log.debug(f"file {self.temp_ca_file.name} not found")

def close(self):
try:
Expand Down

0 comments on commit 7002122

Please sign in to comment.