Commit ed70eb9
authored
Clean up Python mutator temp dir after run (#5522)
## Why
Found during a full-repo review of the CLI. When `DATABRICKS_BUNDLE_TMP`
is not set, the Python mutator creates a temp directory per run for the
files it exchanges with the Python subprocess and never removes it.
Every `bundle validate`/`deploy` on a bundle that uses Python leaves a
`-python*` directory in the system temp dir, and its `input.json`
contains the full serialized bundle configuration.
## Changes
Before, the temp directory leaked on every run; now it is removed once
the subprocess output has been consumed. `createCacheDir` returns a
cleanup function alongside the directory, and the mutator defers it.
When the user sets `DATABRICKS_BUNDLE_TMP`, the directory is a
user-chosen location and is kept for inspection, same as before.
## Test plan
- [x] New unit test `TestCreateCacheDir` in
`bundle/config/mutator/python` covering both branches: temp dir removed
by cleanup, `DATABRICKS_BUNDLE_TMP` dir kept
- [x] `go test ./bundle/config/mutator/python/` passes
- [x] Acceptance test `TestAccept/bundle/python/resolve-variable` passes
for all four variants (both engines, both `databricks-bundles`
versions), exercising the real subprocess flow with cleanup in place
- [x] `./task fmt-q`, `./task lint-q`, `./task checks` pass
This pull request and its description were written by Isaac.1 parent caa3d62 commit ed70eb9
2 files changed
Lines changed: 44 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
315 | 316 | | |
316 | 317 | | |
317 | 318 | | |
318 | | - | |
| 319 | + | |
| 320 | + | |
319 | 321 | | |
320 | 322 | | |
321 | 323 | | |
| |||
325 | 327 | | |
326 | 328 | | |
327 | 329 | | |
328 | | - | |
| 330 | + | |
329 | 331 | | |
330 | 332 | | |
331 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
332 | 340 | | |
333 | 341 | | |
334 | | - | |
| 342 | + | |
| 343 | + | |
335 | 344 | | |
336 | 345 | | |
337 | 346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
474 | 503 | | |
475 | 504 | | |
476 | 505 | | |
| |||
501 | 530 | | |
502 | 531 | | |
503 | 532 | | |
504 | | - | |
| 533 | + | |
505 | 534 | | |
506 | 535 | | |
507 | 536 | | |
| |||
0 commit comments