-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add check for primary endpoint ready #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!! One minor suggestion
src/patroni.py
Outdated
except RetryError: | ||
return False | ||
|
||
return r.json()["state"] == "running" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the state isn't running is it worth retrying? ie
try:
for attempt in Retrying(stop=stop_after_delay(10), wait=wait_fixed(3)):
with attempt:
r = requests.get(
f"{'https' if self._tls_enabled else 'http'}://{self._primary_endpoint}:8008/health",
verify=self._verify,
)
if not r.json()["state"] == "running":
raise endpointNotReadyError
except RetryError:
return False
return True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It is a great improvement! I will implement it. Thanks Mia!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated on fbb4332.
await ops_test.model.add_relation( | ||
f"{APPLICATION_APP_NAME}:{FIRST_DATABASE_RELATION_NAME}", DATABASE_APP_NAME | ||
) | ||
await ops_test.model.wait_for_idle(apps=APP_NAMES, status="active", raise_on_blocked=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleverly tested :)
Added an additional test for relation broken on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome, really good work here :)
* Add check for started service * Add check for primary endpoint being ready * Update charm unit tests * Add unit test * Fix unit test * Make property private * Improve primary endpoint check * Revert change * Add test for relation broken
Issue
Solution
cluster_initialised
flag (that is checked in multiple charm events) before the primary endpoint/service is fully ready by checking its accessibility.Context
Files to
FOCUS
when reviewing this PR:src/charm.py
: has the call to the check, an update to the upgrade charm event handler to avoid problems withe the primary endpoint being deleted when the pod is killed and also an update to the update status event holder to avoid logging error messages when the PostgreSQL/Patroni pebble service is not ready yet.src/patroni.py
: has the implementation of the primary endpoint/service readiness check.src/resources.yaml
has an additional port that is used to contact the primary endpoint during the initial check on charm.py pebble ready event.tests/integration/new_relations/test_new_relations.py
has an update to merge two tests in one (in a way that makes the PostgreSQL charm to be related faster to the application charm; this avoids any kind of regression on this new implementation).Extra details about the other files:
tests/unit/test_charm.py
andtests/unit/test_patroni.py
were updated just to match the new implementations.Testing
Release Notes