Skip to content

Simplify the K8sExecutor and K8sPodOperator - #10393

Merged
dimberman merged 8 commits into
apache:masterfrom
astronomer:simplify_k8s_executor
Sep 17, 2020
Merged

Simplify the K8sExecutor and K8sPodOperator#10393
dimberman merged 8 commits into
apache:masterfrom
astronomer:simplify_k8s_executor

Conversation

@dimberman

@dimberman dimberman commented Aug 19, 2020

Copy link
Copy Markdown
Contributor

As discussed in an earlier email thread, this PR removes much of the configuration elements of the K8sExecutor for a much simpler design.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 UPDATING.md.

@boring-cyborg boring-cyborg Bot added area:Scheduler including HA (high availability) scheduler k8s labels Aug 19, 2020
Comment thread airflow/kubernetes/pod_generator.py Outdated
Comment thread airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py Outdated
Comment thread airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py Outdated
Comment thread airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py Outdated

@turbaszek turbaszek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-2.5k of lines - love it ❤️ This is still WIP but we should remember about note in UPDATING.md

@turbaszek turbaszek added this to the Airflow 2.0.0 milestone Aug 19, 2020
@potiuk

potiuk commented Aug 19, 2020

Copy link
Copy Markdown
Member

-2.5k of lines - love it This is still WIP but we should remember about note in UPDATING.md

Indeed. I love the stats on this one.

@kaxil

kaxil commented Aug 19, 2020

Copy link
Copy Markdown
Member

Nice <3 -- some static checks are failing https://github.com/apache/airflow/pull/10393/checks?check_run_id=1003310026

@dimberman
dimberman force-pushed the simplify_k8s_executor branch 5 times, most recently from 0541262 to 0977f4b Compare August 24, 2020 23:30
Comment thread tests/kubernetes/test_pod_generator.py Outdated
@dimberman
dimberman marked this pull request as ready for review August 25, 2020 02:58
@dimberman
dimberman force-pushed the simplify_k8s_executor branch 4 times, most recently from ee7d498 to 1b6bce9 Compare August 26, 2020 17:46
Comment thread airflow/example_dags/example_kubernetes_executor_config.py Outdated
Comment thread airflow/executors/kubernetes_executor.py Outdated

@kaxil kaxil left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you rebase on latest Master please if you haven't already?

@dimberman

Copy link
Copy Markdown
Contributor Author

@davlum interesting, though without the reconcile methods how would users use the pod_override setting, which is an arbitrary pod? We need some way to ensure features are either added or overwritten based on these three stages. It's also worth mentioning that we now have a generate_dag_yaml command in the CLI so users can see what their pods will look like before they launch (and we plan to add this preview to the UI)

@davlum

davlum commented Sep 14, 2020

Copy link
Copy Markdown
Contributor

Pod override would do exactly that, it would completely override the base definition, not merge with it.

@dimberman

Copy link
Copy Markdown
Contributor Author

@davlum I don't think we would want the pod_override to override all values. The examples I can think of off the top of my head are labels and volume_mounts. The base pod file will have volume mounts for the airflow.cfg and other potential secrets. I as a non-admin should be allowed to ADD volume mounts, but I shouldn't be able to delete them via override. Same with labels. Admin might have labels or node affinities they don't want messed with.

While yes it's POSSIBLE to ensure those are there using the pod_mutation_hook, doing so places onus on the admin for the user's messups.

Comment thread UPDATING.md Outdated
Comment thread UPDATING.md Outdated
Comment thread UPDATING.md Outdated
Comment thread UPDATING.md Outdated
@dimberman
dimberman force-pushed the simplify_k8s_executor branch 3 times, most recently from 1616218 to 88cb3cf Compare September 16, 2020 01:01
@mik-laj
mik-laj requested a review from msumit September 16, 2020 10:15
Comment thread UPDATING.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a full list of configuration options that have been deleted? This is important if we are going to work on airflow upgrade-check, because having the list we can detect incorrect configuration and notify the user at runtime.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mik-laj added

Comment thread UPDATING.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have this deprecation warning? I didn't see it in the code, but I might have missed it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @mik-laj, the deprecation warning was already merged so it didn't show up in the PR https://github.com/apache/airflow/pull/10393/files#diff-868ed785b2a336f20cb6a577dde2502aR198-R201

Comment thread docs/howto/operator/kubernetes.rst Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This sentence needs to be corrected. The plural is used when one class is described.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still support standard python dicts? (Line 60)

Also: why did this bit need to change -- should Volume or VolumeMount not be used anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. @ashb yes Volume and VolumeMount would now be k8s.V1Volume and k8s.V1VolumeMount, I go into more detail on this in the UPDATING.md

@dimberman
dimberman force-pushed the simplify_k8s_executor branch from 88cb3cf to 3a68783 Compare September 16, 2020 14:41
Removes thousands of lines of code that essentially ammount to us
re-creating the Kubernetes API. Will offer a faster, simpler
KubernetesExecutor for 2.0
@dimberman
dimberman force-pushed the simplify_k8s_executor branch from bb57bb7 to 8d0070a Compare September 16, 2020 15:18
@dimberman

Copy link
Copy Markdown
Contributor Author

@mik-laj can I get another lookover? :)

)
namespaced['resources'] = resources
return PodGenerator(**namespaced).gen_pod()
return PodGeneratorDeprecated(**namespaced).gen_pod()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can/should we issue a FutureDeprecationWarning here, so that we can remove this code path in 2.1/2.2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, you issue a warning a few lines up (from the previous PR. right?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep :)

Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Scheduler including HA (high availability) scheduler provider:cncf-kubernetes Kubernetes (k8s) provider related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants