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

[Bug]: controller.controller_name() return "None" when connecting with endpoints #771

Closed
agileshaw opened this issue Nov 16, 2022 · 8 comments
Labels
hint/2.9 going on 2.9 branch kind/bug indicates a bug in the project

Comments

@agileshaw
Copy link

Description

When connecting to a controller implicitly or with its name, running controller.controller_name will provide us with the name of the current controller, which is the expected behavior.

However, when connecting the controller with its endpoint and credentials, controller.controller_name returns "None".

Urgency

Annoying bug in our test suite

Python-libjuju version

2.9.11, 3.0.4

Juju version

2.9.37

Reproduce / Test

from juju.controller import Controller
import asyncio

async def juju_stats():
    controller1 = Controller()
    await controller1.connect() #implicit connection
    print(controller1.controller_name) # output: controller-name
    await controller1.disconnect()

    controller2 = Controller()
    await controller2.connect(endpoint="<ip>:17070", username="admin",
        password="admin_pass", cacert="ca_cert") # explicit connection with credential values
    print(controller2.controller_name) # output: None
    await controller2.disconnect()

asyncio.run(juju_stats())
@agileshaw agileshaw added the kind/bug indicates a bug in the project label Nov 16, 2022
@github-actions
Copy link

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 github-actions bot added the state/incomplete need more information label Jul 29, 2023
@agileshaw
Copy link
Author

This issue still exists in libjuju version 2.9.44.0

@github-actions github-actions bot removed the state/incomplete need more information label Aug 1, 2023
@cderici cderici added the hint/2.9 going on 2.9 branch label Aug 3, 2023
@Maxcode123
Copy link

I'd like to address this issue. I think it should be handled in the connector layer, specifically in the connect method of the Connector. As far as I understand this requires to map the endpoint argument (or username maybe?) to a model (or controller) and then fetch that model's controller. I'm wondering if there's a smarter way than searching for the specified endpoint in controllers.yaml?

@github-actions
Copy link

github-actions bot commented Sep 4, 2023

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 github-actions bot added the state/incomplete need more information label Sep 4, 2023
@github-actions
Copy link

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2023
@agileshaw
Copy link
Author

agileshaw commented Oct 12, 2023

I tested the sample code with libjuju 2.9.44.1 and confirmed the issue still exists. Can we reopen this issue?

@cderici
Copy link
Contributor

cderici commented Oct 12, 2023

I tested the sample code with libjuju 2.9.44.1 and confirmed the issue still exists. Can we reopen this issue?

For sure, looks like it's not very complicated, I'll take a closer look soon 👍

@cderici cderici reopened this Oct 12, 2023
@cderici cderici removed the state/incomplete need more information label Oct 12, 2023
cderici added a commit to cderici/python-libjuju that referenced this issue Oct 13, 2023
jujubot added a commit that referenced this issue Oct 17, 2023
#964

#### Description

This allows all kinds of connections to set the `controller_name` by default by looking up the `endpoints` in the `jujudata`.

Fixes #771

#### QA Steps

Manual QA should follow the steps described in #771.

Find the details of a controller you bootstrapped (any controller would do):

```sh
 $ juju show-controller --show-password
```

Grab the details there and plug them into either a script or in the repl (repl is awkward to use with the certificate):

```python
 c = Controller()
 await c.connect(endpoint="<ip>:17070", username="admin", password="admin_pass", cacert="ca_cert") # explicit connection with credential values
 # check the name
 print(c.controller_name)
```

All CI tests need to pass.

#### Notes & Discussion

JUJU-4781
@cderici
Copy link
Contributor

cderici commented Oct 17, 2023

#964 closes this.

@cderici cderici closed this as completed Oct 17, 2023
cderici added a commit to cderici/python-libjuju that referenced this issue Oct 18, 2023
jujubot added a commit that referenced this issue Oct 20, 2023
#966

#### Description

This is a forward port for the fix #964 for the issue #771 that was on 2.9, bringing it into 3.x.

#### QA Steps

Manual QA should follow the steps described in #771.

Find the details of a controller you bootstrapped (any controller would do):

```sh
 $ juju show-controller --show-password
```

Grab the details there and plug them into either a script or in the repl (repl is awkward to use with the certificate):

```python
 c = Controller()
 await c.connect(endpoint="<ip>:17070", username="admin", password="admin_pass", cacert="ca_cert") # explicit connection with credential values
 # check the name
 print(c.controller_name)
```

All CI tests need to pass.

#### Notes & Discussion

JUJU-4781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hint/2.9 going on 2.9 branch kind/bug indicates a bug in the project
Projects
None yet
Development

No branches or pull requests

3 participants