Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

migrateDatabaseJob fails when upgrading to 2.6.1 with Sentry enabled #31374

Closed
1 of 2 tasks
gil-tober opened this issue May 18, 2023 · 5 comments
Closed
1 of 2 tasks

migrateDatabaseJob fails when upgrading to 2.6.1 with Sentry enabled #31374

gil-tober opened this issue May 18, 2023 · 5 comments
Assignees
Labels
affected_version:2.6 Issues Reported for 2.6 area:core kind:bug This is a clearly a bug pending-response

Comments

@gil-tober
Copy link

Apache Airflow version

2.6.1

What happened

When upgrading Airflow from 2.5.3 to 2.6.1 the airflow-run-migration job fails.

I have deployed the same setup to our DEV environment (where Sentry is disabled) and the upgrade succeeded without an issue.

After that I tried deploying to our PROD environment where Sentry is enabled and the job failed with the error below.

I tried enabling Sentry on DEV and the upgrade failed.

Took a look at airflow.executors.executor_loader.py at lines 162-185 when the exception is raised from. Setting the environment variable _AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1 fixed the error getting in the upgrade job. (Our metadb is Postgres)

Traceback (most recent call last):
  File “/home/airflow/.local/bin/airflow”, line 5, in <module>
    from airflow.__main__ import main
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/__init__.py”, line 66, in <module>
    settings.initialize()
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/settings.py”, line 522, in initialize
    import_local_settings()
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/settings.py”, line 467, in import_local_settings
    import airflow_local_settings
  File “/opt/airflow/dags/repo/airflow_local_settings.py”, line 5, in <module>
    from airflow.www.utils import UIAlert
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/www/utils.py”, line 44, in <module>
    from airflow.models.dagrun import DagRun
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/models/dagrun.py”, line 57, in <module>
    from airflow.models.taskinstance import TaskInstance as TI
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/models/taskinstance.py”, line 100, in <module>
    from airflow.sentry import Sentry
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/sentry.py”, line 195, in <module>
    Sentry = ConfiguredSentry()
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/sentry.py”, line 92, in __init__
    executor_class, _ = ExecutorLoader.import_default_executor_cls()
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/executors/executor_loader.py”, line 158, in import_default_executor_cls
    executor, source = cls.import_executor_cls(executor_name)
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/executors/executor_loader.py”, line 134, in import_executor_cls
    return _import_and_validate(cls.executors[executor_name]), ConnectorSource.CORE
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/executors/executor_loader.py”, line 130, in _import_and_validate
    cls.validate_database_executor_compatibility(executor)
  File “/home/airflow/.local/lib/python3.10/site-packages/airflow/executors/executor_loader.py”, line 181, in validate_database_executor_compatibility
    from airflow.settings import engine
ImportError: cannot import name ‘engine’ from ‘airflow.settings’ (/home/airflow/.local/lib/python3.10/site-packages/airflow/settings.py)

What you think should happen instead

migrateDatabaseJob should not fail when Sentry is enabled

How to reproduce

Upgrade from 2.5.3 to 2.6.1 with CeleryKubernetesExecutor and Sentry enabled

Operating System

Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==8.0.0
apache-airflow-providers-celery==3.1.0
apache-airflow-providers-cncf-kubernetes==6.1.0
apache-airflow-providers-common-sql==1.4.0
apache-airflow-providers-docker==3.6.0
apache-airflow-providers-elasticsearch==4.4.0
apache-airflow-providers-ftp==3.3.1
apache-airflow-providers-google==8.3.0
apache-airflow-providers-grpc==3.1.0
apache-airflow-providers-hashicorp==3.3.1
apache-airflow-providers-http==4.3.0
apache-airflow-providers-imap==3.1.1
apache-airflow-providers-jenkins==3.2.1
apache-airflow-providers-microsoft-azure==6.0.0
apache-airflow-providers-mysql==5.0.0
apache-airflow-providers-odbc==3.2.1
apache-airflow-providers-postgres==5.3.1
apache-airflow-providers-redis==3.1.0
apache-airflow-providers-salesforce==5.3.0
apache-airflow-providers-sendgrid==3.1.0
apache-airflow-providers-sftp==4.2.4
apache-airflow-providers-slack==7.2.0
apache-airflow-providers-snowflake==4.0.5
apache-airflow-providers-sqlite==3.3.2
apache-airflow-providers-ssh==3.6.0
apache-airflow-providers-tableau==4.1.0

Deployment

Official Apache Airflow Helm Chart

Deployment details

Airflow deployed on an EKS cluster using the official Airflow Helm Chart (V1.9.0)
MetaBD is a Postgres RDS
CeleryKubernetesExecutor

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@gil-tober gil-tober added area:core kind:bug This is a clearly a bug needs-triage label for new issues that we didn't triage yet labels May 18, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented May 18, 2023

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

@hussein-awala hussein-awala removed the needs-triage label for new issues that we didn't triage yet label May 18, 2023
@hussein-awala
Copy link
Member

Probably it's a circular import issue similar to what we had in #31033.

@ashb ashb added the affected_version:2.6 Issues Reported for 2.6 label May 18, 2023
@ashb ashb self-assigned this May 18, 2023
@gil-tober
Copy link
Author

gil-tober commented May 19, 2023

Hey @hussein-awala
I saw #31033, the import of Engine in the error that i'm getting is referencing an sqlalchemy.engine.base object.
It could be that there is a circular import there, but first, there isn't a exception for that and second, I'm not that deeply familiar with airflow.settings.py to see it.

@potiuk
Copy link
Member

potiuk commented May 19, 2023

Your problem is likely this:

  File “/opt/airflow/dags/repo/airflow_local_settings.py”, line 5, in <module>
    from airflow.www.utils import UIAlert

Airflow local seetings is loaded during initialization and for some reason, you are trying to import UIAlert there, which in turn tries to (through chain of imports) import settings again, but local_settins are imported during importing settings, so when you agan try to import settings (that are partially imported), Python (rightfully) refuses to cooperate as it would cause circula import and recurrrent operations (settings would again import local_settings which would then again import settings and so-one.

So the question is - why are you trying to import UIAlert in the top level of your local_settings ? Is it really necessary ? Can you change it to local import instead inside a function which you have in your local_settings so that it is not imported when airflow_local_settings is parsed ?

@potiuk
Copy link
Member

potiuk commented May 19, 2023

I am turning that into a discussion, because it is evidently some troubleshooting of mis-configured local settings.

@apache apache locked and limited conversation to collaborators May 19, 2023
@potiuk potiuk converted this issue into discussion #31408 May 19, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
affected_version:2.6 Issues Reported for 2.6 area:core kind:bug This is a clearly a bug pending-response
Projects
None yet
Development

No branches or pull requests

4 participants