Skip to content

Commit 5d05a9e

Browse files
authored
[MISC] Conditional password (#604)
* Conditional password * Revert dependency bump
1 parent e9e8608 commit 5d05a9e

File tree

4 files changed

+4
-22
lines changed

4 files changed

+4
-22
lines changed

src/cluster.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def is_creating_backup(self) -> bool:
412412
for member in r.json()["members"]
413413
)
414414

415-
def is_replication_healthy(self, raft_encryption: bool = False) -> bool:
415+
def is_replication_healthy(self) -> bool:
416416
"""Return whether the replication is healthy."""
417417
try:
418418
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:
427427
member_status = requests.get(
428428
f"{url}/{endpoint}", verify=self.verify, auth=self._patroni_auth
429429
)
430-
# If raft is getting encrypted some of the calls will fail
431-
if member_status.status_code == 503 and raft_encryption:
432-
logger.warning(
433-
"Failed replication check for %s during raft encryption"
434-
% members_ip
435-
)
436-
continue
437430
if member_status.status_code != 200:
438431
logger.debug(
439432
"Failed replication check for %s with code %d"

src/upgrade.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,6 @@ def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None:
158158

159159
self.charm._setup_exporter()
160160
self.charm.backup.start_stop_pgbackrest_service()
161-
raft_encryption = (
162-
int(
163-
json.loads(self.peer_relation.data[self.charm.app].get("dependencies", "{}"))
164-
.get("charm", {})
165-
.get("version", 0)
166-
)
167-
< 3
168-
)
169161

170162
try:
171163
self.charm.unit.set_workload_version(
@@ -185,7 +177,7 @@ def _on_upgrade_granted(self, event: UpgradeGrantedEvent) -> None:
185177
not self.charm._patroni.member_started
186178
or self.charm.unit.name.replace("/", "-")
187179
not in self.charm._patroni.cluster_members
188-
or not self.charm._patroni.is_replication_healthy(raft_encryption)
180+
or not self.charm._patroni.is_replication_healthy()
189181
):
190182
logger.debug(
191183
"Instance not yet back in the cluster."

templates/patroni.yml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ log:
2121
restapi:
2222
listen: '{{ self_ip }}:8008'
2323
connect_address: '{{ self_ip }}:8008'
24+
{%- if patroni_password %}
2425
authentication:
2526
username: patroni
2627
password: {{ patroni_password }}
28+
{%- endif %}
2729
{%- if enable_tls %}
2830
cafile: {{ conf_path }}/ca.pem
2931
certfile: {{ conf_path }}/cert.pem

tests/unit/test_cluster.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ def test_is_replication_healthy(peers_ips, patroni):
235235
]
236236
assert not patroni.is_replication_healthy()
237237

238-
# Test ignoring errors in case of raft encryption.
239-
_get.side_effect = None
240-
_get.return_value.status_code = 503
241-
assert patroni.is_replication_healthy(True)
242-
243238

244239
def test_is_member_isolated(peers_ips, patroni):
245240
with (

0 commit comments

Comments
 (0)