Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with microk8s proxy #1044

Merged
merged 2 commits into from
Apr 19, 2024
Merged

Conversation

Aflynn50
Copy link
Contributor

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.

Set to not delete on close and to remove file when the proxy is deleted.

QA Steps

juju bootstrap microk8s
juju add-model default
juju deploy cos-lite

In python

from juju import model
m = model.Model()
await m.connect()
await m.create_offer("grafana:grafana-dashboard", "grafana-dashboards")
await m.disconnect()

Check all resource in /tmp have been cleaned up

Fixes #1040

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.
Copy link
Contributor

@cderici cderici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with one small change needed 👍

@@ -60,6 +60,7 @@ def connect(self):

def __del__(self):
self.close()
os.unlink(self.temp_ca_file.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's handle the FileNotFoundError here ourselves and log a nice warning, instead of __del__ ignoring it and writes it onto the stderr verbatim. (exceptions raised within destructors are suppressed -- to avoid weird behaviors, like the exception handler trying to destroy the object -- thereby calling __del__ again -- see doc)

We really should stop using things like __del__ and turn this into a context by adding __enter__ and __exit__ to handle these things, but that's beyond the scope of this PR.

Copy link
Contributor Author

@Aflynn50 Aflynn50 Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense I've got the connection logger and logged the error to that in __del__.

@Aflynn50 Aflynn50 force-pushed the fix-microk8s-proxy-issue branch from 0d4fbe8 to 7002122 Compare April 18, 2024 10:18
@Aflynn50
Copy link
Contributor Author

/merge

@jujubot jujubot merged commit 2c30901 into juju:master Apr 19, 2024
7 of 9 checks passed
jujubot added a commit that referenced this pull request May 31, 2024
#1056

## What's Changed
* Make consume respect the controller name in the url by @Aflynn50 in #1038
* Fix multiline description in textarea in bug template GH workflow by @cderici in #1041
* Fix issue with microk8s proxy by @Aflynn50 in #1044
* add missing "revision" parameter to addModel step. by @Thanhphan1147 in #1043
* Add user api to pylibjuju documentation by @cderici in #1049

## New Contributors
* @Thanhphan1147 made their first contribution in #1043

**Full Changelog**: 3.4.0.0...3.5.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Cannot create more than one offer
3 participants