Fix issue with finding degraded pool(s).

When a pool is degraded, or needs special action, the `zpool import`
(without pool to import) line will report:
```
  pool: rpool
    id: 01234567890123456789
 state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:
   [..]
```
If the import with the pool name fails, it is supposed to try importing
using the pool ID.

However, the script is also getting the `action` line (and probably `scrub:`
if/when that's available):
  pool; The pool can be imported using its name or numeric identifier.;config:;
which causes issues on consequent import attempts.

Cleanup the information by rewriting the `sed` command line.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rob Norris <robn@despairlabs.com>
Signed-off-by: Turbo Fredriksson <turbo@bayour.com>
Closes #18000
This commit is contained in:
Turbo Fredriksson 2025-12-04 13:57:39 +00:00 committed by Brian Behlendorf
parent 33dd57e1b4
commit 94975ff79b

View File

@ -107,7 +107,7 @@ find_rootfs()
find_pools()
{
_find_pools=$("${@}" 2> /dev/null | \
sed -Ee '/pool:|^[a-zA-Z0-9]/!d' -e 's@.*: @@' | \
sed -Ee '/ pool: | id: /!d' -e 's@.*: @@' | \
tr '\n' ';')
echo "${_find_pools%%;}" # Return without the last ';'.