Apache Airflow version: 1.10.11
Kubernetes version (if you are using kubernetes) (use kubectl version): 1.16
Environment:
uname -a):What happened:
If resources argument has partial parameters, KubernetesPodOperator generates default as None, but should not have a key.
It is written here:
https://github.com/apache/airflow/blob/d23fa2f8896c5e31745131e6917f1970b4aa590f/airflow/kubernetes/pod.py#L82
For example, if I made operator like KubernetesPodOperator(resources={'limit_cpu': '500m'}), generated pods have wrong limits like below:
24 โ Containers:
25 โ base:
26 โ Image: xxxxxxxx
27 โ Port: <none>
28 โ Host Port: <none>
29 โ Limits:
30 โ cpu: 500m
31 โ ephemeral-storage: 0
32 โ memory: 0
33 โ nvidia.com/gpu: 0
34 โ Requests:
35 โ cpu: 0
36 โ ephemeral-storage: 0
37 โ memory: 0
38 โ nvidia.com/gpu: 0
...
...
107 โ Normal Created 20m kubelet, xxx Created container base
108 โ Normal Started 20m kubelet, xxx Started container base
109 โ Warning Evicted 20m kubelet, xxx Pod ephemeral local storage usage exceeds the total limit of containers 0.
110 โ Normal Killing 20m kubelet, xxx Stopping container base
What you expected to happen:
Omit None value of limits and requests.
For example, Resources.to_k8s_client_obj should be modified like that:
def to_k8s_client_obj(self):
limits = {}
if self.limit_cpu:
limits['cpu'] = self.limit_cpu
...
return k8s.V1ResourceRequirements(limits=limits, requests=reqests)
How to reproduce it:
Anything else we need to know:
Thanks for opening your first issue here! Be sure to follow the issue template!
cc: @dimberman @kaxil -> I guess that one is too for 1.10.12
could be related to https://github.com/apache/airflow/issues/9812
could be related to #9812
Yup they are related
I used this as a work around - https://github.com/apache/airflow/issues/9812#issuecomment-659113921
Hi @roy-ht, thank you for posting this. This will be fixed in 1.10.12.
Hi @dimberman, I created the PR #10140, which solves this issue, however the PR is stuck on static checks, which seems not relevant to my changes. Will be super glad if you can take a look.
Cheers...
With 1.10.11, I also saw KubernetesPodOperator(resources={'limit_cpu': '500m'}) generating this JSON
"resources": {
"limits": {
"cpu": "500m",
"memory": null,
"nvidia.com/gpu": null,
"ephemeral-storage": null } }
that does not look right, either.