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

IngressPerUnitRequirer.url should return a None on relation broken #230

Closed
sed-i opened this issue Aug 29, 2023 · 2 comments
Closed

IngressPerUnitRequirer.url should return a None on relation broken #230

sed-i opened this issue Aug 29, 2023 · 2 comments

Comments

@sed-i
Copy link
Contributor

sed-i commented Aug 29, 2023

Bug Description

When I removed the relation between prometheus and traefik, I noticed that web.external-url still has the ingress path.
This is because in prometheus we use self.ingress.url (IngressPerUnitRequirer.url), which in turn uses _urls_from_relation_data.

However, on relation broken, relation data can be misleading.

self.framework.observe(
self.charm.on[self.relation_name].relation_broken, self._handle_relation
)

Luckily, in _handle_relation, the requirer already has up to date information:

def _handle_relation(self, event: RelationEvent):
    # ...
    self._stored.current_urls = current_urls
    # ...
    self.on.revoked.emit(self.relation, unit_name)

All we need to do™ is also look at self._stored.current_urls inside IngressPerUnitRequirer.url.

To Reproduce

  1. Relate prom - trfk.
  2. Remove the relation.

Environment

Juju 3.2.0. Latest charms.

Relevant log output

NTA.

Additional context

No response

@sed-i
Copy link
Contributor Author

sed-i commented Jul 26, 2024

With recent ops, relation data should be hidden on relation broken.

@dstathis
Copy link
Contributor

We certainly have a recent enough version of ops by now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants