forked from kubernetes/test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup.sh
executable file
·45 lines (40 loc) · 1.6 KB
/
cleanup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
readonly DEFAULT_CLUSTER_NAME="kind-prow-integration"
readonly DEFAULT_CONTEXT="kind-${DEFAULT_CLUSTER_NAME}"
readonly DEFAULT_REGISTRY_NAME="kind-registry"
readonly PROW_COMPONENTS="sinker crier hook horologium prow-controller-manager fakeghserver deck tide deck-tenanted"
function do_kubectl() {
kubectl --context=${DEFAULT_CONTEXT} $@
}
if [[ -n "${ARTIFACTS:-}" && -d "${ARTIFACTS}" ]]; then
log_dir="${ARTIFACTS}/prow_pod_logs"
mkdir -p "${log_dir}"
for app in ${PROW_COMPONENTS}; do
do_kubectl logs svc/$app >"${log_dir}/${app}.log"
done
fi
kind delete cluster --name "${DEFAULT_CLUSTER_NAME}"
container_hash="$(docker ps -q -f name="${DEFAULT_REGISTRY_NAME}" 2>/dev/null || true)"
if [ -z "${container_hash}" ]; then
echo "Container ${DEFAULT_REGISTRY_NAME} does not exist, skipping cleaning up."
exit 0
fi
echo "Deleting container ${DEFAULT_REGISTRY_NAME}"
docker container stop "${DEFAULT_REGISTRY_NAME}"
docker container rm "${DEFAULT_REGISTRY_NAME}"