Skip to content

Commit

Permalink
scripts: Add destroy-storage option to reset tool (#616)
Browse files Browse the repository at this point in the history
This will help for cleaning volumes

Relate-to: #488
Change-Id: I04a13f060b1c4beda9dd5006c435e5b2be12c385
Signed-off-by: Philippe Coval <p.coval@samsung.com>
  • Loading branch information
rzr authored and ktsakalozos committed Sep 12, 2019
1 parent e0dbaab commit 541f444
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions microk8s-resources/wrappers/microk8s-reset.wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ source $SNAP/actions/common/utils.sh

KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"


usage() {
cat<<EOF
Usage: ${SNAP_NAME} [OPTIONS...]
Options:
-h, --help give this help list
--destroy-storage Also destroy storage
EOF
}


destroy_storage() {
echo "Destroying storage"
microk8s.enable storage && microk8s.disable storage \
|| echo "Ignoring storage destroying issue"
}


clean_cluster() {
echo "Calling clean_cluster"
# Clean the cluster
Expand Down Expand Up @@ -57,11 +76,47 @@ then
exit 0
fi

destroy_storage_enabled=false
while getopts ':h-:' opt; do
case $opt in
-)
case "${OPTARG}" in
help)
usage
exit 0
;;
destroy-storage)
destroy_storage_enabled=true
;;
*)
echo "Invalid option --${OPTARG}" >&2
echo "Try '${SNAP_NAME} --help' for more information."
exit 2
;;
esac
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option -${OPTARG}" >&2
echo "Try '${SNAP_NAME} --help' for more information."
exit 2
;;

esac
done

exit_if_stopped
exit_if_no_permissions

if ${destroy_storage_enabled} ; then
destroy_storage
fi
clean_cluster

${SNAP}/microk8s-stop.wrapper
sleep 5
${SNAP}/microk8s-start.wrapper

0 comments on commit 541f444

Please sign in to comment.