Merge pull request #58303 from php-coder/fix_verify-swagger-spec_sript

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix update-swagger-spec.sh to always cleanup etcd

**What this PR does / why we need it**:
This PR fixes `hack/update-swagger-spec.sh` so it always cleanup etcd and to noe leave orphaned process after its execution. This process also doesn't allow to run the script again as it detects existing etcd and won't start.

I also made a minor improvement by adding guard against an empty arguments.

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

CC @simo5
pull/6/head
Kubernetes Submit Queue 2018-01-17 02:43:58 -08:00 committed by GitHub
commit 7bbab6234f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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() {

View File

@ -37,14 +37,17 @@ make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver
function cleanup()
{
[[ -n ${APISERVER_PID-} ]] && kill ${APISERVER_PID} 1>&2 2>/dev/null
if [[ -n "${APISERVER_PID-}" ]]; then
kill "${APISERVER_PID}" &>/dev/null || :
wait "${APISERVER_PID}" &>/dev/null || :
fi
kube::etcd::cleanup
kube::log::status "Clean up complete"
}
trap cleanup EXIT SIGINT
kube::util::trap_add cleanup EXIT
kube::golang::setup_env