Skip to content

Commit

Permalink
Lock file maintenance Python dependencies (#785)
Browse files Browse the repository at this point in the history
* Lock file maintenance Python dependencies

* Fix linting

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Dragomir Penev <[email protected]>
  • Loading branch information
renovate[bot] and dragomirp authored Nov 26, 2024
1 parent 1a33052 commit 97c7747
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 182 deletions.
7 changes: 4 additions & 3 deletions lib/charms/postgresql_k8s/v0/postgresql_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
)
from ops.charm import ActionEvent, RelationBrokenEvent
from ops.framework import Object
from ops.pebble import ConnectionError, PathError, ProtocolError
from ops.pebble import ConnectionError as PebbleConnectionError
from ops.pebble import PathError, ProtocolError
from tenacity import RetryError

# The unique Charmhub library identifier, never change it
Expand All @@ -44,7 +45,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version.
LIBPATCH = 9
LIBPATCH = 10

logger = logging.getLogger(__name__)
SCOPE = "unit"
Expand Down Expand Up @@ -143,7 +144,7 @@ def _on_certificate_available(self, event: CertificateAvailableEvent) -> None:
logger.debug("Cannot push TLS certificates at this moment")
event.defer()
return
except (ConnectionError, PathError, ProtocolError, RetryError) as e:
except (PebbleConnectionError, PathError, ProtocolError, RetryError) as e:
logger.error("Cannot push TLS certificates: %r", e)
event.defer()
return
Expand Down
325 changes: 160 additions & 165 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ package-mode = false
python = "^3.10"
ops = "^2.17.0"
cryptography = "^43.0.3"
boto3 = "^1.35.66"
boto3 = "^1.35.68"
pgconnstr = "^1.0.1"
requests = "^2.32.3"
tenacity = "^9.0.0"
cosl = "^0.0.43"
cosl = "^0.0.45"
pydantic = "^1.10.19"
poetry-core = "^1.9.1"
jsonschema = "^4.23.0"
Expand All @@ -39,7 +39,7 @@ opentelemetry-exporter-otlp-proto-http = "1.21.0"
optional = true

[tool.poetry.group.format.dependencies]
ruff = "^0.7.4"
ruff = "^0.8.0"

[tool.poetry.group.lint]
optional = true
Expand All @@ -51,7 +51,7 @@ codespell = "^2.3.0"
optional = true

[tool.poetry.group.unit.dependencies]
coverage = {extras = ["toml"], version = "^7.6.7"}
coverage = {extras = ["toml"], version = "^7.6.8"}
pydantic = "^1.10.19"
pytest = "^8.3.3"
pytest-mock = "^3.14.0"
Expand All @@ -72,7 +72,7 @@ allure-pytest-collection-report = {git = "https://github.com/canonical/data-plat
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
juju = "<=3.5.2.1"
psycopg2-binary = "^2.9.10"
boto3 = "^1.35.66"
boto3 = "^1.35.68"
tenacity = "^9.0.0"
allure-pytest = "^2.13.5"

Expand Down
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
ServiceInfo,
ServiceStatus,
)
from requests import ConnectionError
from requests import ConnectionError as RequestsConnectionError
from tenacity import RetryError, Retrying, stop_after_attempt, stop_after_delay, wait_fixed

from backups import CANNOT_RESTORE_PITR, S3_BLOCK_MESSAGES, PostgreSQLBackups
Expand Down Expand Up @@ -990,7 +990,7 @@ def _set_active_status(self):
self.unit.status = ActiveStatus("Standby")
elif self._patroni.member_started:
self.unit.status = ActiveStatus()
except (RetryError, ConnectionError) as e:
except (RetryError, RequestsConnectionError) as e:
logger.error(f"failed to get primary with error {e}")

def _initialize_cluster(self, event: WorkloadEvent) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ha_tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.

import asyncio
import logging
import os
from asyncio import TimeoutError

import pytest
from pytest_operator.plugin import OpsTest
Expand Down Expand Up @@ -212,7 +212,7 @@ async def test_app_resources_conflicts(ops_test: OpsTest):
await ops_test.model.wait_for_idle(
apps=[DUP_DATABASE_APP_NAME], timeout=500, status="blocked"
)
except TimeoutError:
except asyncio.TimeoutError:
logger.info("Application is not in blocked state. Checking logs...")

# Since application have postgresql db in storage from external application it should not be able to connect due to new password
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)
from ops.pebble import Change, ChangeError, ChangeID, ServiceStatus
from ops.testing import Harness
from requests import ConnectionError
from requests import ConnectionError as RequestsConnectionError
from tenacity import RetryError, wait_fixed

from charm import EXTENSION_OBJECT_MESSAGE, PostgresqlOperatorCharm
Expand Down Expand Up @@ -1723,13 +1723,13 @@ def test_set_active_status(harness):
for values in itertools.product(
[
RetryError(last_attempt=1),
ConnectionError,
RequestsConnectionError,
harness.charm.unit.name,
f"{harness.charm.app.name}/2",
],
[
RetryError(last_attempt=1),
ConnectionError,
RequestsConnectionError,
True,
False,
],
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_postgresql_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import MagicMock, call, patch

import pytest
from ops.pebble import ConnectionError
from ops.pebble import ConnectionError as PebbleConnectionError
from ops.testing import Harness

from charm import PostgresqlOperatorCharm
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_on_certificate_available(harness):
_push_tls_files_to_workload.assert_called_once()
_defer.assert_not_called()

_push_tls_files_to_workload.side_effect = ConnectionError
_push_tls_files_to_workload.side_effect = PebbleConnectionError
emit_certificate_available_event(harness)
_defer.assert_called_once()

Expand Down

0 comments on commit 97c7747

Please sign in to comment.