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

Remove pid arg from celery option to fix duplicate pid issue, Move celery command to provider package #36794

Merged
merged 25 commits into from
Feb 25, 2024

Conversation

pavansharma36
Copy link
Contributor

@pavansharma36 pavansharma36 commented Jan 15, 2024

closes: #36541


@pavansharma36 pavansharma36 changed the title Add celery pid suffix to fix duplicate pid issue Remove pid arg from celery option to fix duplicate pid issue, Move celery command to provider package Jan 26, 2024
@potiuk
Copy link
Member

potiuk commented Jan 31, 2024

Tests failing

@pavansharma36
Copy link
Contributor Author

pavansharma36 commented Feb 1, 2024

@potiuk can you tell me why its failing to import module from airflow, core modules should be available to providers right

from airflow.cli.commands.daemon_utils import run_command_with_daemon_option
ModuleNotFoundError: No module named 'airflow.cli.commands.daemon_utils'

@potiuk
Copy link
Member

potiuk commented Feb 1, 2024

@potiuk can you tell me why its failing to import module from airflow, core modules should be available to providers right

from airflow.cli.commands.daemon_utils import run_command_with_daemon_option ModuleNotFoundError: No module named 'airflow.cli.commands.daemon_utils'

It's failing in compatibility check. When you install the provider in Airflow 2.6 or 2.7, the module is not there because it has been added later. That's whe we have those compatibility checks - they install the provider in Airflow 2.6 and 2.7 and attempt to import all classes (and fail).

You need make sure to handle back-compatibility here. Likely you should in-line this method with a comment that it should be removed when min_airflow_version is 2.8.0 we have few other cases like that in various providers.

@pavansharma36
Copy link
Contributor Author

@potiuk I tried copying daemon func but it goes way down where so many utils are not present.

Its better if someone with better codebase understanding do this. Let me know if I should create new PR with fix in core cli

@potiuk
Copy link
Member

potiuk commented Feb 2, 2024

@potiuk I tried copying daemon func but it goes way down where so many utils are not present.

Its better if someone with better codebase understanding do this. Let me know if I should create new PR with fix in core cli

Actually I realized there is a simple way you can get back to what it was before. This command in Provider will be only useful since Airflow 2.9 so you can do something similar, when importing the daemon_utils to what is done in auth manager:

try:
    from airflow.auth.managers.base_auth_manager import BaseAuthManager, ResourceMethod
except ImportError:
    raise AirflowOptionalProviderFeatureException(
        "Failed to import BaseUser. This feature is only available in Airflow versions >= 2.8.0"
    )

@potiuk
Copy link
Member

potiuk commented Feb 2, 2024

So simply go back to previous import and add the try/except/raise exception and all should be good.

@pavansharma36 pavansharma36 changed the title Remove pid arg from celery option to fix duplicate pid issue, Move celery command to provider package WIP: Remove pid arg from celery option to fix duplicate pid issue, Move celery command to provider package Feb 2, 2024
@pavansharma36 pavansharma36 changed the title WIP: Remove pid arg from celery option to fix duplicate pid issue, Move celery command to provider package Remove pid arg from celery option to fix duplicate pid issue, Move celery command to provider package Feb 3, 2024
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @o-nikolas ?

@potiuk
Copy link
Member

potiuk commented Feb 8, 2024

WDYT @o-nikolas ?

@o-nikolas
Copy link
Contributor

WDYT @o-nikolas ?

So we went with deprecation messages instead of the approach of automating the action of keeping the two modules in sync via pre-commit?

I'm still worried there will be drift but I suppose adding the precommit stuff is a bit tricky so I'd be okay with this being merged. But I do agree with @potiuk's suggestion above.

@potiuk potiuk merged commit 8d74ee8 into apache:main Feb 25, 2024
59 checks passed
@Taragolis Taragolis mentioned this pull request Mar 1, 2024
2 tasks
abhishekbhakat pushed a commit to abhishekbhakat/my_airflow that referenced this pull request Mar 5, 2024
@ephraimbuddy ephraimbuddy added this to the Airflow 2.9.0 milestone Mar 6, 2024
@ephraimbuddy ephraimbuddy added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Mar 6, 2024
potiuk added a commit to potiuk/airflow that referenced this pull request Apr 9, 2024
Celery provider has an ambedded Airflow CLI command as of 3.6.1. When
the apache#36794 was merged, we thought mistakenly that it will only be used
in airflow 2.9.0+, so we used a feature introduced in Airflow 2.8.0 in
the apache#34945 - but in fact the CLI command is configured by the Celery
Executor which is also part of the Celery provider, so it was also
used for airflow < 2.8.0 and failed due to missing import.

This PR checks if Airflow version is < 2.8.0 and if so, it falls back
to built-in airflow CLI command.
potiuk added a commit that referenced this pull request Apr 9, 2024
Celery provider has an ambedded Airflow CLI command as of 3.6.1. When
the #36794 was merged, we thought mistakenly that it will only be used
in airflow 2.9.0+, so we used a feature introduced in Airflow 2.8.0 in
the #34945 - but in fact the CLI command is configured by the Celery
Executor which is also part of the Celery provider, so it was also
used for airflow < 2.8.0 and failed due to missing import.

This PR checks if Airflow version is < 2.8.0 and if so, it falls back
to built-in airflow CLI command.
utkarsharma2 pushed a commit to astronomer/airflow that referenced this pull request Apr 22, 2024
utkarsharma2 pushed a commit to astronomer/airflow that referenced this pull request Apr 22, 2024
…e#38879)

Celery provider has an ambedded Airflow CLI command as of 3.6.1. When
the apache#36794 was merged, we thought mistakenly that it will only be used
in airflow 2.9.0+, so we used a feature introduced in Airflow 2.8.0 in
the apache#34945 - but in fact the CLI command is configured by the Celery
Executor which is also part of the Celery provider, so it was also
used for airflow < 2.8.0 and failed due to missing import.

This PR checks if Airflow version is < 2.8.0 and if so, it falls back
to built-in airflow CLI command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Celery Worker Doesnt start in daemon mode
5 participants