Merge pull request #51768 from shashidharatd/leak-resource

Automatic merge from submit-queue

Delete the federation namespace from fcp instead of individual objects

**What this PR does / why we need it**:
This PR simplifies cleanup by deleting the entire namespace instead of individual objects.
This PR is linked to https://github.com/kubernetes/kubernetes/issues/50543. This may not solve the issue but instead to try an alternative.

**Release note**:
```release-note
NONE
```

/assign @madhusudancs
This commit is contained in:
Kubernetes Submit Queue 2017-09-14 19:39:58 -07:00 committed by GitHub
commit 5a4d1ddeae

View File

@ -74,17 +74,16 @@ function cleanup-federation-api-objects {
set +o errexit set +o errexit
echo "Cleaning Federation control plane objects" echo "Cleaning Federation control plane objects"
# Delete all resources with the federated-cluster label. kube::log::status "Removing namespace \"${FEDERATION_NAMESPACE}\" from \"${FEDERATION_KUBE_CONTEXT}\""
$host_kubectl delete pods,svc,rc,deployment,secret -lapp=federated-cluster # Try deleting until the namespace is completely gone.
while $host_kubectl --context="${FEDERATION_KUBE_CONTEXT}" delete namespace "${FEDERATION_NAMESPACE}" >/dev/null 2>&1; do
# Delete all PVs bound to PVCs in FEDERATION_NAMESPACE # It is usually slower to remove a namespace because it involves
pvs=$($host_kubectl get pvc --namespace=${FEDERATION_NAMESPACE} -o jsonpath='{.items[*].spec.volumeName}') # performing a cascading deletion of all the resources in the
while $host_kubectl delete pv ${pvs} >/dev/null 2>&1; do # namespace. So we sleep a little longer than other resources
sleep 2 # before retrying
sleep 5
done done
kube::log::status "Removed namespace \"${FEDERATION_NAMESPACE}\" from \"${FEDERATION_KUBE_CONTEXT}\""
# Delete all resources in FEDERATION_NAMESPACE.
$host_kubectl delete pvc,pods,svc,rc,deployment,secret --namespace=${FEDERATION_NAMESPACE} --all
# This is a big hammer. We get rid of federation-system namespace from # This is a big hammer. We get rid of federation-system namespace from
# all the clusters # all the clusters