You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "devscheffer (via GitHub)" <gi...@apache.org> on 2024/02/01 14:18:54 UTC
Re: [PR] The task is stuck in a queued state forever in case of pod launch errors [airflow]
devscheffer commented on PR #36882:
URL: https://github.com/apache/airflow/pull/36882#issuecomment-1921445378
I had similar problems and thought about something like that
```
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import KubernetesPodOperator
from airflow.utils.decorators import apply_defaults
from datetime import timedelta
import time
class CustomKubernetesPodOperator(KubernetesPodOperator):
@apply_defaults
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def execute(self, context):
# Check if there are enough resources on the cluster
while True:
cpu_available = check_cpu()
memory_available = check_memory()
if cpu_available and memory_available:
break
else:
time.sleep(300) # Wait for 5 minutes
# Send the request to the Kubernetes cluster
super().execute(context)
def check_cpu(self):
# Check if there is enough CPU available on the cluster
# Return True if there is enough CPU available, False otherwise
pass
def check_memory(self):
# Check if there is enough memory available on the cluster
# Return True if there is enough memory available, False otherwise
pass
```
--
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org