Skip to content

Commit

Permalink
[MISC] Conditional password (#604)
Browse files Browse the repository at this point in the history
* Conditional password

* Revert dependency bump
  • Loading branch information
dragomirp authored Aug 31, 2024
1 parent e9e8608 commit 5d05a9e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
9 changes: 1 addition & 8 deletions src/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand All @@ -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"
Expand Down
10 changes: 1 addition & 9 deletions src/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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."
Expand Down
2 changes: 2 additions & 0 deletions templates/patroni.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions tests/unit/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 5d05a9e

Please sign in to comment.