ci: fix broken-pipe race in find_extra_block_dev
find_extra_block_dev piped find_extra_block_devs into head -1. Since
find_extra_block_devs prints every eligible disk and ends with echo
"$devs", head closes the pipe after the first line and the producer's
echo races into SIGPIPE (echo: write error: Broken pipe), failing the
command substitution under pipefail/errexit.
The race only fires reliably now that the runners present two data disks
(sdb and sdc), so find_extra_block_devs emits multiple lines; with a
single disk the one-line output almost never triggered it.
Read the producer to completion with mapfile via process substitution
and return the first element, mirroring find_second_block_dev, so there
is no downstream head to close the pipe early.
Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
(cherry picked from commit 7079c9bf62)
This commit is contained in:
1 parent
37baf67d4d
commit
47f91adcb6
1 file changed
+3
-1
@@ -83,7 +83,9 @@ function create_extra_disk() {
|
||||
# iSCSI disk if none exist. Thin wrapper over find_extra_block_devs(); kept as a
|
||||
# convenience for its many callers that expect a single basename.
|
||||
function find_extra_block_dev() {
|
||||
find_extra_block_devs 1 | head -1
|
||||
local devs
|
||||
mapfile -t devs < <(find_extra_block_devs 1)
|
||||
echo "${devs[0]}" # the first disk
|
||||
}
|
||||
|
||||
# find_extra_block_devs [min_count]
|
||||
|
||||
Reference in new issue
Block a user