Skip to content

Commit

Permalink
[DPE-3570] Save 1 min on deploy by skipping init _on_upgrade_charm_ch…
Browse files Browse the repository at this point in the history
…eck_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...
  • Loading branch information
taurus-forever committed Jun 24, 2024
1 parent dbd46b5 commit 24ed7c3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 24ed7c3

Please sign in to comment.