Commit fc5fd6be authored by Arie Peterson's avatar Arie Peterson 🐚
Browse files

Merge branch '12-improve-error-logging-in-driver' into 'master'

Resolve "Improve error logging in driver"

Closes #12

See merge request !5
parents 585165b6 b5b7c9e2
Pipeline #10792 passed with stages
in 1 minute and 4 seconds
......@@ -96,7 +96,10 @@ ghostAction() {
else
local data="{\"type\": \"$action\", \"droplet\": $vps}"
fi
response=$(curl -sS -X POST -H "Authorization: Bearer $apiToken" "$url" -d "$data")
if ! response=$(curl -sS -X POST -H "Authorization: Bearer $apiToken" "$url" -d "$data")
then
exitWithFailure "$response"
fi
# Record the complete body from the HTTP response in the log.
debug "output: "
debug $(jq '.' <<<"$response")
......@@ -152,12 +155,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 +174,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 +188,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.
......
......@@ -12,7 +12,7 @@ provisioner:
driver:
image:
repository: "docker.greenhost.net/open/kubernetes-ghost/driver"
tag: "0.2.0"
tag: "0.3.0"
pullPolicy: "Always"
# Make this storage class the default, so persistent volume claims that do not
......
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