diff --git a/hack/lib/cleanup.sh b/hack/lib/cleanup.sh index b16e02e1eedc..1cb7e72fc56d 100644 --- a/hack/lib/cleanup.sh +++ b/hack/lib/cleanup.sh @@ -152,4 +152,22 @@ function os::cleanup::tmpdir() { ${USE_SUDO:+sudo} rm -rf "${directory}" done } -readonly -f os::cleanup::tmpdir \ No newline at end of file +readonly -f os::cleanup::tmpdir + +# os::cleanup::dump_events dumps all the events from a cluster to a file. +# +# Globals: +# ARTIFACT_DIR +# Arguments: +# None +# Returns: +# None +function os::cleanup::dump_events() { + os::log::info "Dumping cluster events to ${ARTIFACT_DIR}/events.txt" + local kubeconfig + if [[ -n "${ADMIN_KUBECONFIG}" ]]; then + kubeconfig="--config=${ADMIN_KUBECONFIG}" + fi + oc get events --all-namespaces ${kubeconfig} > "${ARTIFACT_DIR}/events.txt" +} +readonly -f os::cleanup::dump_events diff --git a/hack/test-end-to-end-docker.sh b/hack/test-end-to-end-docker.sh index 981738a57371..1a4df8bb8340 100755 --- a/hack/test-end-to-end-docker.sh +++ b/hack/test-end-to-end-docker.sh @@ -39,6 +39,8 @@ function cleanup() os::cleanup::dump_etcd + os::cleanup::dump_events + if [[ -z "${SKIP_TEARDOWN-}" ]]; then os::cleanup::containers fi diff --git a/hack/util.sh b/hack/util.sh index 52ae1cbf6091..58ffd1e19c67 100644 --- a/hack/util.sh +++ b/hack/util.sh @@ -50,6 +50,7 @@ function cleanup_openshift() { if [[ -z "${SKIP_TEARDOWN-}" ]]; then os::cleanup::dump_etcd + os::cleanup::dump_events os::log::info "Tearing down test" kill_all_processes