Skip to content

Commit 74d5ed3

Browse files
committed
Get series from deployed app instead of metadata when charm upgrade
Fixes #668 Charmhub is modeling the charm data separately from where the charm is deployed, therefore the series is not a part of the metadata anymore. So instead of getting the series from the metadata we now get it from the deployed application first, then we try the model config, if everything fails then we look at the metadata as a last resort (mostly to keep backwards compatibility).
1 parent 768d7ff commit 74d5ed3

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

juju/application.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,18 @@ async def unexpose(self, exposed_endpoints=None):
339339
log.debug("Unexposing %s", self.name)
340340
return await app_facade.Unexpose(application=self.name)
341341

342+
async def get_series(self):
343+
"""Return the series on which the application is deployed
344+
345+
:return: str series
346+
"""
347+
app_facade = self._facade()
348+
349+
log.debug(
350+
'Getting series for %s', self.name)
351+
352+
return (await app_facade.Get(application=self.name)).series
353+
342354
async def get_config(self):
343355
"""Return the configuration settings dict for this application.
344356
"""
@@ -728,9 +740,12 @@ async def local_refresh(
728740
charm_dir = path.expanduser().resolve()
729741
model_config = await self.get_config()
730742

731-
series = await get_charm_series(charm_dir, self.model)
743+
series = (
744+
await self.get_series() or
745+
self.model.info.get('default-series', '') or
746+
await get_charm_series(charm_dir, self.model)
747+
)
732748
if not series:
733-
model_config = await self.get_config()
734749
default_series = model_config.get("default-series")
735750
if default_series:
736751
series = default_series.value
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: ubuntu
2-
series: ["focal"]
2+
series: ["bionic", "focal"]
33
summary: "test"
44
description: "test"
55
maintainers: ["test"]

0 commit comments

Comments
 (0)