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

Refresh url on access #107

Merged
merged 7 commits into from
Dec 1, 2022
Merged

Refresh url on access #107

merged 7 commits into from
Dec 1, 2022

Conversation

sed-i
Copy link
Contributor

@sed-i sed-i commented Nov 25, 2022

Issue

canonical/catalogue-k8s-operator#3

Solution

Refresh url on access (example) by pre-fetching urls from relation data instead of stored state.

Context

See thread: canonical/catalogue-k8s-operator#4 (comment)

Testing Instructions

Deploy the bundle and see which URL catalogue has for prom: fqdn or ingress.

$ ./render_bundle.py local.yaml --traefik ../traefik-k8s-operator/traefik-k8s_ubuntu-20.04-amd64.charm
$ juju deploy ./local.yaml --trust
$ juju ssh --container catalogue catalogue/0 cat /web/config.json | jq '.apps'

Release Notes

Prefetch urls from reldata instead of stored state.

@sed-i sed-i force-pushed the feature/refresh_url_on_access branch from 7290099 to 30bdecc Compare December 1, 2022 03:39
@sed-i sed-i requested a review from rbarry82 December 1, 2022 04:32
@sed-i sed-i marked this pull request as ready for review December 1, 2022 04:32
Copy link
Contributor

@PietroPasotti PietroPasotti left a comment

Choose a reason for hiding this comment

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

couple of food-for-thought points, but it looks good.

lib/charms/traefik_k8s/v1/ingress_per_unit.py Outdated Show resolved Hide resolved
return None
return self.urls.get(self.charm.unit.name)
return urls.get(self.charm.unit.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

do you just like this more, or is there a logic change I'm missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we could use walrus then I'd use walrus.
It's to avoid fetching the urls property twice.
It mattered more before I refactored.

@@ -832,16 +831,16 @@ def urls(self) -> Dict[str, str]:

May return an empty dict if the URLs aren't available yet.
"""
data = _type_convert_stored(self._stored.current_urls or {}) # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

can we get rid of stored altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it's used to compare current vs. previous for emitting the custom events.
Do you mean use peer data instead?

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.

3 participants