Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: Correct VTAdmin Discovery File Path And Add Check #12415

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions examples/common/scripts/vtadmin-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
script_dir="$(dirname "${BASH_SOURCE[0]:-$0}")"
source "${script_dir}/../env.sh"

cluster_name="local"
log_dir="${VTDATAROOT}/tmp"
web_dir="${script_dir}/../../../web/vtadmin"

Expand All @@ -20,7 +21,7 @@ vtadmin \
--alsologtostderr \
--rbac \
--rbac-config="${script_dir}/../vtadmin/rbac.yaml" \
--cluster "id=local,name=local,discovery=staticfile,discovery-staticfile-path=./vtadmin/discovery.json,tablet-fqdn-tmpl={{ .Tablet.Hostname }}:15{{ .Tablet.Alias.Uid }}" \
--cluster "id=${cluster_name},name=${cluster_name},discovery=staticfile,discovery-staticfile-path=${script_dir}/../vtadmin/discovery.json,tablet-fqdn-tmpl={{ .Tablet.Hostname }}:15{{ .Tablet.Alias.Uid }}" \
> "${log_dir}/vtadmin-api.out" 2>&1 &

vtadmin_api_pid=$!
Expand All @@ -33,14 +34,26 @@ vtadmin-api is running!
- PID: ${vtadmin_api_pid}
"

# Wait for vtadmin to successfully discover the cluster
for _ in {0..300}; do
id=$(curl -s "http://${hostname}:${vtadmin_api_port}/api/clusters" | jq -r '.result.clusters[0].name')
if [[ ${id} == "${cluster_name}" ]]; then
break
fi
sleep 0.1
done

# Check one last time
[[ $(curl -s "http://${hostname}:${vtadmin_api_port}/api/clusters" | jq -r '.result.clusters[0].name') == "${cluster_name}" ]] || fail "vtadmin failed to discover the running example Vitess cluster."

# As a TODO, it'd be nice to make the assumption that vtadmin-web is already
# installed and built (since we assume that `make` has already been run for
# other Vitess components.)
npm --prefix $web_dir --silent install
npm --prefix "$web_dir" --silent install

REACT_APP_VTADMIN_API_ADDRESS="http://localhost:${vtadmin_api_port}" \
REACT_APP_ENABLE_EXPERIMENTAL_TABLET_DEBUG_VARS="true" \
npm run --prefix $web_dir build
npm run --prefix "$web_dir" build

"${web_dir}/node_modules/.bin/serve" --no-clipboard -l $vtadmin_web_port -s "${web_dir}/build" \
> "${log_dir}/vtadmin-web.out" 2>&1 &
Expand Down