<@ULVA73B9P> when configuring quotas for work pool...
# ask-marvin
p
@Marvin when configuring quotas for work pool, does it count the flows that are sitting idle in pods waiting for retry? Also is it possible to configure them not be sit in a pod while waiting?
m
thought for 45.7 seconds
Let me address both parts of your question based on how Kubernetes work pools operate: 1. Quota Counting: When a flow run is waiting for a retry, and you're using the Kubernetes Worker, the pod does count against your work pool quotas. This is because the pod remains active during the retry wait period. 2. Configuring Retry Behavior: Yes, you can configure flows to not occupy pods while waiting for retries. There are two main approaches: a. Using
retry_delay_seconds
:
Copy code
python
   @flow(retry_delay_seconds=300)  # 5 minute delay
   def my_flow():
       ...
b. More efficiently, use the
retries
parameter with
persist_result=False
:
Copy code
python
   @flow(
       retries=3,
       persist_result=False,
       retry_delay_seconds=300
   )
   def my_flow():
       ...
When using these configurations with a Kubernetes worker: - The pod will terminate after a failure instead of staying alive - The Prefect worker will create a new pod when it's time to retry - This prevents unnecessary resource consumption during retry wait periods - The work pool quota will only count active pods, not waiting retries This approach is particularly useful in your self-hosted Kubernetes environment to optimize resource usage and maintain more accurate quota counts. Note that if you need to preserve logs or other data between retries, you'll need to ensure this information is stored externally (like in your PostgreSQL database or a separate logging system), as the pod will be terminated between retry attempts.
p
@Marvin if flow does not contain tasks that finished successfully before failing, will it sit in a pod?
m
thought for 31.2 seconds
No, if a flow fails without any successfully completed tasks, it will not sit in a pod during the retry wait period. The pod will be terminated, and the infrastructure will be cleaned up. Here's specifically what happens: 1. When the flow fails, Prefect marks the run for retry 2. The current pod is terminated 3. The flow enters a scheduled state while waiting for retry 4. When the retry delay period is over, a new pod is created to execute the retry attempt This behavior is automatic and is part of Prefect's resource management strategy to avoid unnecessary infrastructure costs. You don't need any special configuration to achieve this - it's the default behavior when running flows on Kubernetes workers. This is particularly relevant for your setup with a self-hosted Kubernetes deployment, as it ensures efficient resource utilization in your cluster.