diff --git a/charmcraft.yaml b/charmcraft.yaml index 165c0ea..ef03057 100644 --- a/charmcraft.yaml +++ b/charmcraft.yaml @@ -51,7 +51,7 @@ parts: source: . after: - poetry-deps - poetry-export-extra-args: ['--only', 'main,charm-libs,single-kernel'] + poetry-export-extra-args: ['--only', 'main,charm-libs'] build-packages: - libffi-dev # Needed to build Python dependencies with Rust from source - libssl-dev # Needed to build Python dependencies with Rust from source diff --git a/poetry.lock b/poetry.lock index 3fa6eb9..c2b66b2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1565,7 +1565,7 @@ version = "1.43.0" description = "OpenTelemetry Python API" optional = false python-versions = ">=3.10" -groups = ["main", "charm-libs", "single-kernel"] +groups = ["main", "charm-libs", "integration"] files = [ {file = "opentelemetry_api-1.43.0-py3-none-any.whl", hash = "sha256:20acf45e9b21851926835292e4045d290acade1edd2ff3de86d2f069687ba1fd"}, {file = "opentelemetry_api-1.43.0.tar.gz", hash = "sha256:107d0d03857ea8fc7c5fcbbbd83f800c281f0d560553d61c1d675fccfd1761c1"}, @@ -1580,7 +1580,7 @@ version = "3.8.0" description = "The Python library behind great charms" optional = false python-versions = ">=3.10" -groups = ["main", "charm-libs", "single-kernel"] +groups = ["main", "charm-libs", "integration"] files = [ {file = "ops-3.8.0-py3-none-any.whl", hash = "sha256:03f788091b10c5ed37a0a290e814b1a90aa0dcec6006a87875a085072df2261d"}, {file = "ops-3.8.0.tar.gz", hash = "sha256:bdbf4bbcd0622acade9ef0b156ddefc31be59f0ef55d563081a094cf7dd6665c"}, @@ -1702,14 +1702,14 @@ testing = ["coverage", "pytest", "pytest-benchmark"] [[package]] name = "postgresql-charms-single-kernel" -version = "16.3.0" +version = "16.3.1" description = "Shared and reusable code for PostgreSQL-related charms" optional = false python-versions = "<4.0,>=3.8" -groups = ["single-kernel"] +groups = ["main", "integration"] files = [ - {file = "postgresql_charms_single_kernel-16.3.0-py3-none-any.whl", hash = "sha256:3f0a392b3f26ce3676ac365b49f25baa6ac812f82143c517689935f42114efbd"}, - {file = "postgresql_charms_single_kernel-16.3.0.tar.gz", hash = "sha256:7e0d7db80d0b1a5a97baf002809c101d55e4ffe5b9f26a3ae20b9b150c6ae51e"}, + {file = "postgresql_charms_single_kernel-16.3.1-py3-none-any.whl", hash = "sha256:a1c3f32fb396e69421471d64f54a43968f134fe5538708fabe37139a9fae832e"}, + {file = "postgresql_charms_single_kernel-16.3.1.tar.gz", hash = "sha256:48e028e873b00c877fd36a25ff6c1913a40d559cb4124aae888edd1262cdce3a"}, ] [package.dependencies] @@ -1717,7 +1717,9 @@ ops = ">=2.0.0" tenacity = ">=9.0.0" [package.extras] -postgresql = ["charm-refresh ; python_full_version >= \"3.12.0\"", "charmlibs-interfaces-tls-certificates (>=1.8.3) ; python_full_version >= \"3.12.0\"", "charmlibs-pathops (>=1.0.1) ; python_full_version >= \"3.12.0\"", "charmlibs-rollingops (>=1.1.1) ; python_full_version >= \"3.12.0\"", "charmlibs-snap (>=1.0.1) ; python_full_version >= \"3.12.0\"", "data-platform-helpers (>=0.1.7) ; python_full_version >= \"3.12.0\"", "httpx ; python_full_version >= \"3.12.0\"", "jinja2 (>=3.1.6) ; python_full_version >= \"3.12.0\"", "psycopg2 (>=2.9.10)", "pydantic (>=2.0) ; python_full_version >= \"3.12.0\"", "requests ; python_full_version >= \"3.12.0\"", "tomli ; python_full_version >= \"3.12.0\""] +db-driver = ["psycopg2 (>=2.9.10)"] +postgresql = ["charm-refresh ; python_full_version >= \"3.12.0\"", "charmlibs-interfaces-tls-certificates (>=1.8.3) ; python_full_version >= \"3.12.0\"", "charmlibs-pathops (>=1.0.1) ; python_full_version >= \"3.12.0\"", "charmlibs-rollingops (>=1.1.1) ; python_full_version >= \"3.12.0\"", "data-platform-helpers (>=0.1.7) ; python_full_version >= \"3.12.0\"", "httpx ; python_full_version >= \"3.12.0\"", "jinja2 (>=3.1.6) ; python_full_version >= \"3.12.0\"", "pydantic (>=2.0) ; python_full_version >= \"3.12.0\"", "requests ; python_full_version >= \"3.12.0\"", "tomli ; python_full_version >= \"3.12.0\""] +vm = ["charmlibs-snap (>=1.0.1) ; python_full_version >= \"3.12.0\"", "psutil (>=7.2.2) ; python_full_version >= \"3.12.0\"", "pysyncobj (>=0.3.15) ; python_full_version >= \"3.12.0\""] [[package]] name = "prompt-toolkit" @@ -2298,7 +2300,7 @@ version = "6.0.3" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.8" -groups = ["main", "charm-libs", "integration", "single-kernel"] +groups = ["main", "charm-libs", "integration"] files = [ {file = "PyYAML-6.0.3-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f"}, {file = "PyYAML-6.0.3-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4"}, @@ -2656,7 +2658,7 @@ version = "9.1.4" description = "Retry code until it succeeds" optional = false python-versions = ">=3.10" -groups = ["main", "charm-libs", "integration", "single-kernel"] +groups = ["main", "charm-libs", "integration"] files = [ {file = "tenacity-9.1.4-py3-none-any.whl", hash = "sha256:6095a360c919085f28c6527de529e76a06ad89b23659fa881ae0649b867a9d55"}, {file = "tenacity-9.1.4.tar.gz", hash = "sha256:adb31d4c263f2bd041081ab33b498309a57c77f9acf2db65aadf0898179cf93a"}, @@ -2809,7 +2811,7 @@ version = "4.15.0" description = "Backported and Experimental Type Hints for Python 3.9+" optional = false python-versions = ">=3.9" -groups = ["main", "charm-libs", "integration", "single-kernel", "unit"] +groups = ["main", "charm-libs", "integration", "unit"] files = [ {file = "typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"}, {file = "typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"}, @@ -2883,7 +2885,7 @@ version = "1.9.0" description = "WebSocket client for Python with low level API options" optional = false python-versions = ">=3.9" -groups = ["main", "charm-libs", "integration", "single-kernel"] +groups = ["main", "charm-libs", "integration"] files = [ {file = "websocket_client-1.9.0-py3-none-any.whl", hash = "sha256:af248a825037ef591efbf6ed20cc5faa03d3b47b9e5a2230a529eeee1c1fc3ef"}, {file = "websocket_client-1.9.0.tar.gz", hash = "sha256:9e813624b6eb619999a97dc7958469217c3176312b3a16a4bd1bc7e08a46ec98"}, @@ -2983,4 +2985,4 @@ h11 = ">=0.16.0,<1" [metadata] lock-version = "2.1" python-versions = ">=3.12,<4.0" -content-hash = "7c8395b1c88d5a61167626b339cb87e42258ff92db3442d5ae58938ed05ee52e" +content-hash = "bfe56cca43092fc623111b5e4bfec8198d0de87a57f7db15c81c6da3e6a44965" diff --git a/pyproject.toml b/pyproject.toml index 09ac567..64ae3a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,9 +18,7 @@ pysyncobj = "^0.3.15" charm-refresh = "^3.1.0.2" charmlibs-snap = "^1.0.1" charmlibs-systemd = "^1.0.0" - -[tool.poetry.group.single-kernel.dependencies] -postgresql-charms-single-kernel = "16.3.0" +postgresql-charms-single-kernel = "16.3.1" [tool.poetry.group.charm-libs.dependencies] # data_platform_libs/v0/data_models.py @@ -79,6 +77,7 @@ allure-pytest-default-results = "^0.1.4" tomli = "^2.4.1" tomli-w = "^1.2.0" pysyncobj = "*" +postgresql-charms-single-kernel = "*" [tool.poetry.group.build-refresh-version] optional = true diff --git a/src/cluster.py b/src/cluster.py deleted file mode 100644 index 239b73e..0000000 --- a/src/cluster.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2026 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Helper class used to manage cluster lifecycle.""" - -import logging -from typing import TypedDict - -logger = logging.getLogger(__name__) - - -class ClusterMember(TypedDict): - """Type for cluster member.""" - - name: str - role: str - state: str - api_url: str - host: str - port: int - timeline: int - lag: int diff --git a/src/raft_controller.py b/src/raft_controller.py index 5d8721a..18333e0 100644 --- a/src/raft_controller.py +++ b/src/raft_controller.py @@ -36,6 +36,7 @@ from pysyncobj.utility import TcpUtility from single_kernel_postgresql.config.enums import Substrates from single_kernel_postgresql.config.literals import PATRONI_CLUSTER_STATUS_ENDPOINT +from single_kernel_postgresql.managers.patroni import ClusterMember from single_kernel_postgresql.utils import ( create_directory, parallel_patroni_get_request, @@ -43,7 +44,6 @@ ) from tenacity import RetryError, Retrying, stop_after_attempt, wait_fixed -from cluster import ClusterMember from constants import RAFT_PARTNER_PREFIX, RAFT_PORT if TYPE_CHECKING: diff --git a/tox.ini b/tox.ini index b30be69..6864dc7 100644 --- a/tox.ini +++ b/tox.ini @@ -47,7 +47,7 @@ description = Run unit tests set_env = {[testenv]set_env} commands_pre = - poetry install --only main,charm-libs,single-kernel,unit --no-root + poetry install --only main,charm-libs,unit --no-root commands = poetry run coverage run --source={[vars]src_path} \ -m pytest -v --tb native -s {posargs} {[vars]tests_path}/unit @@ -66,6 +66,6 @@ pass_env = LANDSCAPE_ACCOUNT_NAME LANDSCAPE_REGISTRATION_KEY commands_pre = - poetry install --only integration,single-kernel --no-root + poetry install --only integration --no-root commands = poetry run pytest -v --tb native --log-cli-level=INFO -s --ignore={[vars]tests_path}/unit/ {posargs}