Skip to content

Commit

Permalink
Merge branch 'main' into KU-405/etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoflorido committed Mar 22, 2024
2 parents 8e76b79 + 40e7b85 commit 208cbf6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
17 changes: 0 additions & 17 deletions charms/worker/lxd-profile.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ def switch(self, name: str, path: Path):
app["channel"] = None


async def cloud_profile(ops_test: OpsTest):
"""Apply lxd-profile to the model if the juju cloud is lxd."""
controller = await ops_test.model.get_controller()
cloud = await controller.cloud()
if cloud.cloud.type_ == "lxd":
lxd = LXDSubstrate(None, None)
profile_name = f"juju-{ops_test.model.name}"
lxd.remove_profile(profile_name)
lxd.apply_profile("k8s.profile", profile_name)


@contextlib.asynccontextmanager
async def deploy_model(
request: pytest.FixtureRequest,
Expand Down Expand Up @@ -193,6 +204,7 @@ async def deploy_model(
config=config,
)
with ops_test.model_context(model_name) as the_model:
await cloud_profile(ops_test)
async with ops_test.fast_forward("60s"):
await the_model.deploy(bundle.render)
await the_model.wait_for_idle(
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/cos_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ def apply_profile(
target_profile_name (Optional[str]): Name of the target profile. Defaults to 'cos-profile'.
"""
profile_path = Path("tests/integration/data") / profile_name
with open(profile_path) as file:

with profile_path.open() as file:
try:
raw_profile = yaml.safe_load(file)
config = raw_profile.get("config", {})
devices = raw_profile.get("devices", {})
self.client.profiles.create(target_profile_name, config=config, devices=devices)
log.info(f"Profile {target_profile_name} applied successfully.")
except (yaml.YAMLError, Exception) as e:
log.error(f"Failed to read or apply LXD profile: {e}")
log.exception(f"Failed to read or apply LXD profile: {e}")

def create_container(self, name: str):
"""Create a container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See LICENSE file for licensing details.
description: "LXD profile for Canonical Kubernetes"
config:
boot.autostart: "true"
linux.kernel_modules: ip_vs,ip_vs_rr,ip_vs_wrr,ip_vs_sh,ip_tables,ip6_tables,iptable_raw,netlink_diag,nf_nat,overlay,br_netfilter,xt_socket
raw.lxc: |
lxc.apparmor.profile=unconfined
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/data/test-bundle-etcd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ applications:
num_units: 1
options:
datastore: etcd
k8s-worker:
charm: k8s-worker
channel: latest/edge
num_units: 1
relations:
- [k8s, k8s-worker:cluster]
- [etcd, easyrsa:client]
- [etcd, k8s:etcd]

0 comments on commit 208cbf6

Please sign in to comment.