Skip to content

Commit

Permalink
Merge branch 'main' into DPE-3777-create-nodeport
Browse files Browse the repository at this point in the history
  • Loading branch information
phvalguima authored Apr 16, 2024
2 parents 061e8e4 + eae1732 commit 2124f5f
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 92 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
jobs:
lint:
name: Lint
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v13.0.0
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v13.1.1

unit-test:
name: Unit test charm
Expand All @@ -42,7 +42,7 @@ jobs:

build:
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.0.0
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.1.1
with:
cache: true

Expand All @@ -51,17 +51,17 @@ jobs:
fail-fast: false
matrix:
juju:
- agent: 2.9.47 # renovate: latest juju 2
- agent: 2.9.49 # renovate: latest juju 2
libjuju: ==2.9.46.1 # renovate: latest libjuju 2
allure: false
- agent: 3.1.7 # renovate: latest juju 3
- agent: 3.1.8 # renovate: latest juju 3
allure: true
name: Integration test charm | ${{ matrix.juju.agent }}
needs:
- lint
- unit-test
- build
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v13.0.0
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v13.1.1
with:
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
cloud: microk8s
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ jobs:

build:
name: Build charm
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.0.0
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v13.1.1

release:
name: Release charm
needs:
- ci-tests
- build
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v13.0.0
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v13.1.1
with:
channel: 1/edge
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync_issue_to_jira.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
sync:
name: Sync GitHub issue to Jira
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v13.0.0
uses: canonical/data-platform-workflows/.github/workflows/sync_issue_to_jira.yaml@v13.1.1
with:
jira-base-url: https://warthogs.atlassian.net
jira-project-key: DPE
Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resources:
pgbouncer-image:
type: oci-image
description: OCI image for pgbouncer
upstream-source: ghcr.io/canonical/charmed-postgresql@sha256:a9b6f25cc6a12b0cb81cb19be76804f4a9452e4388ab2a11efd2d57a316977c5
upstream-source: ghcr.io/canonical/charmed-postgresql@sha256:b7db85555240c4e6f2df51badba69d9d8255c6d1e41b37ccb3dd0efcaef59030

provides:
database:
Expand Down
86 changes: 43 additions & 43 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ops = "^2.12.0"
cryptography = "^42.0.5"
jsonschema = "^4.21.1"
tenacity = "^8.2.3"
cosl = "^0.0.10"
cosl = "^0.0.11"
poetry-core = "^1.9.0"
lightkube = "^0.15.2"
lightkube-models = "^1.29.0.6"
Expand All @@ -40,7 +40,7 @@ cosl = "*"
optional = true

[tool.poetry.group.format.dependencies]
ruff = "^0.3.5"
ruff = "^0.3.7"

[tool.poetry.group.lint]
optional = true
Expand All @@ -64,10 +64,10 @@ optional = true
[tool.poetry.group.integration.dependencies]
lightkube = "*"
pytest = "^8.1.1"
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.0.0", subdirectory = "python/pytest_plugins/github_secrets"}
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.1", subdirectory = "python/pytest_plugins/github_secrets"}
pytest-operator = "^0.34.0"
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.1", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v13.1.1", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
# renovate caret doesn't work: https://github.com/renovatebot/renovate/issues/26940
juju = "<=3.4.0.0"
tenacity = "*"
Expand Down
20 changes: 10 additions & 10 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ def _on_update_status(self, _) -> None:

def update_status(self):
"""Health check to update pgbouncer status based on charm state."""
if self.unit.status.message == EXTENSIONS_BLOCKING_MESSAGE:
return

if self.backend.postgres is None:
self.unit.status = BlockedStatus("waiting for backend database relation to initialise")
return
Expand All @@ -453,9 +456,6 @@ def update_status(self):
self.unit.status = BlockedStatus("backend database relation not ready")
return

if self.unit.status.message == EXTENSIONS_BLOCKING_MESSAGE:
return

try:
if self.check_pgb_running():
self.unit.status = ActiveStatus()
Expand Down Expand Up @@ -528,7 +528,8 @@ def check_pgb_running(self):
"""Checks that pgbouncer pebble service is running, and updates status accordingly."""
pgb_container = self.unit.get_container(PGB)
if not pgb_container.can_connect():
self.unit.status = WaitingStatus(CONTAINER_UNAVAILABLE_MESSAGE)
if self.unit.status.message != EXTENSIONS_BLOCKING_MESSAGE:
self.unit.status = WaitingStatus(CONTAINER_UNAVAILABLE_MESSAGE)
logger.warning(CONTAINER_UNAVAILABLE_MESSAGE)
return False

Expand All @@ -545,7 +546,8 @@ def check_pgb_running(self):
pgb_service_status = pgb_container.get_services().get(service).current
if pgb_service_status != ServiceStatus.ACTIVE:
pgb_not_running = f"PgBouncer service {service} not running: service status = {pgb_service_status}"
self.unit.status = BlockedStatus(pgb_not_running)
if self.unit.status.message != EXTENSIONS_BLOCKING_MESSAGE:
self.unit.status = BlockedStatus(pgb_not_running)
logger.warning(pgb_not_running)
return False

Expand Down Expand Up @@ -715,22 +717,20 @@ def generate_relation_databases(self) -> Dict[str, Dict[str, Union[str, bool]]]:
"""Generates a mapping between relation and database and sets it in the app databag."""
if not self.unit.is_leader():
return {}
if dbs := self.get_relation_databases():
return dbs

databases = {}
for relation in self.model.relations.get("db", []):
database = self.legacy_db_relation.get_databags(relation)[0].get("database")
if database:
databases[relation.id] = {
databases[str(relation.id)] = {
"name": database,
"legacy": True,
}

for relation in self.model.relations.get("db-admin", []):
database = self.legacy_db_admin_relation.get_databags(relation)[0].get("database")
if database:
databases[relation.id] = {
databases[str(relation.id)] = {
"name": database,
"legacy": True,
}
Expand All @@ -740,7 +740,7 @@ def generate_relation_databases(self) -> Dict[str, Dict[str, Union[str, bool]]]:
).items():
database = data.get("database")
if database:
databases[rel_id] = {
databases[str(rel_id)] = {
"name": database,
"legacy": False,
}
Expand Down
Loading

0 comments on commit 2124f5f

Please sign in to comment.