juju / python-libjuju

Python library for the Juju API
Apache License 2.0
60 stars 101 forks source link

[Bug]: ImportError: No supported version for facade: ModelConfigFacade #770

Closed sed-i closed 1 year ago

sed-i commented 1 year ago

Description

Integration test fails with a facade error. Pinning juju == 2.9.10 works (still fails later for OSError: [Errno 9] Bad file descriptor but that's a different story).

tests/integration/test_grafana_dashboards.py::test_build_and_deploy 
----------------------------------------------------------------------------------- live log setup ------------------------------------------------------------------------------------
INFO     pytest_operator.plugin:plugin.py:625 Adding model chdv29:test-grafana-dashboards-8uwh on cloud microk8s
ERROR    asyncio:base_events.py:1744 Task exception was never retrieved
future: <Task finished name='Task-36' coro=<Model._watch.<locals>._all_watcher() done, defined at /home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py:1189> exception=ImportError('No supported version for facade: ModelConfigFacade')>
Traceback (most recent call last):
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py", line 1192, in _all_watcher
    model_config = await self.get_config()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/model.py", line 2179, in get_config
    config_facade = client.ModelConfigFacade.from_connection(
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/old_clients/_client.py", line 68, in from_connection
    c = lookup_facade(cls.__name__, version)
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/old_clients/_client.py", line 44, in lookup_facade
    raise ImportError("No supported version for facade: "
ImportError: No supported version for facade: ModelConfigFacade

Urgency

Annoying bug in our test suite

Python-libjuju version

3.0.4

Juju version

juju 2.9.37 with agent version 2.9.29

Reproduce / Test

git clone https://github.com/canonical/cos-configuration-k8s-operator
tox -e integration -- -k test_grafana_dashboards
sed-i commented 1 year ago

Same itest fails with juju 3.0.2-8bf53dc, agent 3.0.2.

tests/integration/test_grafana_dashboards.py::test_build_and_deploy 
----------------------------------------------------------------------------------- live log setup ------------------------------------------------------------------------------------
WARNING  juju.client.connection:connection.py:891 unknown common facade version for AllModelWatcher
WARNING  juju.client.connection:connection.py:891 unknown common facade version for ApplicationOffers
WARNING  juju.client.connection:connection.py:891 unknown common facade version for Cloud
WARNING  juju.client.connection:connection.py:891 unknown common facade version for Controller
WARNING  juju.client.connection:connection.py:891 unknown common facade version for ModelConfig
WARNING  juju.client.connection:connection.py:891 unknown common facade version for ModelManager
WARNING  juju.client.connection:connection.py:891 unknown common facade version for UserManager
ERROR
tests/integration/test_grafana_dashboards.py::test_relating_to_grafana ERROR
tests/integration/test_grafana_dashboards.py::test_dashboard_files_ingested_by_grafana ERROR

======================================================================================= ERRORS ========================================================================================
_______________________________________________________________________ ERROR at setup of test_build_and_deploy _______________________________________________________________________
Traceback (most recent call last):
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/pytest_asyncio/plugin.py", line 301, in _asyncgen_fixture_wrapper
    result = event_loop.run_until_complete(setup())
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/pytest_asyncio/plugin.py", line 283, in setup
    res = await gen_obj.__anext__()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/pytest_operator/plugin.py", line 231, in ops_test
    await ops_test._setup_model()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/pytest_operator/plugin.py", line 686, in _setup_model
    await self._controller.connect(self.controller_name)
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/controller.py", line 136, in connect
    await self.update_endpoints()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/controller.py", line 139, in update_endpoints
    info = await self.info()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/controller.py", line 280, in info
    uuids = await self.model_uuids()
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/controller.py", line 543, in model_uuids
    facade = client.ModelManagerFacade.from_connection(
  File "/home/ubuntu/code/cos-configuration-k8s-operator/.tox/integration/lib/python3.10/site-packages/juju/client/_client.py", line 66, in from_connection
    raise Exception('No facade {} in facades {}'.format(facade_name,
Exception: No facade ModelManager in facades {'Bundle': 6, 'CrossController': 1, 'HighAvailability': 2, 'MigrationTarget': 1, 'ModelSummaryWatcher': 1, 'ModelUpgrader': 1, 'NotifyWatcher': 1, 'Pinger': 1}
juanmanuel-tirado commented 1 year ago

For curiosity, what's the value of the agent-version field in the controllers file (~/.local/share/juju/controllers.yaml)?

sed-i commented 1 year ago

Tests work fine with juju 2.9.37, agent version 2.9.34, pylibjuju 2.9.10.

For that experiment I had

$ cat ~/.local/share/juju/controllers.yaml | yq '.controllers.chdv2934.agent-version'
2.9.34
juanmanuel-tirado commented 1 year ago

Pylibjuju 3.0.4 tries to address both 2.9.x and 3.0.x juju facades. Unfortunately, this seems to skip the existing compatibility. Said that, pylibjuju 3.1.0 will no longer support 2.9.x facades. This means that a 2.9.x agent will have to be targeted using the latest 2.9.x version of pylibjuju.

I will close this issue as there is a workaround for it. Feel free to reopen it.