databricks-cli/libs/exec
Ilia Babanov cbf75b157d
Avoid race-conditions while executing sub-commands (#1201)
## Changes
`executor.Exec` now uses `cmd.CombinedOutput`. Previous implementation
was hanging on my windows VM during `bundle deploy` on the
`ReadAll(MultiReader(stdout, stderr))` line.

The problem is related to the fact the MultiReader reads sequentially,
and the `stdout` is the first in line. Even simple `io.ReadAll(stdout)`
hangs on me, as it seems like the command that we spawn (python wheel
build) waits for the error stream to be finished before closing stdout
on its own side? Reading `stderr` (or `out`) in a separate go-routine
fixes the deadlock, but `cmd.CombinedOutput` feels like a simpler
solution.

Also noticed that Exec was not removing `scriptFile` after itself, fixed
that too.

## Tests
Unit tests and manually
2024-02-12 15:04:14 +00:00
..
exec.go Avoid race-conditions while executing sub-commands (#1201) 2024-02-12 15:04:14 +00:00
exec_test.go Avoid race-conditions while executing sub-commands (#1201) 2024-02-12 15:04:14 +00:00
shell.go Allow specifying executable in artifact section and skip bash from WSL (#1169) 2024-02-01 14:10:04 +00:00
shell_bash.go Allow specifying executable in artifact section and skip bash from WSL (#1169) 2024-02-01 14:10:04 +00:00
shell_bash_test.go Make libs/exec fallback to `sh` if `bash` cannot be found (#1114) 2024-01-11 12:26:31 +00:00
shell_cmd.go Allow specifying executable in artifact section and skip bash from WSL (#1169) 2024-02-01 14:10:04 +00:00
shell_cmd_test.go Make libs/exec fallback to `sh` if `bash` cannot be found (#1114) 2024-01-11 12:26:31 +00:00
shell_sh.go Allow specifying executable in artifact section and skip bash from WSL (#1169) 2024-02-01 14:10:04 +00:00
shell_sh_test.go Make libs/exec fallback to `sh` if `bash` cannot be found (#1114) 2024-01-11 12:26:31 +00:00