juju / python-libjuju

Python library for the Juju API
Apache License 2.0
60 stars 101 forks source link

Cannot deploy a k8s bundle which contain local charms that need resources #472

Closed davigar15 closed 2 years ago

davigar15 commented 3 years ago

Hello,

I found an issue deploying a k8s bundle through libjuju that is causing two problems:

This is the bundle I have been testing with:

description: Squid Bundle
bundle: kubernetes
applications:
  squid-libjuju:
    charm: ./squid
    scale: 1
    resources:
      image: sameersbn/squid:3.5.27-1

The charm can be downloaded executing this command:

charm pull cs:~charmed-osm/squid-0

Script used for the testing:

from juju import loop
from juju.model import Model

async def main():
    model = Model()
    print('Connecting to model')
    # Connect to current model with current user, per Juju CLI
    await model.connect()

    try:
        print('Deploying bundle')
        applications = await model.deploy(
            './k8s-bundle',
        )

        print('Waiting for active')
        await model.block_until(
            lambda: all(unit.workload_status == 'active'
                        for application in applications for unit in application.units))
        print("Successfully deployed!")
        print('Removing bundle')
        for application in applications:
            await application.remove()
    finally:
        print('Disconnecting from model')
        await model.disconnect()
        print("Success")

if __name__ == '__main__':
    loop.run(main())

Error when deploying it with libjuju:

Connecting to model
Deploying bundle
Disconnecting from model
Success
Traceback (most recent call last):
  File "/home/davigar15/code/python-libjuju/lib/python3.8/site-packages/theblues/charmstore.py", line 78, in _get
    response.raise_for_status()
  File "/home/davigar15/code/python-libjuju/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.jujucharms.com/charmstore/v5/k8s-bundle/meta/any?include=bundle-machine-count&include=bundle-metadata&include=bundle-unit-count&include=charm-actions&include=charm-config&include=charm-metadata&include=common-info&include=extra-info&include=owner&include=published&include=resources&include=supported-series&include=terms

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../deploy_bundle.py", line 40, in <module>
    loop.run(main())
  File "/home/davigar15/code/python-libjuju/juju/loop.py", line 38, in run
    raise task.exception()
  File "../deploy_bundle.py", line 21, in main
    applications = await model.deploy(
  File "/home/davigar15/code/python-libjuju/juju/model.py", line 1419, in deploy
    entity = await self.charmstore.entity(entity_url, channel=channel,
  File "/home/davigar15/code/python-libjuju/juju/model.py", line 2303, in coro
    return await self.loop.run_in_executor(None, method)
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/davigar15/code/python-libjuju/lib/python3.8/site-packages/theblues/charmstore.py", line 147, in entity
    return self._meta(entity_id, includes, channel=channel)
  File "/home/davigar15/code/python-libjuju/lib/python3.8/site-packages/theblues/charmstore.py", line 127, in _meta
    data = self._get(url)
  File "/home/davigar15/code/python-libjuju/lib/python3.8/site-packages/theblues/charmstore.py", line 82, in _get
    raise EntityNotFound(url)
theblues.errors.EntityNotFound: https://api.jujucharms.com/charmstore/v5/./k8s-bundle/meta/any?include=bundle-machine-count&include=bundle-metadata&include=bundle-unit-count&include=charm-actions&include=charm-config&include=charm-metadata&include=common-info&include=extra-info&include=owner&include=published&include=resources&include=supported-series&include=terms
cderici commented 2 years ago

Just tried this again and it seems to be working well (i.e. not doing the stuff mentioned in the description). So closing.