Skip to content

Commit e017bd2

Browse files
committed
Fix issue with microk8s proxy
The temporary file used to store the ca_cert was set to delete itself on close. This meant that when it was accessed multiple times it would no longer be present.
1 parent 5ed5ae4 commit e017bd2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

juju/client/proxy/kubernetes/proxy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright 2023 Canonical Ltd.
22
# Licensed under the Apache V2, see LICENCE file for details.
3-
3+
import os
44
import tempfile
55

66
from juju.client.proxy.proxy import Proxy, ProxyNotConnectedError
@@ -33,7 +33,7 @@ def __init__(
3333
raise ValueError("Invalid port number: {}".format(remote_port))
3434

3535
if ca_cert:
36-
self.temp_ca_file = tempfile.NamedTemporaryFile()
36+
self.temp_ca_file = tempfile.NamedTemporaryFile(delete=False)
3737
self.temp_ca_file.write(bytes(ca_cert, 'utf-8'))
3838
self.temp_ca_file.flush()
3939
config.ssl_ca_cert = self.temp_ca_file.name
@@ -60,6 +60,7 @@ def connect(self):
6060

6161
def __del__(self):
6262
self.close()
63+
os.unlink(self.temp_ca_file.name)
6364

6465
def close(self):
6566
try:

0 commit comments

Comments
 (0)