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

Model.consume() from a different controller doesn't work #1031

Closed
sudeephb opened this issue Mar 7, 2024 · 1 comment
Closed

Model.consume() from a different controller doesn't work #1031

sudeephb opened this issue Mar 7, 2024 · 1 comment
Assignees
Labels
hint/good-first-issue a small bug good for newcomers hint/3.x going on main branch kind/bug indicates a bug in the project

Comments

@sudeephb
Copy link

sudeephb commented Mar 7, 2024

Calling model.consume as shown below causes an error.

await model.consume(
               f"admin/{k8s_model.name}.grafana-dashboards",
               application_alias="grafana",
               controller_name=k8s_ctl.controller_name,
        )

The error looks like this:

FAILED ... - juju.errors.JujuError: ['application offer "admin/current-model.grafana-dashboards" not found'] 

where, current-model is the model name, and grafana-dashboards offer is exposed.

As a workaround, using juju CLI works ie. the following works fine

        cmd = [
            "juju",
            "consume",
            "--model",
            f"current-controller:current-model",
            f"{k8s_ctl.controller_name}:admin/{k8s_model.name}.grafana-dashboards",
        ]
        subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

The name of the model is the same in both controllers.
python-libjuju version is 3.3.1.1

@cderici cderici added kind/bug indicates a bug in the project hint/3.x going on main branch hint/good-first-issue a small bug good for newcomers labels Mar 13, 2024
@Aflynn50
Copy link
Contributor

This works if you also put the controller name in the endpoint url, for example:

await model.consume(
               f"k8s_ctl.controller_name:admin/{k8s_model.name}.grafana-dashboards",
               application_alias="grafana",
               controller_name=k8s_ctl.controller_name,
      )

The name of the argument is pretty confusing though, I will bring a PR to allow you to just specify the controller name in the endpoint rather than having to do it separately as well.

jujubot added a commit that referenced this issue Apr 3, 2024
#1038

#### Description

`consume` takes a `controller_name` argument. This is not needed and should be automatically generated from the offer url. A deprecation warning is logged and the variable is not used.

Also update offer and consume integration tests to no longer be skipped.

This helps avoid #1031 

#### QA Steps
```
juju bootstrap lxd c1
juju add-model offerer
juju deploy juju-qa-dummy-source dummy-source
juju offer dummy-source:sink
juju bootstrap lxd c2
python -m asyncio

# In REPL
from juju import model
m = model.Model()
await m.connect()
await m.consume("c1:admin/offerer.dummy-source")

# Exit REPL
juju status
# Confirm SAAS exists
juju remove-saas dummy-source
# Confirm removal
python -m asyncio

# In REPL
from juju import model
m = model.Model()
await m.connect()
await m.consume("admin/offerer.dummy-source", controller_name="c1")

# Exit REPL
juju status
# Confirm SAAS exists
juju remove-saas dummy-source
# Confirm removal
python -m asyncio

# In REPL
from juju import model
m = model.Model()
await m.connect()
await m.consume("c1:admin/offerer.dummy-source", controller_name="c1")

```
All CI tests need to pass.
@Aflynn50 Aflynn50 closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hint/good-first-issue a small bug good for newcomers hint/3.x going on main branch kind/bug indicates a bug in the project
Projects
None yet
Development

No branches or pull requests

3 participants