Skip to content

Commit

Permalink
Merge branch 'main' into feature/juju_3_6_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shayancanonical committed Sep 3, 2024
2 parents c016b2d + f5d26b1 commit 2513c6f
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>canonical/data-platform//renovate_presets/charm.json5"],
"reviewers": ["dragomirp", "lucasgameiroborges", "marceloneppel", "taurus-forever"],
"reviewers": ["team:data-platform-postgresql"],
"packageRules": [
// Later rules override earlier rules
{
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
# - 'LICENSE'
# - '**.md'
# - .github/renovate.json5
# - '.github/workflows/sync_docs.yaml'
schedule:
- cron: '53 0 * * *' # Daily at 00:53 UTC
# Triggered on push to branch "main" by .github/workflows/release.yaml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lib-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
tox run -e build-wrapper
mv requirements-last-build.txt requirements.txt
- name: Check libs
uses: canonical/charming-actions/[email protected].2
uses: canonical/charming-actions/[email protected].3
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- pyproject.toml
- '.github/workflows/ci.yaml'
- '.github/workflows/lib-check.yaml'
- '.github/workflows/sync_docs.yaml'

jobs:
ci-tests:
Expand Down
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 2513c6f

Please sign in to comment.