- Notifications
You must be signed in to change notification settings - Fork1.1k
Commitc3e3bb5
authored
feat: delete pending canceled prebuilds (#20499)
## DescriptionPR#20387 introduced cancelingpending prebuild jobs from inactive template versions to avoidprovisioning obsolete workspaces. However, the associated prebuildsremained in the database with "Canceled" status, visible in the UI.This PR now orphan-deletes these canceled prebuilt workspaces. Since thecanceled jobs were never processed by a provisioner, no Terraformresources were created, making orphan deletion safe.Orphan deletion always creates a provisioner job, but behavesdifferently based on provisioner availability:- If no provisioner daemon is available, the job is immediately markedas completed and the workspace is marked as deleted without anyprovisioner processing- If a provisioner daemon is available, it processes the delete job withempty Terraform state (no actual resources to destroy)The job cancellation and workspace deletion occur atomically in the sametransaction. We don't split this into two separate reconciliation runsbecause there's no way to distinguish between system-canceled prebuildsand user-canceled workspaces. If we deleted canceled workspaces in alater run, we'd delete user-canceled workspaces that users may want tokeep for troubleshooting.Note: This only applies to system-generated prebuilds from inactivetemplate versions.## Changes* Update `UpdatePrebuildProvisionerJobWithCancel` query to return jobID, workspace ID, template ID, and template version preset ID* Add `DeprovisionMode` enum to support orphan deletion in the provisionflow* Update `ActionTypeCancelPending` handler to cancel jobs andorphan-delete associated workspaces atomically1 parent0d765f5 commitc3e3bb5
File tree
9 files changed
+219
-95
lines changed- coderd/database
- dbauthz
- dbmetrics
- dbmock
- queries
- enterprise/coderd/prebuilds
9 files changed
+219
-95
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4933 | 4933 | | |
4934 | 4934 | | |
4935 | 4935 | | |
4936 | | - | |
| 4936 | + | |
4937 | 4937 | | |
4938 | 4938 | | |
4939 | | - | |
| 4939 | + | |
4940 | 4940 | | |
4941 | 4941 | | |
4942 | 4942 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
646 | 646 | | |
647 | 647 | | |
648 | 648 | | |
649 | | - | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
650 | 653 | | |
651 | | - | |
652 | | - | |
| 654 | + | |
| 655 | + | |
653 | 656 | | |
654 | 657 | | |
655 | 658 | | |
| |||
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 303 | + | |
| 304 | + | |
309 | 305 | | |
310 | 306 | | |
311 | 307 | | |
| |||
324 | 320 | | |
325 | 321 | | |
326 | 322 | | |
327 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
60 | 78 | | |
61 | 79 | | |
62 | 80 | | |
| |||
642 | 660 | | |
643 | 661 | | |
644 | 662 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
| 663 | + | |
673 | 664 | | |
674 | 665 | | |
675 | 666 | | |
| |||
717 | 708 | | |
718 | 709 | | |
719 | 710 | | |
720 | | - | |
| 711 | + | |
721 | 712 | | |
722 | 713 | | |
723 | 714 | | |
724 | 715 | | |
725 | 716 | | |
726 | 717 | | |
727 | | - | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
728 | 758 | | |
729 | | - | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
730 | 768 | | |
731 | | - | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
732 | 775 | | |
733 | 776 | | |
734 | | - | |
735 | | - | |
736 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
737 | 783 | | |
738 | 784 | | |
739 | | - | |
740 | | - | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
741 | 793 | | |
742 | 794 | | |
743 | | - | |
744 | | - | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
745 | 801 | | |
746 | | - | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
747 | 805 | | |
748 | 806 | | |
749 | 807 | | |
| |||
758 | 816 | | |
759 | 817 | | |
760 | 818 | | |
| 819 | + | |
761 | 820 | | |
762 | 821 | | |
763 | 822 | | |
| |||
795 | 854 | | |
796 | 855 | | |
797 | 856 | | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
798 | 862 | | |
799 | 863 | | |
800 | 864 | | |
| |||
0 commit comments
Comments
(0)