Skip to content

Commit

Permalink
fix(model): unify parse_storage_constraint or client.Constraints duri…
Browse files Browse the repository at this point in the history
…ng deploy

Signed-off-by: Adam Dyess <adam.dyess@canonical.com>
  • Loading branch information
addyess committed Aug 23, 2024
1 parent 6c6d70d commit 3eb4cd3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 9 additions & 2 deletions juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,13 @@ async def _deploy(self, charm_url, application, series, config,

app_facade = client.ApplicationFacade.from_connection(self.connection())

# Prepare all storage constraints
storage = storage or dict()
storage = {
k: v if isinstance(v, client.Constraints) else parse_storage_constraint(v)
for k, v in storage.items()
}

if server_side_deploy:
# Call DeployFromRepository
app = client.DeployFromRepositoryArg(
Expand All @@ -2116,7 +2123,7 @@ async def _deploy(self, charm_url, application, series, config,
devices=devices,
dryrun=False,
placement=placement,
storage={k: parse_storage_constraint(v) for k, v in (storage or dict()).items()},
storage=storage,
trust=trust,
base=charm_origin.base,
channel=channel,
Expand Down Expand Up @@ -2151,7 +2158,7 @@ async def _deploy(self, charm_url, application, series, config,
endpoint_bindings=endpoint_bindings,
num_units=num_units,
resources=resources,
storage={k: parse_storage_constraint(v) for k, v in (storage or dict()).items()},
storage=storage,
placement=placement,
devices=devices,
attach_storage=attach_storage,
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,21 @@ async def test_model_cache_update():
await controller.destroy_models(model_name)


@base.bootstrapped
async def test_deploy_with_storage():
async with base.CleanModel() as model:
await model.deploy(
'postgresql',
storage={"pgdata": {"size": 1024, "count": 1}},
)
await model.wait_for_idle(status="active")
storages = await model.list_storage()
await model.list_storage(filesystem=True)
await model.list_storage(volume=True)

assert any([tag.storage("pgdata") in s['storage-tag'] for s in storages])


@base.bootstrapped
async def test_add_storage():
pytest.skip('skip in favour of test_add_and_list_storage')
Expand Down

0 comments on commit 3eb4cd3

Please sign in to comment.