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

Local resources in sidecar charms do not work #550

Closed
davigar15 opened this issue Sep 28, 2021 · 2 comments · Fixed by #552
Closed

Local resources in sidecar charms do not work #550

davigar15 opened this issue Sep 28, 2021 · 2 comments · Fixed by #552

Comments

@davigar15
Copy link

davigar15 commented Sep 28, 2021

Hello,

Deploying a bundle with local resources do not work.

Steps to reproduce:

The bundle:


bundle: kubernetes
applications:
  onos2:
    charm: "../charms/onos.charm"
    scale: 1
    options:
      admin-password: admin
    resources:
      onos-image: onosproject/onos:2.6.0
"""
This example:

1. Connects to the current model
2. Deploy a bundle and waits until it reports itself active
3. Destroys the units and applications

"""
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(
            './examples/k8s-local-bundle/bundle.yaml',
        )

        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())

juju status:

Model         Controller  Cloud/Region        Version  SLA          Timestamp
test-libjuju  osm-vca     microk8s/localhost  2.9.9    unsupported  17:42:13+02:00

App    Version  Status   Scale  Charm  Store  Channel  Rev  OS          Address  Message
onos2           waiting    0/1  onos   local             0  kubernetes           installing agent

Unit     Workload  Agent       Address  Ports  Message
onos2/0  waiting   allocating                  installing agent

juju debug-log:

controller-0: 17:29:40 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:29:40 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:29:43 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:29:43 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:29:43 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:29:43 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:29:46 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:29:46 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:29:46 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:29:46 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:29:49 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:29:49 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:29:49 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:29:49 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:29:52 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:29:52 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:29:52 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:29:52 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:29:55 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:29:55 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:29:55 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:29:55 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:29:58 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:29:59 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:29:59 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:29:59 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:30:02 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:30:02 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:30:02 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:30:02 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:30:05 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:30:05 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:30:05 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:30:05 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:30:08 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:30:08 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:30:08 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:30:08 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:30:11 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:30:11 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
controller-0: 17:30:11 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": restart immediately
controller-0: 17:30:11 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:30:14 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:30:14 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:30:14 ERROR juju.worker.caasapplicationprovisioner.runner exited "onos2": getting OCI image resources: unable to fetch OCI image resources for onos2: resource#onos2/onos-image not found
controller-0: 17:30:14 INFO juju.worker.caasapplicationprovisioner.runner restarting "onos2" in 3s
controller-0: 17:30:17 INFO juju.worker.caasapplicationprovisioner.runner start "onos2"
controller-0: 17:30:17 INFO juju.worker.caasapplicationprovisioner.runner stopped "onos2", err: restart immediately
@juanmanuel-tirado
Copy link
Contributor

Probably related to:
https://bugs.launchpad.net/juju/+bug/1942937

@cderici
Copy link
Contributor

cderici commented Oct 4, 2021

cderici added a commit to cderici/python-libjuju that referenced this issue Oct 4, 2021
jujubot added a commit that referenced this issue Oct 5, 2021
…s-550

#552

### Description

Problem is described in #550. This PR solves it by getting resources information from the deployed bundle (instead of setting it to empty as before).

### QA Steps

```
$ pyton3 -m tox -e py3 -- tests/unit/test_bundle.py

all tests should pass

$ python3 examples/deploy_local_bundle_with_resources.py 

Connecting to model
unknown facade CAASModelConfigManager
unexpected facade CAASModelConfigManager found, unable to decipher version to use
unknown facade RaftLease
unexpected facade RaftLease found, unable to decipher version to use
unknown facade Secrets
unexpected facade Secrets found, unable to decipher version to use
unknown facade SecretsManager
unexpected facade SecretsManager found, unable to decipher version to use
unknown facade SecretsRotationWatcher
unexpected facade SecretsRotationWatcher found, unable to decipher version to use
Deploying bundle
Waiting for active
Successfully deployed!
Removing bundle
Disconnecting from model
Success
```

### Notes & Discussion

Fixes #550
wolsen added a commit to wolsen/python-libjuju that referenced this issue Dec 21, 2021
PR juju#600 updated the get_public_address method for units to look up the
public address in the ApplicationFacade's UnitsInfo object. However,
the change used the get(str) method of the Type class which performs a
lookup in the json dictionary using the hyphenated key rather than the
underscore key, thus always returns None since this key is not in the
JSON dictionary. Changing it to return the lookup of 'public-address'
instead of 'public_address' results in the unit's public address being
returned.

Fixes juju#550

Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
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 a pull request may close this issue.

3 participants