juju / python-libjuju

Python library for the Juju API
Apache License 2.0
57 stars 93 forks source link

Model.deploy() failing while specifying a k8s charm bundle #1032

Closed sudeephb closed 1 month ago

sudeephb commented 3 months ago

I have the following piece of code to deploy a bundle(cos-lite):

    await model.deploy(
        "cos-lite",
        channel="edge",
        trust=True,
        overlays=[str(Path(__file__).parent.resolve() / "offers-overlay.yaml")], # the file exists
    )

The deployment fails with the following error:

await model.deploy(
.tox/integration/lib/python3.10/site-packages/juju/model.py:1706: in deploy
    await handler.execute_plan()
.tox/integration/lib/python3.10/site-packages/juju/bundle.py:386: in execute_plan
    await self._resolve_charms()
.tox/integration/lib/python3.10/site-packages/juju/bundle.py:372: in _resolve_charms
    charm_url, charm_origin = await self.model._resolve_charm(charm_url, origin)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <juju.model.Model object at 0x774307592ef0>
url = <juju.url.URL object at 0x7743054de020>
origin = <class 'juju.client._definitions.CharmOrigin'>({'architecture': 'amd64', 'base': <class 'juju.client._definitions.Base...key': None, 'revision': None, 'risk': 'edge', 'source': 'charm-hub', 'track': '', 'type_': None, 'unknown_fields': {}})
force = False, series = None, model_config = None

    async def _resolve_charm(self, url, origin, force=False, series=None, model_config=None):
        """Calls Charms.ResolveCharms to resolve all the fields of the
        charm_origin and also the url and the supported_series

        :param str url: The url of the charm
        :param client.CharmOrigin origin: The manually constructed origin
        based on what we know about the charm and the deployment so far

        Returns the confirmed origin returned by the Juju API to be used in
        calls like ApplicationFacade.Deploy

        :returns str, client.CharmOrigin, [str]
        """
        charms_cls = client.CharmsFacade
        if charms_cls.best_facade_version(self.connection()) < 3:
            raise JujuError("resolve charm")

        charms_facade = charms_cls.from_connection(self.connection())

        # TODO (cderici): following part can be refactored out, since the
        #  origin should be set (including the base) before calling this,
        #  though all tests need to run (in earlier versions too) before
        #  committing to make sure there's no regression
        source = Source.CHARM_HUB.value

        resolve_origin = {'source': source, 'architecture': origin.architecture,
                          'track': origin.track, 'risk': origin.risk,
                          'base': origin.base, 'revision': origin.revision,
                          }

        resp = await charms_facade.ResolveCharms(resolve=[{
            'reference': str(url),
            'charm-origin': resolve_origin
        }])
        if len(resp.results) != 1:
            raise JujuError("expected one result, received {}".format(resp.results))

        result = resp.results[0]
        if result.error:
>           raise JujuError(result.error.message)
E           juju.errors.JujuError: selecting releases: charm or bundle not found for channel "edge", base "amd64/ubuntu/edge"
E           available releases are:
E             channel "latest/stable": available series are: focal
E             channel "latest/candidate": available series are: focal
E             channel "latest/beta": available series are: focal
E             channel "latest/edge": available series are: focal
E             channel "1.0/stable": available series are: focal
E             channel "1.0/candidate": available series are: focal
E             channel "1.0/beta": available series are: focal
E             channel "1.0/edge": available series are: focal

.tox/integration/lib/python3.10/site-packages/juju/model.py:[184](https://github.com/sudeephb-test-organization/hardware-observer-operator/actions/runs/8285741032/job/22674138237#step:10:185)2: JujuError

Deploying the same using juju CLI command combined with subprocess.run() works perfectly fine. The environment is a microk8s cloud created on a github runner.

Aflynn50 commented 2 months ago

Hey Sudeep, which version of pylibjuju and juju are you using?

sudeephb commented 2 months ago

@Aflynn50 Both juju and py libjuju are version 3.1.0.

Aflynn50 commented 2 months ago

Can you try with the latest pylibjuju 3.4.0? The version of pylibjuju does not have to match the juju version, pylibjuju versions 3.x work with any previous version of juju as well.

I'm not certain but I believe this bug should already be fixed in the latest version.

github-actions[bot] commented 1 month ago

This issue is marked as incomplete because it has been open 30 days with no activity. Please remove incomplete label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 5 days with no activity.