Skip to content

Commit

Permalink
Merge pull request kubernetes#58303 from php-coder/fix_verify-swagger…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
Kubernetes Submit Queue authored Jan 17, 2018
2 parents 99fb21f + a2b728a commit 7bbab62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions hack/lib/etcd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 5 additions & 2 deletions hack/update-swagger-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7bbab62

Please sign in to comment.