From 24ed7c3904fc5cec201d60b3b13d050d836d8364 Mon Sep 17 00:00:00 2001 From: Alex Lutay <1928266+taurus-forever@users.noreply.github.com> Date: Mon, 26 Feb 2024 14:59:43 +0100 Subject: [PATCH] [DPE-3570] Save 1 min on deploy by skipping init _on_upgrade_charm_check_legacy() The _on_upgrade_charm_check_legacy() was necessary to allow very old revision 228 refresh to the revision 336 (the revision 228 didn't have `pre-upgrade-check` action). It is no longer topical, but still is being called from __init__ of class PostgreSQLUpgrade() for each Juju event. Inside we are checking `if self.charm._patroni.member_started` which is causing one minute waiting timeout for patroni which is not yet even installed: > 13:19:04 DEBUG unit.postgresql/0.juju-log ops 2.9.0 up and running. > 13:19:04 INFO unit.postgresql/0.juju-log Running legacy hooks/install. > 13:19:05 DEBUG unit.postgresql/0.juju-log ops 2.9.0 up and running. > 13:19:05 DEBUG unit.postgresql/0.juju-log Charm called itself via hooks/install. > 13:19:05 DEBUG unit.postgresql/0.juju-log Legacy hooks/install exited with status 0. > 13:19:05 DEBUG unit.postgresql/0.juju-log Wait all units join the upgrade relation > 13:19:05 DEBUG unit.postgresql/0.juju-log Emitting Juju event install. > 13:19:53 INFO juju.worker.uniter.operation ran "install" hook (via hook dispatching script: dispatch) > 13:19:53 DEBUG unit.postgresql/0.juju-log upgrade:0: ops 2.9.0 up and running. > 13:19:54 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:19:57 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:00 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:03 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:06 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:09 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:12 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:15 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:18 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:21 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:24 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:27 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:30 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:33 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:36 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:39 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:42 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:45 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:48 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:51 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:54 DEBUG unit.postgresql/0.juju-log upgrade:0: Starting new HTTP connection (1): 10.172.136.223:8008 > 13:20:54 DEBUG unit.postgresql/0.juju-log upgrade:0: Emitting Juju event upgrade_relation_created. > 13:20:54 DEBUG unit.postgresql/0.juju-log upgrade:0: Persisting dependencies to upgrade relation data... --- src/upgrade.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/upgrade.py b/src/upgrade.py index f8fce9ab13..7fa435b651 100644 --- a/src/upgrade.py +++ b/src/upgrade.py @@ -115,8 +115,10 @@ def _on_upgrade_charm_check_legacy(self) -> None: peers_state = list(filter(lambda state: state != "", self.unit_states)) - if len(peers_state) == len(self.peer_relation.units) and ( - set(peers_state) == {"ready"} or len(peers_state) == 0 + if ( + len(peers_state) == len(self.peer_relation.units) + and (set(peers_state) == {"ready"} or len(peers_state) == 0) + and self.charm.is_cluster_initialised ): if self.charm._patroni.member_started: # All peers have set the state to ready