question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KubernetesPodOperator handles a default value of k8s V1ResourceRequirements as None causes incorrect value

See original GitHub issue

Apache Airflow version: 1.10.11

Kubernetes version (if you are using kubernetes) (use kubectl version): 1.16

Environment:

  • Cloud provider or hardware configuration: Amazon EKS
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:

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:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
odavidcommented, Aug 4, 2020

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…

1reaction
dimbermancommented, Aug 4, 2020

Hi @roy-ht, thank you for posting this. This will be fixed in 1.10.12.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[GitHub] [airflow] roy-ht opened a new issue #9827
For a smooth issue process, try to answer the following questions. ... KubernetesPodOperator generates default as None, but should not have ...
Read more >
airflow.providers.cncf.kubernetes.operators.kubernetes_pod
KubernetesPodOperator (*, namespace: Optional[str] = None, image: Optional[str] = None, ... (templated) If not specified, default value is ~/.kube/config.
Read more >
Use the KubernetesPodOperator | Astronomer Documentation
The KubernetesPodOperator (KPO) runs a Docker image in a dedicated Kubernetes Pod. By abstracting calls to the Kubernetes API, the KubernetesPodOperator lets ...
Read more >
Use the KubernetesPodOperator | Cloud Composer
Launching Kubernetes pods into the environment cluster can cause competition for cluster resources, such as CPU or memory. Because the Airflow scheduler and ......
Read more >
Updating Airflow
The following airflow.cfg values will be deprecated: ... sub_path=None, read_only=True ) k = KubernetesPodOperator( namespace='default', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found