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

Undeclared depedency when using OpenStack provider #452

Open
gnuoy opened this issue Jun 30, 2021 · 5 comments
Open

Undeclared depedency when using OpenStack provider #452

gnuoy opened this issue Jun 30, 2021 · 5 comments
Labels

Comments

@gnuoy
Copy link
Contributor

gnuoy commented Jun 30, 2021

Commit 4cccbdc introduces a dependency on python-novaclient and python-keystoneclient but zaza itself does not depend on those packages. This breaks charms like grafana which are using zaza to test on openstack but do not include these OpenStack client modules in their dependencies.

Failure from grafana test run:

2021-06-30 08:51:18 [INFO] Using config /home/ubuntu/.local/share/juju/clouds.yaml                                                                                                                            
Traceback (most recent call last):                                                                                                                                                                            
  File "/home/ubuntu/work/branches/grafana/.build/grafana/.tox/func/bin/functest-run-suite", line 8, in <module>                                                                                              
    sys.exit(main())                                                                                                                                                                                          
  File "/home/ubuntu/work/branches/grafana/.build/grafana/.tox/func/lib/python3.8/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 308, in main                                                  
    func_test_runner(                                                                                                                                                                                         
  File "/home/ubuntu/work/branches/grafana/.build/grafana/.tox/func/lib/python3.8/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 242, in func_test_runner                                      
    run_env_deployment(env_deployment, keep_model=preserve_model,                                                                                                                                             
  File "/home/ubuntu/work/branches/grafana/.build/grafana/.tox/func/lib/python3.8/site-packages/zaza/charm_lifecycle/func_test_runner.py", line 166, in run_env_deployment                                    
    destroy.destroy(model_name)                                                                                                                                                                               
  File "/home/ubuntu/work/branches/grafana/.build/grafana/.tox/func/lib/python3.8/site-packages/zaza/charm_lifecycle/destroy.py", line 42, in destroy                                                         
    import zaza.utilities.openstack_provider as op                                                                                                                                                            
  File "/home/ubuntu/work/branches/grafana/.build/grafana/.tox/func/lib/python3.8/site-packages/zaza/utilities/openstack_provider.py", line 21, in <module>                                                   
    from keystoneauth1 import session                                                                                                                                                                         
ModuleNotFoundError: No module named 'keystoneauth1'    
@ajkavanagh ajkavanagh added the bug label Jun 30, 2021
@rgildein
Copy link
Contributor

rgildein commented Aug 2, 2022

Could we solve this issue?

@ajkavanagh
Copy link
Contributor

Could we solve this issue?

Yes, it can be solved; just need to make the module that imports openstack.py only do it on demand; essentially, make it a lazily loaded module.

@rgildein
Copy link
Contributor

rgildein commented Aug 3, 2022

Oh, so python-novaclient and keystoneauth1 won't be added to zaza dependencies?

@ajkavanagh
Copy link
Contributor

zaza only "needs" these dependencies when running on an OpenStack provider, as part of a clean-up, which it shouldn't really need to do. However, the world is a messy place. It would not be particularly good to make zaza have actual OpenStack dependencies as this would mean that these modules would have to be installed when testing on just K8s, or AWS or even just locally.

Ideally, the openstack provider and all associated functionality would be in a namespaced, separate, submodule that could be 'plugged in' as required. That module would have the OpenStack python modules as dependencies, so that when the OpenStack provider module is required for a particular test, its dependencies would already be available, and zaza would have no particular knowledge about OpenStack, MaaS, etc.

However, we are not there, yet. Thus, to solve this tactically, the best way would be to just make the imports lazy on demand so that if OpenStack is never used as a provider then the modules are never attempted to be imported and this error won't occur.

@rgildein
Copy link
Contributor

rgildein commented Aug 3, 2022

I see your point here and I agree that those dependencies would not make sense for k8s or AWS, ... .

The 'plug in' should be nice, but also a bit complicated.

What do you think about using optional dependencies in setup.py? This approach will be much cleaner than adding these dependencies to tox.ini without commenting why they are there. Related bug.

setup.py

...
openstack_require = [
    "python-openstackclient"
]
...
    extras_require={
        'testing': tests_require,
        'openstack': openstack_require,
    },
...

tox.ini (in charm project)

...
[testenv:func]
deps =
  git+https://github.com/openstack-charmers/zaza.git#egg=zaza[openstack]
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants