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

Fix the reset wrapper - do a proper reset #626

Merged
merged 4 commits into from
Sep 3, 2019
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
14 changes: 8 additions & 6 deletions microk8s-resources/wrappers/microk8s-reset.wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"
clean_cluster() {
echo "Calling clean_cluster"
# Clean the cluster
REMOVEABLE_NSES=$($KUBECTL get ns -o=name | awk -F/ '{if ($2 !~ /^(default|kube-public|kube-system|kube-node-lease)$/) print}' | paste -s --delimiters=' ')
if [ -n "$REMOVEABLE_NSES" ]
then
$KUBECTL delete $REMOVEABLE_NSES
fi
NSES=$($KUBECTL get ns -o=name | awk -F/ '{print $2}' | paste -s --delimiters=' ')
for NS in $NSES
do
echo "Cleaning resources in namespace $NS"
# Remove all resource types except the standard k8s apiservices themselves
$KUBECTL delete --all $($KUBECTL api-resources -o name --verbs=delete --namespaced=true | grep -v '^apiservices$' | paste -s --delimiters=',') --namespace="$NS"
done
REMOVEABLE_NSES=$($KUBECTL get ns -o=name | awk -F/ '{if ($2 !~ /^(default|kube-public|kube-system)$/) print}' | paste -s --delimiters=' ')
if [ -n "$REMOVEABLE_NSES" ]
then
$KUBECTL delete $REMOVEABLE_NSES
fi

echo "Removing CRDs"
$KUBECTL delete --all customresourcedefinitions.apiextensions.k8s.io
Expand All @@ -36,7 +36,7 @@ clean_cluster() {
done

echo "Cleaning up addons client binaries.."
if [ -d "$SNAP_DATA/bin/" ]
if [ -d "$SNAP_DATA/bin/" ]
then
sudo rm -rf "$SNAP_DATA/bin/"
fi
Expand All @@ -45,6 +45,8 @@ clean_cluster() {
exit_if_stopped
exit_if_no_permissions

clean_cluster

${SNAP}/microk8s-stop.wrapper
sleep 5
${SNAP}/microk8s-start.wrapper
6 changes: 3 additions & 3 deletions tests/test-addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ def test_basic(self):
microk8s_enable("storage")
print("Validating storage")
validate_storage()
print("Disabling storage")
p = Popen("/snap/bin/microk8s.disable storage".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
p.communicate(input=b'Y\n')[0]
microk8s_enable("registry")
print("Validating registry")
validate_registry()
Expand All @@ -74,6 +71,9 @@ def test_basic(self):
microk8s_disable("registry")
print("Disabling dashboard")
microk8s_disable("dashboard")
print("Disabling storage")
p = Popen("/snap/bin/microk8s.disable storage".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
p.communicate(input=b'Y\n')[0]
'''
We would disable DNS here but this freezes any terminating pods.
We let microk8s.reset to do the cleanup.
Expand Down