diff --git a/src/cluster.py b/src/cluster.py index f7eb91b838..a45e6f889b 100644 --- a/src/cluster.py +++ b/src/cluster.py @@ -412,7 +412,7 @@ def is_creating_backup(self) -> bool: for member in r.json()["members"] ) - def is_replication_healthy(self, raft_encryption: bool = False) -> bool: + def is_replication_healthy(self) -> bool: """Return whether the replication is healthy.""" try: for attempt in Retrying(stop=stop_after_delay(60), wait=wait_fixed(3)): @@ -427,13 +427,6 @@ def is_replication_healthy(self, raft_encryption: bool = False) -> bool: member_status = requests.get( f"{url}/{endpoint}", verify=self.verify, auth=self._patroni_auth ) - # If raft is getting encrypted some of the calls will fail - if member_status.status_code == 503 and raft_encryption: - logger.warning( - "Failed replication check for %s during raft encryption" - % members_ip - ) - continue if member_status.status_code != 200: logger.debug( "Failed replication check for %s with code %d" diff --git a/src/upgrade.py b/src/upgrade.py index 7701430ba8..1c155443ef 100644 --- a/src/upgrade.py +++ b/src/upgrade.py @@ -158,14 +158,6 @@ def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None: self.charm._setup_exporter() self.charm.backup.start_stop_pgbackrest_service() - raft_encryption = ( - int( - json.loads(self.peer_relation.data[self.charm.app].get("dependencies", "{}")) - .get("charm", {}) - .get("version", 0) - ) - < 3 - ) try: self.charm.unit.set_workload_version( @@ -185,7 +177,7 @@ def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None: not self.charm._patroni.member_started or self.charm.unit.name.replace("/", "-") not in self.charm._patroni.cluster_members - or not self.charm._patroni.is_replication_healthy(raft_encryption) + or not self.charm._patroni.is_replication_healthy() ): logger.debug( "Instance not yet back in the cluster." diff --git a/templates/patroni.yml.j2 b/templates/patroni.yml.j2 index 74128ff575..af3773a068 100644 --- a/templates/patroni.yml.j2 +++ b/templates/patroni.yml.j2 @@ -21,9 +21,11 @@ log: restapi: listen: '{{ self_ip }}:8008' connect_address: '{{ self_ip }}:8008' + {%- if patroni_password %} authentication: username: patroni password: {{ patroni_password }} + {%- endif %} {%- if enable_tls %} cafile: {{ conf_path }}/ca.pem certfile: {{ conf_path }}/cert.pem diff --git a/tests/unit/test_cluster.py b/tests/unit/test_cluster.py index 5f12f1fd91..370f47c147 100644 --- a/tests/unit/test_cluster.py +++ b/tests/unit/test_cluster.py @@ -235,11 +235,6 @@ def test_is_replication_healthy(peers_ips, patroni): ] assert not patroni.is_replication_healthy() - # Test ignoring errors in case of raft encryption. - _get.side_effect = None - _get.return_value.status_code = 503 - assert patroni.is_replication_healthy(True) - def test_is_member_isolated(peers_ips, patroni): with (