-
Notifications
You must be signed in to change notification settings - Fork 27
[DPE-8439] No reinit #1114
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-8439] No reinit #1114
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (67.28%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## 16/edge #1114 +/- ##
===========================================
- Coverage 67.30% 67.28% -0.03%
===========================================
Files 16 16
Lines 3762 3723 -39
Branches 541 537 -4
===========================================
- Hits 2532 2505 -27
+ Misses 1072 1061 -11
+ Partials 158 157 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if not self._patroni.member_started and self._patroni.is_database_running: | ||
| try: | ||
| container.restart(self.postgresql_service) | ||
| logger.info("restarted Patroni because it was not running") | ||
| except ChangeError: | ||
| logger.error("failed to restart Patroni after checking that it was not running") | ||
| 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.
Looks practically identical to thee restart check in _on_update_status() itself:
postgresql-k8s-operator/src/charm.py
Lines 1582 to 1598 in 6abe374
| if ( | |
| not self.is_cluster_restoring_backup | |
| and not self.is_cluster_restoring_to_time | |
| and not self.is_unit_stopped | |
| and services[0].current != ServiceStatus.ACTIVE | |
| ): | |
| logger.warning( | |
| f"{self.postgresql_service} pebble service inactive, restarting service" | |
| ) | |
| try: | |
| container.restart(self.postgresql_service) | |
| except ChangeError: | |
| logger.exception("Failed to restart patroni") | |
| # If service doesn't recover fast, exit and wait for next hook run to re-check | |
| if not self._patroni.member_started: | |
| self.unit.status = MaintenanceStatus("Database service inactive, restarting") | |
| return |
| if self._handle_processes_failures(): | ||
| return | ||
|
|
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.
Reinit removed and the restart check seems to be duplicated to the one above.
| @property | ||
| def is_database_running(self) -> bool: | ||
| """Returns whether the PostgreSQL database process is running (and isn't frozen).""" | ||
| container = self._charm.unit.get_container("postgresql") | ||
| output = container.exec(["ps", "aux"]).wait_output() | ||
| postgresql_processes = [ | ||
| process | ||
| for process in output[0].split("/n") | ||
| if "/usr/lib/postgresql/14/bin/postgres" in process | ||
| ] | ||
| # Check whether the PostgreSQL process has a state equal to T (frozen). | ||
| return any(process for process in postgresql_processes if process.split()[7] != "T") | ||
|
|
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.
Dead code. Also 14 specific.
taurus-forever
left a comment
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.
Thank you!
Checklist