Skip to content

Remove dependency to juju-cli for controller_name#1009

Merged
jujubot merged 2 commits intojuju:2.9from
cderici:controller-name-not-found
Jan 23, 2024
Merged

Remove dependency to juju-cli for controller_name#1009
jujubot merged 2 commits intojuju:2.9from
cderici:controller-name-not-found

Conversation

@cderici
Copy link
Copy Markdown
Contributor

@cderici cderici commented Jan 17, 2024

Description

controllers.yaml is read for the controller_name after a connection is established, and this creates a dependency on the juju-cli to be installed in the system, which is not required for pylibjuju.

Fixes #996

QA Steps

Testing this requires a bit of stateful actions. I see two easy ways to test:

  1. Use the integration test I added.

Add import pdb;pdb.set_trace() right before the new_cont.connect( line, and run the integration test with --pdb as follows:

tox -e integration -- -- tests/integration/test_connection.py::test_connection_happy_path --pdb

Before continuing, go find the controllers.yaml and rename it to something else (sort of easier than removing juju-cli etc):

mv controllers.yaml controllers.yaml.tmp

Now continue in the pdb (c) to see if the new connection will be established without a problem.

  1. Do what the integration test is doing manually in the repl:
 $ python -m asyncio
>>> from juju import controller
>>> c=controller.Controller();await c.connect()

Stop at this point to rename the controllers.yaml file.

>>> new_c=controller.Controller()
>>> await new_c.connect(endpoint=c.endpoint, username=c.username, password=c.password, cacert=c.cacert)

This should succeed.

Don't forget to rename your controllers.yaml back:

mv controllers.yaml.tmp controllers.yaml

Notes & Discussion

JUJU-5317

controllers.yaml is read for the controller_name after a connection is
established, and this creates a depends on the juju-cli to be
installed in the system, which is not required for pylibjuju.
@cderici cderici added hint/2.9 going on 2.9 branch area/forward-port to be forward ported - remove label after port labels Jan 17, 2024
@cderici cderici requested a review from jack-w-shaw January 18, 2024 15:20
@cderici
Copy link
Copy Markdown
Contributor Author

cderici commented Jan 23, 2024

/merge

@jujubot jujubot merged commit 4f38c4e into juju:2.9 Jan 23, 2024
@cderici cderici removed the area/forward-port to be forward ported - remove label after port label Feb 7, 2024
@cderici cderici mentioned this pull request Feb 8, 2024
jujubot added a commit that referenced this pull request Feb 13, 2024
#1023

## What's Changed
* Drop use of walrus operator by @freyes in #993
* No controller model access needed for connection with a non-admin user by @cderici in #1003
* Password resolution in connector by @cderici in #1002
* Remove dependency to juju-cli for controller_name by @cderici in #1009

#### Notes & Discussion

JUJU-5413
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants