Skip to content

Commit ab23ce3

Browse files
authored
Merge pull request #754 from cderici/small-fixes-for-3.0
#754 #### Description This includes a bunch of small fixes/patches to make sure that everything's working fine with the `Juju 3.0` (along with the `2.9` track -- e.g. coming `2.9.36`), tested currently against `3.0/candidate`. #### QA Steps Bootstrap with juju `3.0/edge` and run: ``` tox -e integration ``` which goes through all the integration tests. The `tests/integration/test_model.py::test_storage_pools` might fail if you're not using lxd, but other than that everything should be all green. #### Notes & Discussion * So this PR makes sure that we're good with `juju 3.0` (I manually ran the integration tests on aws) * #752 makes sure we're good with `juju 2.9.36` * And the CI tests are currently running against `latest/stable` (juju `2.9.35`), so we should be good there too. So the `pylibjuju 3.0.3` should be ready to go after this lands.
2 parents 6d81ce6 + 0dc720b commit ab23ce3

17 files changed

Lines changed: 14548 additions & 46 deletions

juju/application.py

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ async def get_series(self):
368368
log.debug(
369369
'Getting series for %s', self.name)
370370

371-
return (await app_facade.Get(application=self.name)).series
371+
appGetResults = (await app_facade.Get(application=self.name))
372+
if self._facade_version() >= 15:
373+
base_channel = appGetResults.base.channel
374+
return utils.base_channel_to_series(base_channel)
375+
return appGetResults.series
372376

373377
async def get_config(self):
374378
"""Return the configuration settings dict for this application.
@@ -768,19 +772,22 @@ async def refresh(
768772
else:
769773
resource_ids = None
770774

775+
set_charm_args = {
776+
'application': self.entity_id,
777+
'charm_url': charm_url,
778+
'charm_origin': dest_origin,
779+
'config_settings': None,
780+
'config_settings_yaml': None,
781+
'force': force,
782+
'force_units': force_units,
783+
'resource_ids': resource_ids,
784+
'storage_constraints': None,
785+
}
786+
if self.connection.is_using_old_client:
787+
set_charm_args['force_series'] = force_series
788+
771789
# Update the application
772-
await app_facade.SetCharm(
773-
application=self.entity_id,
774-
charm_url=charm_url,
775-
charm_origin=dest_origin,
776-
config_settings=None,
777-
config_settings_yaml=None,
778-
force=force,
779-
force_series=force_series,
780-
force_units=force_units,
781-
resource_ids=resource_ids,
782-
storage_constraints=None,
783-
)
790+
await app_facade.SetCharm(**set_charm_args)
784791

785792
await self.model.block_until(
786793
lambda: self.data['charm-url'] == charm_url
@@ -830,19 +837,23 @@ async def local_refresh(
830837
metadata,
831838
resources=resources)
832839

840+
set_charm_args = {
841+
'application': self.entity_id,
842+
'charm_origin': charm_origin,
843+
'charm_url': charm_url,
844+
'config_settings': None,
845+
'config_settings_yaml': None,
846+
'force': force,
847+
'force_units': force_units,
848+
'resource_ids': resources,
849+
'storage_constraints': None,
850+
}
851+
852+
if self.connection.is_using_old_client:
853+
set_charm_args['force_series'] = force_series
854+
833855
# Update application
834-
await app_facade.SetCharm(
835-
application=self.entity_id,
836-
charm_origin=charm_origin,
837-
charm_url=charm_url,
838-
config_settings=None,
839-
config_settings_yaml=None,
840-
force=force,
841-
force_series=force_series,
842-
force_units=force_units,
843-
resource_ids=resources,
844-
storage_constraints=None,
845-
)
856+
await app_facade.SetCharm(**set_charm_args)
846857

847858
await self.model.block_until(
848859
lambda: self.data['charm-url'] == charm_url

juju/client/old_clients/_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66

77
from juju.client.old_clients import _client7, _client1, _client3, _client2, \
8-
_client4, _client6, _client5, _client11, _client9, _client18, _client15
8+
_client4, _client6, _client5, _client11, _client9, _client18, _client15, \
9+
_client10, _client12, _client13, _client14
910

1011

1112
CLIENTS = {
@@ -20,6 +21,10 @@
2021
"9": _client9,
2122
"18": _client18,
2223
"15": _client15,
24+
"10": _client10,
25+
"12": _client12,
26+
"13": _client13,
27+
"14": _client14,
2328
}
2429

2530

juju/client/old_clients/_client10.py

Lines changed: 3433 additions & 0 deletions
Large diffs are not rendered by default.

juju/client/old_clients/_client12.py

Lines changed: 4508 additions & 0 deletions
Large diffs are not rendered by default.

juju/client/old_clients/_client13.py

Lines changed: 4571 additions & 0 deletions
Large diffs are not rendered by default.

juju/client/old_clients/_client14.py

Lines changed: 1908 additions & 0 deletions
Large diffs are not rendered by default.

juju/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,12 @@ def get_local_charm_base(series, channel_from_arg, charm_metadata,
382382
charm_path)
383383

384384
return baseCls(channel_for_base, os_name_for_base)
385+
386+
387+
def base_channel_to_series(channel):
388+
"""Returns the series string using the track inside the base channel
389+
390+
:param str channel: is track/risk (e.g. 20.04/stable)
391+
:return: str series (e.g. focal)
392+
"""
393+
return get_version_series(origin.Channel.parse(channel).track)
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"

tests/charm-with-storage/dispatch

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: test-charm-with-storage
2+
series: ["focal"]
3+
summary: "test charm"
4+
description: "test"
5+
maintainers: ["test"]
6+
7+
storage:
8+
pgdata:
9+
type: filesystem
10+
description: "test storage"

0 commit comments

Comments
 (0)