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

[DPE-3562] Don't block on missing Postgresql version #626

Merged
merged 5 commits into from
Aug 19, 2024

Conversation

dragomirp
Copy link
Contributor

@dragomirp dragomirp commented Aug 13, 2024

Port of canonical/postgresql-operator#578

Don't block the relation if Postgresql can't get the database version.

Comment on lines +236 to +237
application_relation_databag.update(updates)
unit_relation_databag.update(updates)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So that that mccabe doesn't complain.

except (
PostgreSQLCreateDatabaseError,
PostgreSQLCreateUserError,
PostgreSQLGetPostgreSQLVersionError,
):
self.charm.unit.status = BlockedStatus(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should most probably defer here. Should I change this as well?

Copy link
Member

Choose a reason for hiding this comment

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

I think a defer would be good here. We just need to ensure that we can change the status to Active later when the database/user creation succeeds (which is what we are already missing today).

Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.66%. Comparing base (e760a3d) to head (e05981f).
Report is 3 commits behind head on main.

Files Patch % Lines
src/relations/db.py 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #626      +/-   ##
==========================================
- Coverage   70.71%   70.66%   -0.05%     
==========================================
  Files          11       11              
  Lines        2926     2932       +6     
  Branches      511      512       +1     
==========================================
+ Hits         2069     2072       +3     
- Misses        748      750       +2     
- Partials      109      110       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +207 to +215
postgresql_version = None
try:
postgresql_version = self.charm.postgresql.get_postgresql_version()
except PostgreSQLGetPostgreSQLVersionError:
logger.exception(
"Failed to retrieve the PostgreSQL version to initialise/update %s relation"
% self.relation_name
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

K8S charm will not update the endpoints as aggressively as VM. This will be reran only on config change. Should I try add something to update status?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a time for Pebble Notices and stop relying update-status?
Up 2 Marcelo here.

Copy link
Member

Choose a reason for hiding this comment

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

If it's possible to avoid calls to sleep or similar things on the notice event received by the charm (if we need to notify again from inside that event handler because the database version couldn't still be retrieved), I'm fine with using Pebble notices for that. Otherwise, I'd keep it on update status for now.

@dragomirp dragomirp marked this pull request as ready for review August 13, 2024 12:00
Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

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

Up 2 Marcelo...

Comment on lines +207 to +215
postgresql_version = None
try:
postgresql_version = self.charm.postgresql.get_postgresql_version()
except PostgreSQLGetPostgreSQLVersionError:
logger.exception(
"Failed to retrieve the PostgreSQL version to initialise/update %s relation"
% self.relation_name
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a time for Pebble Notices and stop relying update-status?
Up 2 Marcelo here.

except (
PostgreSQLCreateDatabaseError,
PostgreSQLCreateUserError,
PostgreSQLGetPostgreSQLVersionError,
):
self.charm.unit.status = BlockedStatus(
Copy link
Member

Choose a reason for hiding this comment

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

I think a defer would be good here. We just need to ensure that we can change the status to Active later when the database/user creation succeeds (which is what we are already missing today).

Comment on lines +99 to +105
if (
not self.set_up_relation(event.relation)
and self.charm.unit.status.message
== f"Failed to initialize {self.relation_name} relation"
):
event.defer()
return
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Charm should be unblocked by _update_unit_status if set_up_relation succeeds.

@dragomirp dragomirp merged commit 43bf7a9 into main Aug 19, 2024
90 checks passed
@dragomirp dragomirp deleted the dpe-3562-blocking-legacy-relation branch August 19, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants