Repository: apache/airflow

Issue:
Unnecessary warnings during airflow pods starts
### Apache Airflow version

2.2.2 (latest released)

### What happened

Warnings `{providers_manager.py:156} WARNING - Exception when importing 'airflow.providers.google.leveldb.hooks.leveldb.LevelDBHook' from 'apache-airflow-providers-google' package: No module named 'plyvel'` appear in `wait-for-airflow-migrations` init containers and during webserver pod start.

### What you expected to happen

No such warnings, they were not present in 2.1.3 version.

### How to reproduce

Install Airflow using airflow helm chart with 2.2.2 airflow docker image and check `wait-for-airflow-migrations` init containers logs. Warnings can also be seen in webserver container.

### Operating System

Debian “buster”

### Versions of Apache Airflow Providers

Providers that come with the official Airflow docker image.

### Deployment

Official Apache Airflow Helm Chart

### Deployment details

_No response_

### Anything else

Looking at commit history, isn't this supposed to be a debug level log as per https://github.com/apache/airflow/commit/2f32df7b711cf63d18efd5e0023b22a79040cc86#diff-c56df299b30e60d690494057a4e8721d36406c0cca266961ff2ae6504993c8cb ?

Seems like this logic was changed in https://github.com/apache/airflow/commit/29aab6434ffe0fb8c83b6fd6c9e44310966d496a#diff-c56df299b30e60d690494057a4e8721d36406c0cca266961ff2ae6504993c8cbL288 since `_sanity_check`  doesn't handle `ImportError`s as debug messages . Should these warnings be ignored for now?

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)



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

Oh yeah it's been on my list as thing to fix! It's really annoying . Let me assign you @Aakcht 

Resolving patch:
diff --git a/airflow/providers_manager.py b/airflow/providers_manager.py
--- a/airflow/providers_manager.py
+++ b/airflow/providers_manager.py
@@ -140,6 +140,16 @@ def _sanity_check(provider_package: str, class_name: str) -> bool:
         return False
     try:
         import_string(class_name)
+    except ImportError as e:
+        # When there is an ImportError we turn it into debug warnings as this is
+        # an expected case when only some providers are installed
+        log.debug(
+            "Exception when importing '%s' from '%s' package: %s",
+            class_name,
+            provider_package,
+            e,
+        )
+        return False
     except Exception as e:
         log.warning(
             "Exception when importing '%s' from '%s' package: %s",
@@ -642,16 +652,6 @@ def _import_hook(
                 field_behaviours = hook_class.get_ui_field_behaviour()
                 if field_behaviours:
                     self._add_customized_fields(package_name, hook_class, field_behaviours)
-        except ImportError as e:
-            # When there is an ImportError we turn it into debug warnings as this is
-            # an expected case when only some providers are installed
-            log.debug(
-                "Exception when importing '%s' from '%s' package: %s",
-                hook_class_name,
-                package_name,
-                e,
-            )
-            return None
         except Exception as e:
             log.warning(
                 "Exception when importing '%s' from '%s' package: %s",


Test patch: