Skip to content

Commit f6562a9

Browse files
authored
[DPE-6191] fix install timeout + fix broken CI (#373)
* fix install timeout * update poetry + workflows * remove fields related to packages * fix linting issues * duplicate requirements in separate parts * migrate to use charm_version file per Carls suggestion * give workflow in tox access to poetry export * update charm version to pep format * PR feedback * remove build wrapper
1 parent d3e85cd commit f6562a9

26 files changed

+946
-757
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
jobs:
1717
lint:
1818
name: Lint
19-
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v21.0.0
19+
uses: canonical/data-platform-workflows/.github/workflows/lint.yaml@v24.0.6
2020

2121
lib-check:
2222
name: Check libraries
@@ -54,7 +54,7 @@ jobs:
5454

5555
build:
5656
name: Build charm | ${{ matrix.path }}
57-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.0
57+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.6
5858
strategy:
5959
matrix:
6060
path:
@@ -80,9 +80,9 @@ jobs:
8080
- lint
8181
- unit-test
8282
- build
83-
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v21.0.0
83+
uses: canonical/data-platform-workflows/.github/workflows/integration_test_charm.yaml@v24.0.6
8484
with:
85-
artifact-prefix: packed-charm-cache-false # TODO revert to "packed-charm-cache-true" when cache re-enabled
85+
artifact-prefix: packed-charm-cache-false # TODO revert to "packed-charm-cache-true" when cache re-enabled
8686
cloud: microk8s
8787
microk8s-snap-channel: 1.29-strict/stable
8888
juju-agent-version: ${{ matrix.juju.agent }}

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ jobs:
3535

3636
build:
3737
name: Build charm
38-
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v21.0.0
38+
uses: canonical/data-platform-workflows/.github/workflows/build_charm.yaml@v24.0.6
3939
with:
40-
artifact-prefix: temp-release-packed-charm # TODO: remove after caching re-enabled on PR
40+
artifact-prefix: temp-release-packed-charm # TODO: remove after caching re-enabled on PR
4141

4242
release:
4343
name: Release charm
4444
needs:
4545
- ci-tests
4646
- build
47-
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v21.0.0
47+
uses: canonical/data-platform-workflows/.github/workflows/release_charm.yaml@v24.0.6
4848
with:
4949
channel: 6/edge
5050
artifact-prefix: ${{ needs.build.outputs.artifact-prefix }}

charmcraft.yaml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,45 @@
33

44
type: "charm"
55
bases:
6-
- build-on:
7-
- name: "ubuntu"
8-
channel: "22.04"
9-
run-on:
10-
- name: "ubuntu"
11-
channel: "22.04"
6+
- name: ubuntu
7+
channel: "22.04"
8+
architectures: [amd64]
129
parts:
13-
charm:
14-
charm-strict-dependencies: true
10+
files:
11+
plugin: dump
12+
source: .
13+
build-packages:
14+
- git
1515
override-build: |
16-
rustup default stable
16+
# Workaround to add unique identifier (git hash) to charm version while specification
17+
# DA053 - Charm versioning
18+
# (https://docs.google.com/document/d/1Jv1jhWLl8ejK3iJn7Q3VbCIM9GIhp8926bgXpdtx-Sg/edit?pli=1)
19+
# is pending review.
20+
python3 -c 'import pathlib; import shutil; import subprocess; git_hash=subprocess.run(["git", "describe", "--always", "--dirty"], capture_output=True, check=True, encoding="utf-8").stdout; file = pathlib.Path("charm_version"); shutil.copy(file, pathlib.Path("charm_version.backup")); version = file.read_text().strip(); file.write_text(f"{version}+{git_hash}")'
1721
craftctl default
22+
stage:
23+
# Exclude requirements.txt file during staging
24+
# Workaround for https://github.com/canonical/charmcraft/issues/1389 on charmcraft 2
25+
- -requirements.txt
26+
prime:
27+
- charm_version
28+
- workload_version
29+
charm:
1830
build-snaps:
1931
- rustup
2032
build-packages:
2133
- libffi-dev
2234
- libssl-dev
2335
- pkg-config
24-
override-pull: |
25-
craftctl default
26-
if [[ ! -f requirements.txt ]]
27-
then
28-
echo 'ERROR: Use "tox run -e build-dev" instead of calling "charmcraft pack" directly' >&2
29-
exit 1
30-
fi
31-
files:
32-
plugin: dump
33-
source: .
34-
prime:
35-
- charm_internal_version
36-
- charm_version
37-
- workload_version
3836
override-build: |
3937
rustup default stable
38+
# Convert subset of poetry.lock to requirements.txt
39+
curl -sSL https://install.python-poetry.org | python3 -
40+
/root/.local/bin/poetry self add poetry-plugin-export
41+
/root/.local/bin/poetry export --only main,charm-libs --output requirements.txt
4042
craftctl default
43+
stage:
44+
# Exclude charm_version file during staging
45+
- -charm_version
46+
charm-strict-dependencies: true
47+
charm-requirements: [requirements.txt]

poetry.lock

Lines changed: 769 additions & 632 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
# See LICENSE file for licensing details.
33

44
[tool.poetry]
5-
name = "mongodb-k8s"
6-
version = "0.0.1-dev.0"
7-
description = ""
8-
license = "Apache-2.0"
9-
authors = [
10-
"Mykola Marzhan <[email protected]>"
11-
]
12-
readme = "README.md"
13-
homepage = "https://charmhub.io/mongodb-k8s?channel=6/edge"
14-
repository = "https://github.com/canonical/mongodb-k8s-operator"
5+
package-mode = false
6+
requires-poetry = ">=2.0.0"
7+
8+
9+
1510

1611
[tool.poetry.dependencies]
1712
python = "^3.10.12"
@@ -20,7 +15,7 @@ pymongo = "^4.7.3"
2015
tenacity = "^8.2.3"
2116
pyyaml = "^6.0.1"
2217
jinja2 = "^3.1.3"
23-
poetry-core = "^1.9.0"
18+
poetry-core = "^2.0"
2419
data-platform-helpers = "^0.1.3"
2520
overrides = "^7.7.0"
2621
lightkube = "^0.15.3"
@@ -35,6 +30,9 @@ jsonschema = "^4.22.0" # tls_certificates lib v3
3530
cosl = "^0.0.16" # loki_push_api
3631
pyOpenSSL = "^24.2.1"
3732

33+
[tool.poetry.requires-plugins]
34+
poetry-plugin-export = ">=1.8"
35+
3836
[tool.poetry.group.format]
3937
optional = true
4038

@@ -76,13 +74,12 @@ pytest = "^8.1.1"
7674
pytest-asyncio = "^0.21.1"
7775
pytest-mock = "^3.14.0"
7876
pytest-operator = "^0.36.0"
79-
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
80-
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
81-
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/github_secrets"}
82-
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v21.0.0", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
77+
pytest-operator-cache = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/pytest_operator_cache"}
78+
pytest-operator-groups = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/pytest_operator_groups"}
79+
pytest-github-secrets = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/github_secrets"}
80+
allure-pytest-collection-report = {git = "https://github.com/canonical/data-platform-workflows", tag = "v24.0.6", subdirectory = "python/pytest_plugins/allure_pytest_collection_report"}
8381

8482
[build-system]
85-
requires = ["poetry-core>=1.9.0"]
8683
build-backend = "poetry.core.masonry.api"
8784

8885
# Testing tools configuration

src/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Config:
2222
MONGOD_CONF_DIR = "/etc/mongod"
2323
MONGODB_LOG_FILENAME = "mongodb.log"
2424

25-
CHARM_INTERNAL_VERSION_FILE = "charm_internal_version"
25+
CHARM_INTERNAL_VERSION_FILE = "charm_version"
2626
LICENSE_PATH = "/licenses/LICENSE"
2727
CONTAINER_NAME = "mongod"
2828
SERVICE_NAME = "mongod"

tests/integration/backup_tests/test_backups.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from ..ha_tests import helpers as ha_helpers
1818
from ..helpers import (
19+
DEPLOYMENT_TIMEOUT,
1920
check_or_scale_app,
2021
destroy_cluster,
2122
get_app_name,
@@ -112,7 +113,7 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
112113
await ops_test.model.wait_for_idle(
113114
apps=[DATABASE_APP_NAME],
114115
status="active",
115-
timeout=2000,
116+
timeout=DEPLOYMENT_TIMEOUT,
116117
raise_on_error=False,
117118
)
118119

@@ -416,7 +417,12 @@ async def test_restore_new_cluster(
416417
)
417418

418419
await asyncio.gather(
419-
ops_test.model.wait_for_idle(apps=[new_cluster_app_name], status="active", idle_period=20),
420+
ops_test.model.wait_for_idle(
421+
apps=[new_cluster_app_name],
422+
status="active",
423+
timeout=DEPLOYMENT_TIMEOUT,
424+
idle_period=20,
425+
),
420426
)
421427

422428
leader_unit = await helpers.get_leader_unit(ops_test, db_app_name=new_cluster_app_name)

tests/integration/backup_tests/test_sharding_backups.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from ..backup_tests import helpers as backup_helpers
1515
from ..ha_tests.helpers import deploy_and_scale_application, get_direct_mongo_client
1616
from ..helpers import (
17+
DEPLOYMENT_TIMEOUT,
1718
METADATA,
1819
MONGOS_PORT,
1920
get_leader_id,
@@ -338,7 +339,7 @@ async def deploy_cluster_backup_test(
338339
apps=[S3_APP_NAME, config_server_name, shard_one_name, shard_two_name],
339340
idle_period=20,
340341
raise_on_blocked=False,
341-
timeout=TIMEOUT,
342+
timeout=DEPLOYMENT_TIMEOUT,
342343
raise_on_error=False,
343344
)
344345

tests/integration/ha_tests/helpers.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from ..helpers import (
3333
APP_NAME,
34+
DEPLOYMENT_TIMEOUT,
3435
MONGOD_PORT,
3536
MONGOS_PORT,
3637
get_app_name,
@@ -193,7 +194,7 @@ async def deploy_and_scale_mongodb(
193194
status="active",
194195
raise_on_blocked=True,
195196
raise_on_error=False,
196-
timeout=TIMEOUT,
197+
timeout=DEPLOYMENT_TIMEOUT,
197198
)
198199

199200
return mongodb_application_name
@@ -232,7 +233,7 @@ async def deploy_and_scale_application(ops_test: OpsTest) -> str:
232233
status="waiting",
233234
raise_on_blocked=True,
234235
raise_on_error=False,
235-
timeout=TIMEOUT,
236+
timeout=DEPLOYMENT_TIMEOUT,
236237
)
237238

238239
return APPLICATION_DEFAULT_APP_NAME
@@ -275,7 +276,11 @@ async def get_process_pid(
275276

276277

277278
async def send_signal_to_pod_container_process(
278-
ops_test: OpsTest, unit_name: str, container_name: str, process: str, signal_code: str
279+
ops_test: OpsTest,
280+
unit_name: str,
281+
container_name: str,
282+
process: str,
283+
signal_code: str,
279284
) -> None:
280285
"""Send the specified signal to a pod container process.
281286
@@ -330,7 +335,9 @@ async def get_replica_set_primary(
330335
) -> Optional[Unit]:
331336
"""Returns the primary unit name based no the replica set host."""
332337
with await get_direct_mongo_client(
333-
ops_test, excluded=excluded, use_subprocess_to_get_password=use_subprocess_to_get_password
338+
ops_test,
339+
excluded=excluded,
340+
use_subprocess_to_get_password=use_subprocess_to_get_password,
334341
) as client:
335342
data = client.admin.command("replSetGetStatus")
336343
unit_name = host_to_unit(primary_host(data))
@@ -674,7 +681,10 @@ async def wait_until_unit_in_status(
674681
) -> None:
675682
"""Waits until a replica is in the provided status as reported by MongoDB or timeout occurs."""
676683
with await get_direct_mongo_client(
677-
ops_test, online_unit.name, use_subprocess_to_get_password=True, app_name=app_name
684+
ops_test,
685+
online_unit.name,
686+
use_subprocess_to_get_password=True,
687+
app_name=app_name,
678688
) as client:
679689
data = client.admin.command("replSetGetStatus")
680690

@@ -809,7 +819,7 @@ def convert_time(time_as_str: str) -> int:
809819
def get_highest_unit(ops_test: OpsTest, app_name: str) -> Unit:
810820
"""Retrieves the most recently added unit to the MongoDB application."""
811821
num_units = len(ops_test.model.applications[app_name].units)
812-
highest_unit_name = f"mongodb-k8s/{num_units-1}"
822+
highest_unit_name = f"mongodb-k8s/{num_units - 1}"
813823
for unit in ops_test.model.applications[app_name].units:
814824
if unit.name == highest_unit_name:
815825
return unit
@@ -831,7 +841,11 @@ async def are_all_db_processes_down(ops_test: OpsTest, process: str) -> bool:
831841
with attempt:
832842
for unit in ops_test.model.applications[app].units:
833843
_, raw_pid, _ = await ops_test.juju(
834-
"ssh", "--container", MONGODB_CONTAINER_NAME, unit.name, *pgrep_cmd
844+
"ssh",
845+
"--container",
846+
MONGODB_CONTAINER_NAME,
847+
unit.name,
848+
*pgrep_cmd,
835849
)
836850

837851
# If something was returned, there is a running process.

tests/integration/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
UNIT_IDS = [0, 1, 2]
2626
MONGOS_PORT = 27018
2727
MONGOD_PORT = 27017
28-
28+
DEPLOYMENT_TIMEOUT = 2000
2929
TEST_DOCUMENTS = """[
3030
{
3131
\"uid\": 123,

0 commit comments

Comments
 (0)