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

ModuleNotFoundExceptions not matched as optional features #23823

Closed
2 tasks done
ianbuss opened this issue May 20, 2022 · 2 comments · Fixed by #23825
Closed
2 tasks done

ModuleNotFoundExceptions not matched as optional features #23823

ianbuss opened this issue May 20, 2022 · 2 comments · Fixed by #23825
Labels
area:core kind:bug This is a clearly a bug

Comments

@ianbuss
Copy link
Contributor

ianbuss commented May 20, 2022

Apache Airflow version

2.3.0 (latest released)

What happened

The providers_manager.py logs an import warning with stack trace (see example) for optional provider features instead of an info message noting the optional feature is disabled. Sample message:

[2022-05-19 21:46:53,065] {providers_manager.py:223} WARNING - Exception when importing 'airflow.providers.google.cloud.hooks.compute_ssh.ComputeEngineSSHHook' from 'apache-airflow-providers-google' package
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/airflow/providers_manager.py", line 257, in _sanity_check
    imported_class = import_string(class_name)
  File "/usr/local/lib/python3.9/site-packages/airflow/utils/module_loading.py", line 32, in import_string
    module = import_module(module_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/local/lib/python3.9/site-packages/airflow/providers/google/cloud/hooks/compute_ssh.py", line 23, in <module>
    import paramiko
ModuleNotFoundError: No module named 'paramiko'

What you think should happen instead

There is explicit code for catching ModuleNotFoundExceptions so these import errors should be logged as info messages like:

[2022-05-20 08:18:54,680] {providers_manager.py:215} INFO - Optional provider feature disabled when importing 'airflow.providers.google.cloud.hooks.compute_ssh.ComputeEngineSSHHook' from 'apache-airflow-providers-google' package

How to reproduce

Install the google provider but do not install the ssh submodule (or alternatively the mysql module). Various airflow components will produce the above warning logs.

Operating System

Debian bullseye

Versions of Apache Airflow Providers

No response

Deployment

Other Docker-based deployment

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@ianbuss ianbuss added area:core kind:bug This is a clearly a bug labels May 20, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented May 20, 2022

Thanks for opening your first issue here! Be sure to follow the issue template!

@potiuk
Copy link
Member

potiuk commented May 20, 2022

AAArgh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants