hack/update-swagger-spec.sh(cleanup): fix signal handler to really cleanup etcd and minor improvements.

Prior this change, etcd wasn't cleaned up on my machine that lead to
orphaned etcd process after the update-swagger-spec.sh failed.

This change also adds additional improvements:
- don't kill/wait/rm when argument is empty.
- use kube::util::trap_add.
This commit is contained in:
Slava Semushin
2018-01-15 20:38:23 +01:00
parent e290741719
commit a2b728a706
2 changed files with 12 additions and 5 deletions

View File

@@ -74,12 +74,16 @@ kube::etcd::start() {
}
kube::etcd::stop() {
kill "${ETCD_PID-}" >/dev/null 2>&1 || :
wait "${ETCD_PID-}" >/dev/null 2>&1 || :
if [[ -n "${ETCD_PID-}" ]]; then
kill "${ETCD_PID}" &>/dev/null || :
wait "${ETCD_PID}" &>/dev/null || :
fi
}
kube::etcd::clean_etcd_dir() {
rm -rf "${ETCD_DIR-}"
if [[ -n "${ETCD_DIR-}" ]]; then
rm -rf "${ETCD_DIR}"
fi
}
kube::etcd::cleanup() {