Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds resource support for charmhub deployments #516

Merged
merged 2 commits into from
Aug 23, 2021

Conversation

tlm
Copy link
Member

@tlm tlm commented Aug 3, 2021

Adds support to pylib Juju for deploying charmhub charms with associated resources.

juju/model.py Outdated Show resolved Hide resolved
@tlm tlm marked this pull request as ready for review August 4, 2021 02:54
@tlm tlm force-pushed the resources-ch-2.9 branch from 646749e to efda862 Compare August 4, 2021 02:58
@tlm tlm force-pushed the resources-ch-2.9 branch from efda862 to ab2e5da Compare August 11, 2021 06:02
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got a python lint error:

examples/charmhub_deploy.py:12:1: E302 expected 2 blank lines, found 1

@tlm tlm force-pushed the resources-ch-2.9 branch from ab2e5da to abf57e7 Compare August 11, 2021 21:35
Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a question, there's one more thing I wish to check tomorrow on resources before I'm done.

juju/model.py Outdated Show resolved Hide resolved
'path': resource.path,
'type_': resource.type_,
'origin': 'store',
'revision': -1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not resource.revision?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't get provided with any resource revisions in the facade call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The resource revision is optional and provided by the user on the cli. Just like they can upload a resource file by specifying it, rather than use the version in the store. Which is missing here too.

https://github.com/juju/juju/blob/7a0b2cd2ebf913530eb97d26f76628d4d8e30c33/resource/resourceadapters/deploy.go#L55

Check out the juju-qa-test charm, it has non k8s resources, you can specify by revision, or upload a file, or neither.

@tlm tlm force-pushed the resources-ch-2.9 branch 2 times, most recently from 13934c8 to dfed876 Compare August 17, 2021 01:59
@tlm tlm force-pushed the resources-ch-2.9 branch from dfed876 to b880396 Compare August 19, 2021 01:47
Copy link
Member

@SimonRichardson SimonRichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix the lint issues, then add the following example for non-k8s models (I've tested and it works):

"""
This example:

1. Connects to the current model
2. Deploy a charm and waits until it reports itself active
3. Destroys the unit and application

"""
from juju import loop
from juju.model import Model


async def main():
    model = Model()
    print('Connecting to model')
    await model.connect()

    try:
        print('Deploying ')
        application = await model.deploy(
            'ch:juju-qa-test',
            application_name='juju-qa-test',
            channel='2.0/edge',
        )

        print('Waiting for active')
        await model.block_until(
            lambda: all(unit.workload_status == 'active'
                        for unit in application.units))

    finally:
        print('Disconnecting from model')
        await model.disconnect()

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

Then we can land this.
Thanks for this.

Add another exmaple to show machine deployment with resources.
@SimonRichardson
Copy link
Member

@tlm LAND IT!

:shipit:

@SimonRichardson
Copy link
Member

$$merge$$

@jujubot jujubot merged commit c9540e6 into juju:2.9 Aug 23, 2021
SimonRichardson added a commit to SimonRichardson/python-libjuju that referenced this pull request Oct 12, 2021
2.9.4
^^^^^

Tuesday October 12 2021

* Charmhub deploy charm by @SimonRichardson in juju#483
* add wait_for_status instead of wait_for_active by @sed-i in juju#517
* Adds resource support for charmhub deployments by @tlm in juju#516
* Fix bug juju#519 and juju#522: Add local resources for bundles by @davigar15 in juju#520
* Patching some missing kwargs by @cderici in juju#527
* Implementing `backup` functionality by @cderici in juju#536
* Fix issue 532: Set the default_series properly by @davigar15 in juju#533
* A random small bug fix by @cderici in juju#541
* Allow ApplicationFacade set_config with non-string values by @cderici in juju#540
* Skip macaroon tests issue 534 by @cderici in juju#542
* Fix issue 530: Check the controller for unsynched models by @cderici in juju#539
* Upgrade setup-python action. by @juanmanuel-tirado in juju#543
* Fix integration tests by @cderici in juju#544
* Bring juju/juju.py into life by @cderici in juju#546
* Extract resources info from apps in locally deployed bundle by cderici in juju#552
* Fix for simple bug in bundle deployment code self.charm -> self['charm'] by @jnsgruk in ttps://github.com/juju/pull/558
* Fix integration tests continued by @cderici in ttps://github.com/juju/pull/547
* Get the config dir resolve logic into one place by @cderici in ttps://github.com/juju/pull/555
* Complete the backups functionality by @cderici in ttps://github.com/juju/pull/556
jujubot added a commit that referenced this pull request Oct 12, 2021
#561

2.9.4
^^^^^

Tuesday October 12 2021

* Charmhub deploy charm by @SimonRichardson in #483
* add wait_for_status instead of wait_for_active by @sed-i in #517
* Adds resource support for charmhub deployments by @tlm in #516
* Fix bug #519 and #522: Add local resources for bundles by @davigar15 in #520
* Patching some missing kwargs by @cderici in #527
* Implementing `backup` functionality by @cderici in #536
* Fix issue 532: Set the default_series properly by @davigar15 in #533
* A random small bug fix by @cderici in #541
* Allow ApplicationFacade set_config with non-string values by @cderici in #540
* Skip macaroon tests issue 534 by @cderici in #542
* Fix issue 530: Check the controller for unsynched models by @cderici in #539
* Upgrade setup-python action. by @juanmanuel-tirado in #543
* Fix integration tests by @cderici in #544
* Bring juju/juju.py into life by @cderici in #546
* Extract resources info from apps in locally deployed bundle by cderici in #552
* Fix for simple bug in bundle deployment code self.charm -> self['charm'] by @jnsgruk in ttps://github.com//pull/558
* Fix integration tests continued by @cderici in ttps://github.com//pull/547
* Get the config dir resolve logic into one place by @cderici in ttps://github.com//pull/555
* Complete the backups functionality by @cderici in ttps://github.com//pull/556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants