From ea7547cd42e6ce39c698c404d5271c854dbce0fb Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 9 Feb 2018 08:59:56 -0500 Subject: [PATCH] Check etcd port instead of process name currently the pgrep check does not allow any etcd process to exist other than the one we intend to start in our scripts. All we need to know is if the port is free. So let us use netstat to check if anyone is using that port. We don't really need to know if there is another instance of etcd is running or not. --- hack/lib/etcd.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hack/lib/etcd.sh b/hack/lib/etcd.sh index b8b03fe85ba..0685da4f138 100755 --- a/hack/lib/etcd.sh +++ b/hack/lib/etcd.sh @@ -27,10 +27,10 @@ kube::etcd::validate() { exit 1 } - # validate it is not running - if pgrep -x etcd >/dev/null 2>&1; then - kube::log::usage "etcd appears to already be running on this machine (`pgrep -xl etcd`) (or its a zombie and you need to kill its parent)." - kube::log::usage "retry after you resolve this etcd error." + # validate etcd port is free + if netstat -nat | grep "[\.:]${ETCD_PORT:?} .*LISTEN" >/dev/null 2>&1; then + kube::log::usage "unable to start etcd as port ${ETCD_PORT} is in use. please stop the process listening on this port and retry." + kube::log::usage "`netstat -nat | grep "[\.:]${ETCD_PORT:?} .*LISTEN"`" exit 1 fi