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

scripts: Add destroy-storage option to reset tool #616

Merged
merged 2 commits into from
Sep 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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