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:
[email protected]