Commit b6bde3b
committed
fix(bundler): harden undeploy.sh resilience and CRD discovery
Combines three related hardening changes to the generated undeploy.sh
(previously split across NVIDIA#599, NVIDIA#601, NVIDIA#600). They share a file and a
theme -- make undeploy recover from partial or transient failure --
so bundling them avoids three sequential PR rebases over the same
template.
1. Transient-failure resilience (was NVIDIA#599).
Three `kubectl | jq | while` pipelines in the post-uninstall cleanup
path ran under `set -euo pipefail` with no fallback. A momentary
control-plane 502 or auth refresh killed the whole script after
Helm uninstalls succeeded, leaving orphan CRDs, webhooks, and
`Active` namespaces. Wrap each pipeline's trailing `done` in
`|| echo "Warning: ..." >&2` so the failure is visible but the
script continues. Matches the `|| true` pattern already used in the
adjacent ORPHANED_CRD_GROUPS loop.
2. Pre-flight CRD discovery via Helm annotation (was NVIDIA#601).
check_release_for_stuck_crds sourced its CRD list only from
`helm get manifest`, which returns CRDs under the chart's templates/
section but omits CRDs installed from the chart's crds/ directory
(the Helm-recommended layout used by most operator charts). CRs
backed by crds/-installed CRDs (e.g., NIMService) slipped past the
finalizer pre-flight. Union both sources (manifest + annotated) and
dedupe. Uses `awk 'NF'` instead of `grep -v '^$'` to drop empty
lines without the grep-exits-1-on-no-match behavior, which would
abort the script under pipefail when a release has no CRDs.
3. Post-flight Helm-annotation CRD check (was NVIDIA#600).
Helm-managed CRDs that survive the per-release deletion loop went
unnoticed until the next deploy.sh run rejected them. Add a
verification pass at the end of undeploy.sh that re-enumerates CRDs
filtered by meta.helm.sh/release-name + release-namespace
annotations and surfaces any leftovers as a post-flight warning.
CRDs already being deleted (non-null .metadata.deletionTimestamp)
are excluded: the earlier `kubectl delete crd ... --wait=false`
returns immediately, so a slow finalizer can leave the CRD listed
though cleanup is normal. Only truly stuck (not-yet-terminating)
CRDs are reported.
Unit test TestUndeployScript_TransientFailureWarnsAndContinues
generates a bundle, stubs kubectl to exit non-zero, sources each of
the three helpers, and asserts the helper returns 0 and emits the
expected Warning: on stderr.
Fixes: N/A
Related: NVIDIA#477 (introduced the per-component CRD cleanup pipeline),
NVIDIA#599, NVIDIA#600, NVIDIA#601 (superseded by this PR).
Signed-off-by: Yuan Chen <yuanchen97@gmail.com>1 parent b82af6f commit b6bde3b
2 files changed
Lines changed: 220 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
2274 | 2276 | | |
2275 | 2277 | | |
2276 | 2278 | | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
158 | 174 | | |
159 | 175 | | |
160 | 176 | | |
| |||
188 | 204 | | |
189 | 205 | | |
190 | 206 | | |
191 | | - | |
192 | | - | |
193 | | - | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
194 | 224 | | |
195 | 225 | | |
196 | 226 | | |
197 | | - | |
| 227 | + | |
| 228 | + | |
198 | 229 | | |
199 | | - | |
200 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
201 | 254 | | |
202 | 255 | | |
203 | 256 | | |
| |||
219 | 272 | | |
220 | 273 | | |
221 | 274 | | |
222 | | - | |
| 275 | + | |
223 | 276 | | |
224 | 277 | | |
225 | 278 | | |
| |||
298 | 351 | | |
299 | 352 | | |
300 | 353 | | |
301 | | - | |
302 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
303 | 361 | | |
304 | 362 | | |
305 | 363 | | |
306 | 364 | | |
| 365 | + | |
| 366 | + | |
307 | 367 | | |
308 | 368 | | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 369 | + | |
315 | 370 | | |
316 | 371 | | |
317 | 372 | | |
| |||
434 | 489 | | |
435 | 490 | | |
436 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
437 | 516 | | |
438 | 517 | | |
439 | 518 | | |
| |||
0 commit comments