Commit 8599aac
committed
fix: prevent EC2 termination when GitHub runner de-registration fails
When the scale-down Lambda fails to de-register a runner from GitHub
(even after automatic retries via @octokit/plugin-retry), the EC2
instance should NOT be terminated. This prevents stale runner entries
in GitHub org settings.
This change complements PR #4990 which added @octokit/plugin-retry for
automatic retries. While that handles transient failures, this ensures
that if de-registration ultimately fails, we don't leave orphaned
GitHub runner entries by terminating the EC2 instance prematurely.
Key changes:
- Extract deleteGitHubRunner() helper that catches errors per-runner
- Only terminate EC2 instance if ALL GitHub de-registrations succeed
- If any de-registration fails, leave instance running for next cycle
- Rename githubAppClient to githubInstallationClient for clarity
- Refactor to split owner/repo once instead of multiple times
- Fix error logging to handle non-Error objects properly
The @octokit/plugin-retry (added in #4990) handles automatic retries
at the client level, so no custom retry logic is needed here.
Tests:
- Add test verifying EC2 is NOT terminated when de-registration fails1 parent 6dc97d5 commit 8599aac
File tree
2 files changed
+93
-33
lines changed- lambdas/functions/control-plane/src/scale-runners
2 files changed
+93
-33
lines changedLines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
634 | 663 | | |
635 | 664 | | |
636 | 665 | | |
| |||
Lines changed: 64 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
130 | 164 | | |
131 | | - | |
| 165 | + | |
132 | 166 | | |
133 | 167 | | |
134 | 168 | | |
| |||
141 | 175 | | |
142 | 176 | | |
143 | 177 | | |
144 | | - | |
| 178 | + | |
145 | 179 | | |
146 | 180 | | |
147 | 181 | | |
148 | 182 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 183 | + | |
| 184 | + | |
164 | 185 | | |
165 | 186 | | |
166 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
167 | 191 | | |
168 | 192 | | |
169 | 193 | | |
170 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
171 | 201 | | |
172 | 202 | | |
173 | 203 | | |
174 | 204 | | |
175 | 205 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
179 | 210 | | |
180 | 211 | | |
181 | 212 | | |
| |||
0 commit comments