Commit 6caf8f21 authored by Arie Peterson's avatar Arie Peterson 🐚
Browse files

Catch and propagate errors from some external programs from the driver

parent 585165b6
......@@ -152,12 +152,18 @@ domount() {
device="/dev/xvd${diskLetter}1"
debug "device: $device"
# Use the `blkid` program to scan the device for an existing filesystem.
existingFileSystem=$(lsblk -n -o FSTYPE "$device")
if ! existingFileSystem=$(lsblk -n -o FSTYPE "$device" 2>&1)
then
exitWithFailure "$existingFileSystem"
fi
debug "blkid: $existingFileSystem"
if [[ -z "$existingFileSystem" ]]
then
debug "No existing filesystem; creating one."
mkfs.xfs "$device" >/dev/null 2>&1
if ! result=$(mkfs.xfs "$device" 2>&1)
then
exitWithFailure "$result"
fi
else
debug "Existing filesystem."
fi
......@@ -165,7 +171,10 @@ domount() {
# Create mount point if necessary.
mkdir -p "$mountPath" >/dev/null 2>&1
# Mount the virtual block device at the given mount point.
mount "$device" "$mountPath" >/dev/null 2>&1
if ! result=$(mount "$device" "$mountPath" 2>&1)
then
exitWithFailure "$result"
fi
output "Success"
exit 0
......@@ -176,7 +185,10 @@ unmount() {
local mountPath=$1
# Unmount the file system.
umount "$mountPath" >/dev/null 2>&1
if ! result=$(umount "$mountPath" 2>&1)
then
exitWithFailure "$result"
fi
# We would like to detach the disk here, but Kubernetes doesn't give us
# enough information to do so. Instead, we do a just-in-time detach when
# the disk is attached later on.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment