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

Move all k8S classes to cncf.kubernetes provider #32767

Merged
merged 2 commits into from
Jul 26, 2023

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Jul 22, 2023

This is the big move of all Kubenetes classes to go to provider.

The changes that are implemented in this move:

  • replaced all imports from airflow.kubernetes to cncf.kubernetes
    Swith PEP-563 dynamic import rediretion and deprecation messages
    those messages now support overriding the "replacement" hints
    to make K8s deprecations more accurate
  • pre_7_4_0_compatibility package with classes used by past
    providerrs have been "frozen" and stored in the package with
    import redirections from airflow.kubernetes(with deprecation warnings)
  • kubernetes configuration is moved to kubernetes provider
  • mypy started complaining about conf and set used in configuration.
    so better solution to handle deprecations and hinting conf
    returning AirlfowConfigParsing was added.
  • example_kuberntes_executor uses configuration reading not in
    top level but in execute method
  • PodMutationHookException and PodReconciliationError have
    been moved to cncf.kubernetes provider and they are imported
    from there with fallback to an airflow.exception ones in case
    old provider is used in Airflow 2.7.0
  • k8s methods in task_instance have been deprecated and reolaced
    with functions in "cncf.kubernetes` template_rendering module
    the old way still works but raise deprecaton warnings.
  • added extras with versions for celery and k8s
  • raise AirflowOptionalProviderFeatureException in case there is
    attempt to use CeleryK8sExecutor and cncf.k8s is not installed.
  • added few "new" core utils to k8s (hashlib_wrapper etc)
  • both warnings and errors indicate minimum versions for both cncf.k8s
    and Celery providers.

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@potiuk potiuk added the full tests needed We need to run full set of tests for this PR to merge label Jul 22, 2023
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch 3 times, most recently from 0489b31 to 2b5f5c9 Compare July 22, 2023 12:10
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch 2 times, most recently from d3a18e9 to 4e281b6 Compare July 22, 2023 18:39
@potiuk potiuk marked this pull request as ready for review July 22, 2023 18:39
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch 2 times, most recently from 83e9b83 to dcc849d Compare July 22, 2023 19:44
@potiuk
Copy link
Member Author

potiuk commented Jul 22, 2023

Based on #32775 so only last commit counts.

@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch from dcc849d to 5bff371 Compare July 23, 2023 08:19
@potiuk potiuk changed the title Move kubernetes classes to provider Move all k8S classes to cncf.kubernetes provider Jul 23, 2023
@potiuk
Copy link
Member Author

potiuk commented Jul 23, 2023

Only last commit counts.

@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch 2 times, most recently from 76afae1 to 4e56e6a Compare July 23, 2023 08:42
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch 3 times, most recently from 17c3838 to e2ed30e Compare July 25, 2023 07:24
@potiuk potiuk requested a review from uranusjr as a code owner July 25, 2023 07:24
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch 3 times, most recently from 205c9a4 to d7d4bbb Compare July 25, 2023 14:58
@potiuk
Copy link
Member Author

potiuk commented Jul 25, 2023

  • all is now green
  • added detailed explanation in the commit about the scope of changes
  • added pre-commits that are preventing accidental top-level imports of airflow.kubernetes from anywhere but itself (for back-compat) and airflow.providers.cncf.kubernetes from anywhere in the code except the "kubernetes" command
  • added explanation that you need cncf.kubernetes > 7.4.0 or celery > 3.3.0 when your imports using old 'airflow.kubernetes" or "airflow.executors" fail.

airflow/utils/deprecation_tools.py Show resolved Hide resolved
airflow/utils/deprecation_tools.py Outdated Show resolved Hide resolved
airflow/utils/deprecation_tools.py Outdated Show resolved Hide resolved
airflow/config_templates/__init__.py Outdated Show resolved Hide resolved
airflow/kubernetes/pre_7_4_0_compatibility/__init__.py Outdated Show resolved Hide resolved
airflow/providers/cncf/kubernetes/provider.yaml Outdated Show resolved Hide resolved
docs/apache-airflow/core-concepts/executor/kubernetes.rst Outdated Show resolved Hide resolved
tests/cli/commands/test_task_command.py Outdated Show resolved Hide resolved
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch from d7d4bbb to c486137 Compare July 25, 2023 19:22
@potiuk
Copy link
Member Author

potiuk commented Jul 25, 2023

Applied this round of comments from @jedcunningham . Also added newsfragment

@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch from c486137 to eb6573a Compare July 25, 2023 19:48
@potiuk potiuk requested a review from eladkal as a code owner July 25, 2023 19:48
This is the big move of all Kubenetes classes to go to provider.

The changes that are implemented in this move:

* replaced all imports from airflow.kubernetes to cncf.kubernetes
  Swith PEP-563 dynamic import rediretion and deprecation messages
  those messages now support overriding the "replacement" hints
  to make K8s deprecations more accurate
* pre_7_4_0_compatibility package with classes used by past
  providerrs have been "frozen" and stored in the package with
  import redirections from airflow.kubernetes(with deprecation warnings)
* kubernetes configuration is moved to kubernetes provider
* mypy started complaining about conf and set used in configuration.
  so better solution to handle deprecations and hinting conf
  returning AirlfowConfigParsing was added.
* example_kuberntes_executor uses configuration reading not in
  top level but in execute method
* PodMutationHookException and PodReconciliationError have
  been moved to cncf.kubernetes provider and they are imported
  from there with fallback to an airflow.exception ones in case
  old provider is used in Airflow 2.7.0
* k8s methods in task_instance have been deprecated and reolaced
  with functions in "cncf.kubernetes` template_rendering module
  the old way still works but raise deprecaton warnings.
* added extras with versions for celery and k8s
* raise AirflowOptionalProviderFeatureException in case there is
  attempt to use CeleryK8sExecutor and cncf.k8s is not installed.
* added few "new" core utils to k8s (hashlib_wrapper etc)
* both warnings and errors indicate minimum versions for both cncf.k8s
  and Celery providers.
@potiuk potiuk force-pushed the move-kubernetes-classes-to-provider branch from eb6573a to b7af1c4 Compare July 25, 2023 21:22
newsfragments/32767.significant.rst Outdated Show resolved Hide resolved
@potiuk potiuk merged commit e934603 into apache:main Jul 26, 2023
61 checks passed
@potiuk potiuk deleted the move-kubernetes-classes-to-provider branch July 26, 2023 06:25
potiuk added a commit to potiuk/airflow that referenced this pull request Jul 27, 2023
The apache#32767 missed imports of imports for a few kubernetes modules.

This PR adds the missing ones.
jedcunningham pushed a commit that referenced this pull request Jul 27, 2023
The #32767 missed imports of imports for a few kubernetes modules.

This PR adds the missing ones.
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Aug 2, 2023
potiuk added a commit to potiuk/airflow that referenced this pull request Sep 13, 2023
The apache#32767 has moved all k8s classes to cncf.kubernetes provider,
however there was a mistake with location of Pod*Exceptions - rather
than in pod_manager they remained defined in the kubernetes_executor
package - which has the side-effect that trying to import them
in Airflow Pre 2.7 raised the
"You should not use the provider's executors in this version of
Airflow." error.

This change moves the exceptions to the pod_generator package
to fix the problem.
potiuk added a commit that referenced this pull request Sep 13, 2023
The #32767 has moved all k8s classes to cncf.kubernetes provider,
however there was a mistake with location of Pod*Exceptions - rather
than in pod_manager they remained defined in the kubernetes_executor
package - which has the side-effect that trying to import them
in Airflow Pre 2.7 raised the
"You should not use the provider's executors in this version of
Airflow." error.

This change moves the exceptions to the pod_generator package
to fix the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:CLI area:dev-tools area:plugins area:Triggerer area:webserver Webserver related Issues full tests needed We need to run full set of tests for this PR to merge provider:cncf-kubernetes Kubernetes provider related issues type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants