Fix etcd healthcheck

The etcd healthcheck was not working as it was trying to use
127.0.0.1:2379 as the etcd endpoint when none was specified.

This patch updates the healthcheck to set the $ETCDCTL_ENDPOINTS
environment variable for the etcdctl command after reading the value
from /etc/etcd/etcd.conf.

It also updates the existing healthcheck logic to use "grep -q" so that
log entries are not continually created every time the healthcheck is
executed.

Change-Id: If5ee2fdecf8c9ba458bce92fc2c427aeed1b865a
This commit is contained in:
James Slagle 2019-10-07 16:15:14 -04:00
parent 58abba685e
commit a5f5b369d4

View File

@ -1,5 +1,6 @@
#!/bin/bash
export ETCDCTL_API=3
etcdctl endpoint health | grep "is healthy"
export $(grep ETCD_LISTEN_CLIENT_URLS /etc/etcd/etcd.conf)
ETCDCTL_ENDPOINTS=$ETCD_LISTEN_CLIENT_URLS etcdctl endpoint health | grep -q "is healthy"
exit $?