joshzana opened a new issue #18963:
URL: https://github.com/apache/airflow/issues/18963


   ### Apache Airflow version
   
   2.2.0 (latest released)
   
   ### Operating System
   
   Ubuntu 20.04.3 LTS
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-amazon==2.3.0
   apache-airflow-providers-celery==2.1.0
   apache-airflow-providers-cncf-kubernetes==2.0.3
   apache-airflow-providers-docker==2.2.0
   apache-airflow-providers-elasticsearch==2.0.3
   apache-airflow-providers-ftp==2.0.1
   apache-airflow-providers-google==6.0.0
   apache-airflow-providers-grpc==2.0.1
   apache-airflow-providers-hashicorp==2.1.1
   apache-airflow-providers-http==2.0.1
   apache-airflow-providers-imap==2.0.1
   apache-airflow-providers-microsoft-azure==3.2.0
   apache-airflow-providers-mysql==2.1.1
   apache-airflow-providers-odbc==2.0.1
   apache-airflow-providers-postgres==2.3.0
   apache-airflow-providers-redis==2.0.1
   apache-airflow-providers-sendgrid==2.0.1
   apache-airflow-providers-sftp==2.1.1
   apache-airflow-providers-slack==4.1.0
   apache-airflow-providers-sqlite==2.0.1
   apache-airflow-providers-ssh==2.2.0
   
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   Airflow is deployed through Kubernetes and configured via environment 
variables.
   
   ### What happened
   
   Enabling airflow sentry via these env vars:
   ```
   AIRFLOW__SENTRY__SENTRY_ON="True"
   SENTRY_DSN=<dsn>
   SENTRY_ENVIRONMENT=<env>
   ```
   Worked fine in airflow 2.1.4.
   
   Upgrading to Airflow 2.2 and staring up any container fails with warning and 
then an exception "airflow.exceptions.AirflowConfigException: section/key 
[sentry/before_send] not found in config"
   
   Adding the following env var fixes it:
   ```
   AIRFLOW__SENTRY__BEFORE_SEND=""
   ```
   
   
   ### What you expected to happen
   
   The new env var should not be required and should have a reasonable fallback.
   I believe the code change in #18261 should have had a `fallback=None` arg 
passed in to the `config.getimport`call like I see in other calls to `getimport`
   
   
   ### How to reproduce
   
   Set up env vars
   
   ```
   AIRFLOW__SENTRY__SENTRY_ON="True"
   SENTRY_DSN=<dsn>
   SENTRY_ENVIRONMENT=<env>
   ```
   
   Run any airflow command.
   
   Tail the logs
   ```
   WARNING - section/key [sentry/before_send] not found in config
   Traceback (most recent call last):
     File "/home/airflow/.local/bin/airflow", line 8, in <module>
       sys.exit(main())
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/__main__.py", line 
40, in main
       args.func(args)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/cli_parser.py", 
line 47, in command
       func = import_string(import_path)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/module_loading.py",
 line 32, in import_string
       module = import_module(module_path)
     File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in 
import_module
       return _bootstrap._gcd_import(name[level:], package, level)
     File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
     File "<frozen importlib._bootstrap>", line 991, in _find_and_load
     File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
     File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
     File "<frozen importlib._bootstrap_external>", line 843, in exec_module
     File "<frozen importlib._bootstrap>", line 219, in 
_call_with_frames_removed
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/cli/commands/db_command.py",
 line 24, in <module>
       from airflow.utils import cli as cli_utils, db
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/db.py", line 
27, in <module>
       from airflow.jobs.base_job import BaseJob  # noqa: F401
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/__init__.py", 
line 19, in <module>
       import airflow.jobs.backfill_job
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/jobs/backfill_job.py",
 line 28, in <module>
       from airflow import models
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/__init__.py", 
line 20, in <module>
       from airflow.models.baseoperator import BaseOperator, BaseOperatorLink
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/baseoperator.py",
 line 61, in <module>
       from airflow.models.taskinstance import Context, TaskInstance, 
clear_task_instances
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py",
 line 84, in <module>
       from airflow.sentry import Sentry
     File "/home/airflow/.local/lib/python3.8/site-packages/airflow/sentry.py", 
line 190, in <module>
       Sentry = ConfiguredSentry()
     File "/home/airflow/.local/lib/python3.8/site-packages/airflow/sentry.py", 
line 112, in __init__
       sentry_config_opts['before_send'] = conf.getimport('sentry', 
'before_send')
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/configuration.py", 
line 477, in getimport
       full_qualified_path = conf.get(section=section, key=key, **kwargs)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/configuration.py", 
line 373, in get
       return self._get_option_from_default_config(section, key, **kwargs)
     File 
"/home/airflow/.local/lib/python3.8/site-packages/airflow/configuration.py", 
line 383, in _get_option_from_default_config
       raise AirflowConfigException(f"section/key [{section}/{key}] not found 
in config")
   airflow.exceptions.AirflowConfigException: section/key [sentry/before_send] 
not found in config
   ```
   
   ### Anything else
   
   This is only hit by users that enable sentry, as in the default airflow 
configuration this code is not executed.
   
   ### Are you willing to submit PR?
   
   - [ ] 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)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to