Commit e0591a9
authored
Include pending tasks in quota calculations (#4651)
When creating tasks in parallel, a race condition could lead to quota over-commitment. Tasks are first created in a `PENDING` state, 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 `PENDING` tasks 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 `PENDING` to `RUNNING`. This ensures that a task successfully submitted to Diego is correctly reflected as `RUNNING` in the Cloud Controller database, aligning the desired state with the action taken.1 parent 6cab54a commit e0591a9
File tree
9 files changed
+143
-63
lines changed- app/models/runtime
- constraints
- spec/unit/models/runtime
- constraints
9 files changed
+143
-63
lines changedLines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
343 | 347 | | |
344 | 348 | | |
345 | 349 | | |
| |||
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
351 | 359 | | |
352 | 360 | | |
353 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
| |||
371 | 375 | | |
372 | 376 | | |
373 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
374 | 382 | | |
375 | 383 | | |
376 | 384 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
85 | 92 | | |
86 | 93 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
450 | | - | |
451 | | - | |
452 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
457 | 455 | | |
458 | 456 | | |
459 | 457 | | |
460 | 458 | | |
461 | 459 | | |
462 | 460 | | |
463 | 461 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 462 | + | |
| 463 | + | |
469 | 464 | | |
470 | 465 | | |
471 | 466 | | |
472 | 467 | | |
473 | 468 | | |
474 | 469 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
| 470 | + | |
479 | 471 | | |
480 | 472 | | |
481 | 473 | | |
482 | 474 | | |
483 | 475 | | |
484 | 476 | | |
485 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
486 | 486 | | |
487 | | - | |
488 | | - | |
489 | | - | |
| 487 | + | |
490 | 488 | | |
491 | 489 | | |
492 | | - | |
493 | | - | |
494 | 490 | | |
495 | 491 | | |
496 | 492 | | |
497 | 493 | | |
498 | 494 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
| 495 | + | |
504 | 496 | | |
| 497 | + | |
| 498 | + | |
505 | 499 | | |
506 | 500 | | |
507 | 501 | | |
| |||
548 | 542 | | |
549 | 543 | | |
550 | 544 | | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
551 | 558 | | |
552 | 559 | | |
553 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
655 | | - | |
656 | | - | |
| 655 | + | |
| 656 | + | |
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
663 | | - | |
664 | | - | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
665 | 673 | | |
666 | 674 | | |
667 | 675 | | |
668 | 676 | | |
669 | 677 | | |
670 | 678 | | |
671 | | - | |
672 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
673 | 683 | | |
674 | 684 | | |
675 | 685 | | |
| |||
710 | 720 | | |
711 | 721 | | |
712 | 722 | | |
713 | | - | |
| 723 | + | |
714 | 724 | | |
715 | 725 | | |
716 | 726 | | |
717 | | - | |
| 727 | + | |
718 | 728 | | |
719 | 729 | | |
720 | 730 | | |
| |||
723 | 733 | | |
724 | 734 | | |
725 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
726 | 749 | | |
727 | 750 | | |
728 | | - | |
| 751 | + | |
729 | 752 | | |
730 | 753 | | |
731 | 754 | | |
| |||
0 commit comments