canonical / prometheus-k8s-operator

https://charmhub.io/prometheus-k8s
Apache License 2.0
21 stars 35 forks source link

move external_url dependees out of constructor #392

Closed lucabello closed 1 year ago

lucabello commented 2 years ago

Issue

This PR addresses #388.

Solution

Moving things depending on self.external_url outside of the constructor, so they are not called on removing the application.

Release Notes

I moved the logic depending on self.external_url to a separate function and invoked that in _configure() instead of __init__().
This way, that code is executed in every part of the lifecycle except the removal.

lucabello commented 2 years ago

An event guard probably makes more sense!

rbarry82 commented 2 years ago

I was slow on the uptake for the review, but please don't directly check JUJU_HOOK_NAME. This isn't a promise Juju gives us, and even OF doesn't try to be that clever. catching ModelError is much less brittle