Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion e2e/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ microshift_debug_info() {
microshift_cleanup() {
local output_dir="${1}"
log "Cleaning MicroShift"
ssh_cmd "echo 1 | sudo microshift-cleanup-data --all" &>"${output_dir}/0000-cleanup.log"
ssh_cmd "echo 1 | sudo microshift-cleanup-data --all --keep-images" &>"${output_dir}/0000-cleanup.log"
}

microshift_reprovision() {
Expand Down
3 changes: 2 additions & 1 deletion e2e/tests/assets/greenboot-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function check_greenboot_exit_status() {
local cleanup=$2

if [ "${cleanup}" -ne 0 ]; then
echo 1 | microshift-cleanup-data --all
# Skip image deletion to speed up the test and make it more reliable
echo 1 | microshift-cleanup-data --all --keep-images
systemctl enable --now microshift || true
fi

Expand Down
23 changes: 14 additions & 9 deletions scripts/microshift-cleanup-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ SCRIPT_NAME=$(basename "$0")
# to allow for pod deletion when MicroShift is stopped
PODS_NS_LIST=(openshift-service-ca openshift-ingress openshift-dns openshift-storage openshift-ovn-kubernetes)
FULL_CLEAN=true
KEEP_IMAGE=false

function usage() {
echo "Stop all MicroShift services, also cleaning their data"
echo ""
echo "Usage: ${SCRIPT_NAME} <--all | --ovn>"
echo " --all Clean all MicroShift and OVN data"
echo " --ovn Clean OVN data only"
echo "Usage: ${SCRIPT_NAME} <--all [--keep-images] | --ovn>"
echo " --all Clean all MicroShift and OVN data"
echo " --keep-images Keep container images when cleaning all data"
echo " --ovn Clean OVN data only"
exit 1
}

Expand All @@ -34,15 +36,16 @@ function stop_disable_services() {
}

function stop_clean_pods() {
# Wipe the crio data off and return
if ${FULL_CLEAN} ; then
# Wipe all the crio data off and return
if ${FULL_CLEAN} && ! ${KEEP_IMAGE} ; then
echo Removing crio container and image storage
crio wipe -f &>/dev/null
systemctl restart crio
return
fi

# It is necessary to stop the pods (OVN-related last) to allow for further termination
# Delete pods only, preserving images
# It is necessary to remove the pods (OVN-related last) to allow for further termination
# of processes (i.e. conmon, etc.) that use the files under /var/run/ovn.
# The cleanup of OVN data only works if the files under /var/run/ovn are not in use.
echo Removing MicroShift pods
Expand All @@ -56,7 +59,8 @@ function stop_clean_pods() {
if [ "$(echo "${ocp_pods}" | wc -w)" -eq 0 ] ; then
break
fi
crictl rmp -f "${ocp_pods}" &>/dev/null
# shellcheck disable=SC2086
crictl rmp -f ${ocp_pods} &>/dev/null
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug introduced when fixing shellcheck errors. The command expects multiple arguments, so quotes are not allowed.

retries=$(( retries - 1 ))
done
done
Expand Down Expand Up @@ -97,6 +101,7 @@ function clean_data() {
# Parse command line
case $1 in
--all)
[ "$2" = "--keep-images" ] && KEEP_IMAGE=true
;;
--ovn)
FULL_CLEAN=false
Expand All @@ -116,11 +121,11 @@ if ${FULL_CLEAN} ; then
echo "DATA LOSS WARNING: Do you wish to stop and clean ALL MicroShift data AND cri-o container workloads?"
select yn in "Yes" "No"; do
case "${yn}" in
Yes)
Yes)
break
;;
*)
echo "Aborting cleanup"
echo "Aborting cleanup"
exit 0
;;
esac
Expand Down