Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non blocking userprompt with timeout if no multipath device detected. #1449

Merged
merged 12 commits into from Sep 1, 2017
73 changes: 59 additions & 14 deletions usr/share/rear/layout/prepare/GNU/Linux/210_load_multipath.sh
Expand Up @@ -34,22 +34,67 @@ blacklist {
fi

LogPrint "Activating multipath"
modprobe dm-multipath >&2
multipath >&2
if [ $? -ne 0 ] ; then
LogPrint "Failed to activate multipath, or no multipath device found."
rear_shell "Did you activate the multipath devices?"
else
LogPrint "multipath activated"
dmsetup ls --target multipath
multipath -l
list_mpath_device=1
modprobe dm-multipath >&2 && LogPrint "multipath activated" || LogPrint "Failed to load dm-multipath module"

# Asking to the User what to do after multipath command return 1.
# It could be because no multipath device were found (sles11/rhel6)
# or a real problem in the multipath configuration.
prompt="Failed to get multipath device list or no multipath device found."

rear_workflow="rear $WORKFLOW"
unset choices
choices[0]="Multipath is not needed. Continue recovery."
choices[1]="Run multipath with debug options."
choices[2]="Enter into rear-shell to manually debug multipath."
choices[3]="Abort '$rear_workflow'"
choice=""
wilful_input=""

# looping on this menu while multipath failed to list device.
# Note: On sles11/rhel6, multipath failed if no multipath device is found.
while ! multipath ; do
echo
choice="$( UserInput -p "$prompt" -D "${choices[0]}" "${choices[@]}")"&& wilful_input="yes" || wilful_input="no"
case "$choice" in
(${choices[0]})
# continue recovery without multipath
is_true "$wilful_input" && LogPrint "User confirmed continuing without multipath" || LogPrint "Continuing '$rear_workflow' by default"
LogPrint "You should consider removing BOOT_ON_SAN parameter from your rear configuration file if you don't need multipath on this server."

# Avoid to list mpath device.
list_mpath_device=0
break
;;
(${choices[1]})
# Run multipath in debug level
LogPrint "starting multipath -v3 (debug mode)"
multipath -v3
;;
(${choices[2]})
# Exit to shell to debug multipathing issue
rear_shell "Do you want to go back to '$rear_workflow' ?"
;;
(${choices[3]})
# Abort rear recovery
abort_recreate
Error "User chose to abort '$rear_workflow' in ${BASH_SOURCE[0]}"
;;
esac
done

# Search and list mpath device.
if is_true $list_mpath_device ; then
LogPrint "Listing multipath device found"
LogPrint "$(dmsetup ls --target multipath 2>&1)"
fi
fi

### Create multipath devices (at least partitions on them).
create_multipath() {
local multipath device
read multipath device junk < <(grep "multipath $1 " "$LAYOUT_FILE")

create_partitions "$device"
function create_multipath() {
local device=$1
if grep "^multipath $device " "$LAYOUT_FILE" 1>&2 ; then
Log "Found current or former multipath device $device in $LAYOUT_FILE: Creating partitions on it"
create_partitions "$device"
fi
}