You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/10/21 21:06:07 UTC
[GitHub] [airflow] kaxil opened a new issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
kaxil opened a new issue #11731:
URL: https://github.com/apache/airflow/issues/11731
<!--
Welcome to Apache Airflow! For a smooth issue process, try to answer the following questions.
Don't worry if they're not all applicable; just try to include what you can :-)
If you need to include code snippets or logs, please put them in fenced code
blocks. If they're super-long, please use the details tag like
<details><summary>super-long log</summary> lots of stuff </details>
Please delete these comment blocks before submitting the issue.
-->
<!--
IMPORTANT!!!
PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
Please complete the next sections or the issue will be closed.
These questions are the first thing we need to know to understand the context.
-->
**Apache Airflow version**: 1.10.12
**What happened**:
Using the following `pod_mutation_hook` failed in 1.10.12 (it should have been backwards-compatible with 1.10.10) -- possibly I broke it.
```python
from airflow.contrib.kubernetes.pod import Pod
from airflow.configuration import conf
def pod_mutation_hook(pod: Pod):
extra_labels = {
"kubernetes_executor": "False",
"kubernetes_pod_operator": "False"
}
if 'airflow-worker' in pod.labels.keys() or \
conf.get('core', 'EXECUTOR') == "KubernetesExecutor":
extra_labels["kubernetes_executor"] = "True"
else:
extra_labels["kubernetes_pod_operator"] = "True"
pod.labels.update(extra_labels)
pod.tolerations += {{ toJson .Values.podMutation.tolerations }}
pod.affinity.update({{ toJson .Values.podMutation.affinity }})
```
**Error**:
```
[2020-10-21 20:55:11,879] {scheduler_job.py:1401} ERROR - Exception when executing execute_helper
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/airflow/kubernetes/pod_launcher.py", line 114, in _mutate_pod_backcompat
settings.pod_mutation_hook(dummy_pod)
File "/usr/local/airflow/config/airflow_local_settings.py", line 21, in pod_mutation_hook
pod.affinity.update({})
AttributeError: 'V1Affinity' object has no attribute 'update'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/airflow/kubernetes/pod_launcher.py", line 124, in _mutate_pod_backcompat
settings.pod_mutation_hook(pod)
File "/usr/local/airflow/config/airflow_local_settings.py", line 13, in pod_mutation_hook
if 'airflow-worker' in pod.labels.keys() or \
AttributeError: 'V1Pod' object has no attribute 'labels'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/airflow/jobs/scheduler_job.py", line 1399, in _execute
self._execute_helper()
File "/usr/lib/python3.7/site-packages/airflow/jobs/scheduler_job.py", line 1470, in _execute_helper
if not self._validate_and_run_task_instances(simple_dag_bag=simple_dag_bag):
File "/usr/lib/python3.7/site-packages/airflow/jobs/scheduler_job.py", line 1532, in _validate_and_run_task_instances
self.executor.heartbeat()
File "/usr/lib/python3.7/site-packages/airflow/executors/base_executor.py", line 134, in heartbeat
self.sync()
File "/usr/lib/python3.7/site-packages/airflow/executors/kubernetes_executor.py", line 870, in sync
self.kube_scheduler.run_next(task)
File "/usr/lib/python3.7/site-packages/airflow/executors/kubernetes_executor.py", line 497, in run_next
self.launcher.run_pod_async(pod, **self.kube_config.kube_client_request_args)
File "/usr/lib/python3.7/site-packages/airflow/kubernetes/pod_launcher.py", line 93, in run_pod_async
pod = self._mutate_pod_backcompat(pod)
File "/usr/lib/python3.7/site-packages/airflow/kubernetes/pod_launcher.py", line 127, in _mutate_pod_backcompat
raise Exception([e, e2])
Exception: [AttributeError("'V1Affinity' object has no attribute 'update'"), AttributeError("'V1Pod' object has no attribute 'labels'")]
```
cc @dimberman
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil closed issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
kaxil closed issue #11731:
URL: https://github.com/apache/airflow/issues/11731
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dmateusp edited a comment on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
dmateusp edited a comment on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-737126142
I ran it in 1.10.13 and it seems fixed! sorry I couldn't reproduce earlier and thanks for the bugfix
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dmateusp commented on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
dmateusp commented on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-731165437
hey @dimberman thanks for having a look, I'm going reproduce it again and add details here
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dimberman commented on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
dimberman commented on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-730559153
Hello @kaxil @dmateusp
This commit in v1-10-test should fix the issue with affinities https://github.com/apache/airflow/commit/9f1b66f9e7cd250f28e1763ad95a99eb049fe3d8
@dmateusp can you please provide an example/more details of how annotations aren't working? I added a test in this commit but I am seeing the annotations so want to figure out how to reproduce.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-729292131
@dimberman ?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] kaxil commented on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
kaxil commented on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-725744220
@dimberman Thoughts?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dmateusp commented on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
dmateusp commented on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-737126142
I ran it in 1.10.13 and it seems fix! sorry I couldn't reproduce earlier and thanks for the bugfix
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] dmateusp commented on issue #11731: Using affinity and labels in pod_mutation_hook is not backwards-compatible in 1.10.12
Posted by GitBox <gi...@apache.org>.
dmateusp commented on issue #11731:
URL: https://github.com/apache/airflow/issues/11731#issuecomment-721274670
Trying to update to 1.10.12 and I'm seeing that my `pod_mutation_hook` seems to have no effect on `annotations`, might be related?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org