Skip to content

Commit

Permalink
Merge pull request #5427 from planetscale/morgo-etcd-as-prereq
Browse files Browse the repository at this point in the history
Search for etcd in PATH, don't install if installed
  • Loading branch information
morgo authored Nov 15, 2019
2 parents 177653e + 86e1499 commit bd7cb8a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ function install_etcd() {
rm "$file"
ln -snf "$dist/etcd-${version}-${platform}-${target}/etcd" "$VTROOT/bin/etcd"
}
install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd

# Install etcd if not detected
which etcd || install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd

echo
echo "bootstrap finished"
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function install_etcd() {
rm "$file"
ln -snf "$dist/etcd-${version}-${platform}-${target}/etcd" "$VTROOT/bin/etcd"
}
install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd
which etcd || install_dep "etcd" "v3.3.10" "$VTROOT/dist/etcd" install_etcd


# Download and install consul, link consul binary into our root.
Expand Down
7 changes: 0 additions & 7 deletions examples/local/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ if [ "${TOPO}" = "zk2" ]; then
else
echo "enter etcd2 env"

case $(uname) in
Linux) etcd_platform=linux;;
Darwin) etcd_platform=darwin;;
esac

ETCD_SERVER="localhost:2379"
ETCD_VERSION=$(cat "${VTROOT}/dist/etcd/.installed_version")
ETCD_BINDIR="${VTROOT}/dist/etcd/etcd-${ETCD_VERSION}-${etcd_platform}-amd64/"
TOPOLOGY_FLAGS="-topo_implementation etcd2 -topo_global_server_address $ETCD_SERVER -topo_global_root /vitess/global"

mkdir -p "${VTDATAROOT}/tmp"
Expand Down
2 changes: 1 addition & 1 deletion examples/local/etcd-down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This is an example script that stops the ZooKeeper servers started by zk-up.sh.
# This is an example script that stops the etcd servers started by etcd-up.sh.

set -e

Expand Down
7 changes: 4 additions & 3 deletions examples/local/etcd-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,23 @@ set -e
cell=${CELL:-'test'}

script_root=$(dirname "${BASH_SOURCE[0]}")
export ETCDCTL_API=2

# shellcheck source=./env.sh
# shellcheck disable=SC1091
source "${script_root}/env.sh"

${ETCD_BINDIR}/etcd --data-dir "${VTDATAROOT}/etcd/" --listen-client-urls "http://${ETCD_SERVER}" --advertise-client-urls "http://${ETCD_SERVER}" > "${VTDATAROOT}"/tmp/etcd.out 2>&1 &
etcd --data-dir "${VTDATAROOT}/etcd/" --listen-client-urls "http://${ETCD_SERVER}" --advertise-client-urls "http://${ETCD_SERVER}" > "${VTDATAROOT}"/tmp/etcd.out 2>&1 &
PID=$!
echo $PID > "${VTDATAROOT}/tmp/etcd.pid"
sleep 5

echo "add /vitess/global"
${ETCD_BINDIR}/etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/global &
etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/global &


echo "add /vitess/$cell"
${ETCD_BINDIR}/etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/$cell &
etcdctl --endpoints "http://${ETCD_SERVER}" mkdir /vitess/$cell &

# And also add the CellInfo description for the cell.
# If the node already exists, it's fine, means we used existing data.
Expand Down

0 comments on commit bd7cb8a

Please sign in to comment.