Skip to content

Commit

Permalink
update to jammy (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
delgod authored Jan 26, 2023
1 parent ea8940d commit 16989be
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ juju add-model dev
# Enable DEBUG logging
juju model-config logging-config="<root>=INFO;unit=DEBUG"
# Deploy the charm
juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0 --num-units=1
juju deploy ./mongodb-k8s_ubuntu-22.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0 --num-units=1
```

## Canonical Contributor Agreement
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This operator charm deploys and operates MongoDB on Kubernetes. It offers featur
- at least 2 CPU threads per host.
- For production deployment: at least 60GB of available storage on each host.
- Access to the internet for downloading the charm.
- Machine is running Ubuntu 20.04(focal) or later.
- Machine is running Ubuntu 22.04(jammy) or later.

## Config options
auto-delete - `boolean`; When a relation is removed, auto-delete ensures that any relevant databases
Expand All @@ -29,13 +29,12 @@ tls internal key - `string`; TLS external key for encryption inside the cluster
### Basic Usage
To deploy a single unit of MongoDB using its default configuration
```shell
juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0
juju deploy ./mongodb-k8s_ubuntu-22.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0
```

It is customary to use MongoDB with replication. Hence usually more than one unit (preferably an odd number to prohibit a "split-brain" scenario) is deployed. To deploy MongoDB with multiple replicas, specify the number of desired units with the `-n` option.
```shell
juju deploy ./mongodb-k8s_ubuntu-20.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0
-n <number_of_replicas>
juju deploy ./mongodb-k8s_ubuntu-22.04-amd64.charm --resource mongodb-image=dataplatformoci/mongodb:5.0 -n <number_of_replicas>
```

### Replication
Expand Down
4 changes: 2 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ parts:
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
2 changes: 1 addition & 1 deletion lib/charms/mongodb/v0/mongodb_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def _get_sans(self) -> List[str]:
return [
f"{self.charm.app.name}-{unit_id}",
socket.getfqdn(),
f"{self.charm.app.name}-{unit_id}.{self.charm.app.name}-endpoints",
f"{self.charm.app.name}-{unit_id}.{self.charm.app.name}-endpoints",
str(self.charm.model.get_binding(self.peer_relation).network.bind_address),
]

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/ha_tests/application_charm/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
2 changes: 2 additions & 0 deletions tests/integration/ha_tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ async def deploy_and_scale_mongodb(
application_name=mongodb_application_name,
resources=resources,
num_units=num_units,
series="jammy",
)

await ops_test.model.wait_for_idle(
Expand Down Expand Up @@ -204,6 +205,7 @@ async def deploy_and_scale_application(ops_test: OpsTest) -> str:
application_charm,
application_name=APPLICATION_DEFAULT_APP_NAME,
num_units=1,
series="jammy",
)

await ops_test.model.wait_for_idle(
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ async def test_build_and_deploy(ops_test: OpsTest):
charm = await ops_test.build_charm(".")
resources = {"mongodb-image": METADATA["resources"]["mongodb-image"]["upstream-source"]}
await ops_test.model.deploy(
charm, resources=resources, application_name=APP_NAME, num_units=len(UNIT_IDS)
charm,
resources=resources,
application_name=APP_NAME,
num_units=len(UNIT_IDS),
series="jammy",
)

# issuing dummy update_status just to trigger an event
Expand Down
9 changes: 7 additions & 2 deletions tests/integration/tls_tests/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None:
async with ops_test.fast_forward():
my_charm = await ops_test.build_charm(".")
resources = {"mongodb-image": METADATA["resources"]["mongodb-image"]["upstream-source"]}
await ops_test.model.deploy(my_charm, num_units=3, resources=resources)
await ops_test.model.deploy(my_charm, num_units=3, resources=resources, series="jammy")
await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=2000)

config = {"generate-self-signed-certificates": "true", "ca-common-name": "Test CA"}
await ops_test.model.deploy(TLS_CERTIFICATES_APP_NAME, channel="beta", config=config)
await ops_test.model.deploy(
TLS_CERTIFICATES_APP_NAME,
channel="beta",
config=config,
series="focal",
)
await ops_test.model.wait_for_idle(
apps=[TLS_CERTIFICATES_APP_NAME], status="active", timeout=1000
)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ envlist = fmt, lint, unit
src_path = {toxinidir}/src/
tst_path = {toxinidir}/tests/
lib_path = {toxinidir}/lib/charms/mongodb
all_path = {[vars]src_path} {[vars]tst_path}
all_path = {[vars]src_path} {[vars]tst_path} {[vars]lib_path}

[testenv]
whitelist_externals = poetry
Expand Down

0 comments on commit 16989be

Please sign in to comment.