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

[IPA] Make sure ingress.url returns an up-to-date value #84

Merged
merged 5 commits into from
Aug 30, 2022

Conversation

sed-i
Copy link
Contributor

@sed-i sed-i commented Aug 29, 2022

An IPA analogue to #80.

Context

canonical/alertmanager-k8s-operator#94

Release Notes

[IPA] Make sure ingress.url returns an up-to-date value

@sed-i sed-i marked this pull request as ready for review August 30, 2022 01:35
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.

Why the return type change in 'url'?
That's a backwards-incompatible change. What if user code is doing if self.ipa.url is None...?

self.assertEqual(self.harness.charm.ipa.url, "http://a.b/c")

# THEN the ready event is emitted
after = self.harness.charm.ready_event_count
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. This is magic!

@simskij
Copy link
Member

simskij commented Aug 30, 2022

Why the return type change in 'url'? That's a backwards-incompatible change. What if user code is doing if self.ipa.url is None...?

Agreeing with @PietroPasotti here. I get that the behavior is equivalent in case of if not self.ipa.url, which probably is what users should do in the first place, but we have no guarantees that is the case. It also seems like returning None would be the expected behavior here.

Comment on lines 539 to 546
def url(self) -> str:
"""The full ingress URL to reach the current unit.

May return None if the URL isn't available yet.
"""
data = self._stored.current_url or "" # type: ignore
assert isinstance(data, str) # for static checker
return data
Copy link
Contributor

Choose a reason for hiding this comment

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

If this method "May return None", shouldn't be the return type Optional[str]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@sed-i
Copy link
Contributor Author

sed-i commented Aug 30, 2022

Thanks for the reviews!
I reverted the "" back to None. Originally I was concerned about None going into and from Stored.

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.

nice work!

@sed-i sed-i merged commit b57449e into main Aug 30, 2022
@sed-i sed-i deleted the feature/test_revoked_ipa branch August 30, 2022 15:55
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.

4 participants