Skip to content

Commit d67be90

Browse files
authored
Merge pull request #896 from cderici/series-local-bundle-manifest
#896 #### Description This fixes a duplication introduced in this cherry pick bd06a24, and adds functionality to determine series using utils for base, which already has the logic for checking `manifest.yaml` for bases (alongside with `metadata.yaml` etc). Fixes #891 #### QA Steps This adds the simplified version of the scenario in #891 as an integration test, so the following should pass: ```sh tox -e integration -- tests/integration/test_model.py::test_deploy_bundle_local_charm_series_manifest ``` **Alternatively**, get the onos charm: ```sh wget https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages/-/raw/master/charm-packages/pebble_charm_vnf/juju-bundles/charms/onos_ubuntu-20.04-amd64.charm ``` Write the following in a `bundle.yaml`: ```yaml description: Onos Bundle bundle: kubernetes applications: onos: charm: './onos_ubuntu-20.04-amd64.charm' scale: 1 options: admin-password: admin resources: onos-image: onosproject/onos:2.6.0 ``` Deploy with this change, should go through just fine without complaining about the series: ```sh $ python -m asyncio asyncio REPL 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. >>> import asyncio >>> from juju import model;m=model.Model();await m.connect();await m.deploy('./bundle.yaml') unknown facade AgentLifeFlag unexpected facade AgentLifeFlag found, unable to decipher version to use [<Application entity_id="onos">] >>> ```
2 parents 36d078b + 8983b25 commit d67be90

7 files changed

Lines changed: 54 additions & 2 deletions

File tree

juju/bundle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ async def _handle_local_charms(self, bundle, bundle_dir):
127127
metadata = utils.get_local_charm_metadata(charm_dir)
128128
series = await get_charm_series(metadata, self.model)
129129
if not series:
130-
metadata = utils.get_local_charm_metadata(charm_dir)
131-
series = await get_charm_series(metadata, self.model)
130+
base = utils.get_local_charm_base(None, charm_path, client.Base)
131+
series = utils.base_channel_to_series(base.channel)
132+
if not series:
132133
raise JujuError(
133134
"Couldn't determine series for charm at {}. "
134135
"Add a 'series' key to the bundle.".format(charm_dir))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
applications:
2+
test1:
3+
charm: "../charm-manifest"
4+
num_units: 1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
options:
2+
status:
3+
type: string
4+
default: "active"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
status="$(config-get status)"
4+
5+
if [[ "$status" == "error" ]]; then
6+
if [[ -e .errored ]]; then
7+
status="active"
8+
else
9+
touch .errored
10+
exit 1
11+
fi
12+
fi
13+
status-set "$status"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
analysis:
2+
attributes:
3+
- name: language
4+
result: python
5+
- name: framework
6+
result: operator
7+
bases:
8+
- architectures:
9+
- amd64
10+
channel: '20.04'
11+
name: ubuntu
12+
charmcraft-started-at: '2021-08-20T08:09:00.639806Z'
13+
charmcraft-version: 1.2.1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: charm
2+
summary: "test"
3+
description: "test"
4+
maintainers: ["test"]

tests/integration/test_model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,19 @@ async def test_deploy_bundle_local_charms(event_loop):
127127
assert model.units['test2/0'].workload_status == 'active'
128128

129129

130+
@base.bootstrapped
131+
@pytest.mark.asyncio
132+
async def test_deploy_bundle_local_charm_series_manifest(event_loop):
133+
bundle_path = TESTS_DIR / 'integration' / 'bundle' / 'local-manifest.yaml'
134+
135+
async with base.CleanModel() as model:
136+
await model.deploy(bundle_path)
137+
await wait_for_bundle(model, bundle_path)
138+
assert set(model.units.keys()) == set(['test1/0'])
139+
assert model.units['test1/0'].agent_status == 'idle'
140+
assert model.units['test1/0'].workload_status == 'active'
141+
142+
130143
@base.bootstrapped
131144
@pytest.mark.asyncio
132145
async def test_deploy_invalid_bundle(event_loop):

0 commit comments

Comments
 (0)