Include pending tasks in quota calculations #4651
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When creating tasks in parallel, a race condition could lead to quota over-commitment. Tasks are first created in a
PENDINGstate, which was not included in quota calculations. This allowed multiple tasks to be created and submitted to Diego for execution, even if their combined resource usage exceeded the defined quota.When the task's state was subsequently updated, the model validation would fail due to the exceeded quota, incorrectly marking the task as
FAILED. This created a state mismatch, as the task had already been successfully submitted to Diego.This change resolves the issue by including
PENDINGtasks in the memory and log rate limit calculations, treating the state as a desired state similar to apps. This prevents the initial over-submission of tasks.Additionally, the quota validation is now skipped when a task transitions from
PENDINGtoRUNNING. This ensures that a task successfully submitted to Diego is correctly reflected asRUNNINGin the Cloud Controller database, aligning the desired state with the action taken.Fixes #4619
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
mainbranchI have run all the unit tests using
bundle exec rakeI have run CF Acceptance Tests