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-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to