Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/vt/vtadmin/web/build/**/* linguist-generated=true
15 changes: 6 additions & 9 deletions .github/workflows/vtadmin_web_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ on:
push:
paths:
- '.github/workflows/vtadmin_web_build.yml'
- 'go/vt/vtadmin/web/**'
- 'tools/check_vtadmin_web_embed.sh'
- 'web/vtadmin/**'
pull_request:
paths:
- '.github/workflows/vtadmin_web_build.yml'
- 'go/vt/vtadmin/web/**'
- 'tools/check_vtadmin_web_embed.sh'
- 'web/vtadmin/**'

defaults:
run:
working-directory: ./web/vtadmin

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -27,11 +27,8 @@ jobs:
# node-version should match package.json
node-version: '16.13.0'

- name: Install dependencies
run: npm ci

- name: Build front-end
run: npm run build
- name: Build front-end and validate embedded files
run: tools/check_vtadmin_web_embed.sh

# Cancel pending and in-progress runs of this workflow if a newer ref is pushed to CI.
concurrency:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ tags

# C build dirs
**/build
!go/vt/vtadmin/web/build

# generated protobuf files
/go/vt/.proto.tmp
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ web_start: web_bootstrap
vtadmin_web_install:
cd web/vtadmin && npm install

# Builds the vtadmin-web front-end files that are embedded in the vtadmin binary.
vtadmin_web_embed: vtadmin_web_install
./tools/vtadmin_web_embed.sh

# Generate JavaScript/TypeScript bindings for vtadmin-web from the Vitess .proto files.
# Eventually, we'll want to call this target as part of the standard `make proto` target.
# While vtadmin-web is new and unstable, however, we can keep it out of the critical build path.
Expand Down
7 changes: 2 additions & 5 deletions examples/local/scripts/vtadmin-down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@

source ./env.sh

echo "Stopping vtadmin-web..."
kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-web.pid")"

echo "Stopping vtadmin-api..."
kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin-api.pid")"
echo "Stopping vtadmin..."
kill -9 "$(cat "$VTDATAROOT/tmp/vtadmin.pid")"
40 changes: 8 additions & 32 deletions examples/local/scripts/vtadmin-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
source ./env.sh

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

vtadmin_api_port=14200
vtadmin_web_port=14201

vtadmin \
--addr ":${vtadmin_api_port}" \
--http-origin "http://localhost:${vtadmin_web_port}" \
--http-tablet-url-tmpl "http://{{ .Tablet.Hostname }}:15{{ .Tablet.Alias.Uid }}" \
--tracer "opentracing-jaeger" \
--grpc-tracing \
Expand All @@ -20,36 +17,15 @@ vtadmin \
--rbac \
--rbac-config="./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 }}" \
> "${log_dir}/vtadmin-api.out" 2>&1 &
> "${log_dir}/vtadmin.out" 2>&1 &

vtadmin_api_pid=$!
echo ${vtadmin_api_pid} > "${log_dir}/vtadmin-api.pid"
vtadmin_pid=$!
echo ${vtadmin_pid} > "${log_dir}/vtadmin.pid"

echo "\
vtadmin-api is running!
- API: http://localhost:${vtadmin_api_port}
- Logs: ${log_dir}/vtadmin-api.out
- PID: ${vtadmin_api_pid}
"

# 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

REACT_APP_VTADMIN_API_ADDRESS="http://localhost:${vtadmin_api_port}" \
REACT_APP_ENABLE_EXPERIMENTAL_TABLET_DEBUG_VARS="true" \
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 &

vtadmin_web_pid=$!
echo ${vtadmin_web_pid} > "${log_dir}/vtadmin-web.pid"

echo "\
vtadmin-web is running!
- Browser: http://localhost:${vtadmin_web_port}
- Logs: ${log_dir}/vtadmin-web.out
- PID: ${vtadmin_web_pid}
vtadmin is running!
- Web: http://localhost:${vtadmin_api_port}
- API: http://localhost:${vtadmin_api_port}/api
- Logs: ${log_dir}/vtadmin.out
- PID: ${vtadmin_pid}
"
1 change: 1 addition & 0 deletions go/cmd/vtadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func main() {
// HTTP server flags
rootCmd.Flags().BoolVar(&httpOpts.DisableCompression, "http-no-compress", false, "whether to disable compression of HTTP API responses")
rootCmd.Flags().BoolVar(&httpOpts.DisableDebug, "http-no-debug", false, "whether to disable /debug/pprof/* and /debug/env HTTP endpoints")
rootCmd.Flags().BoolVar(&httpOpts.DisableWeb, "http-no-web", false, "whether to disable the web interface")
rootCmd.Flags().Var(&debug.OmitEnv, "http-debug-omit-env", "name of an environment variable to omit from /debug/env, if http debug endpoints are enabled. specify multiple times to omit multiple env vars")
rootCmd.Flags().Var(&debug.SanitizeEnv, "http-debug-sanitize-env", "name of an environment variable to sanitize in /debug/env, if http debug endpoints are enabled. specify multiple times to sanitize multiple env vars")
rootCmd.Flags().StringSliceVar(&httpOpts.CORSOrigins, "http-origin", []string{}, "repeated, comma-separated flag of allowed CORS origins. omit to disable CORS")
Expand Down
6 changes: 6 additions & 0 deletions go/vt/vtadmin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"vitess.io/vitess/go/vt/vtadmin/rbac"
"vitess.io/vitess/go/vt/vtadmin/sort"
"vitess.io/vitess/go/vt/vtadmin/vtadminproto"
"vitess.io/vitess/go/vt/vtadmin/web"
"vitess.io/vitess/go/vt/vterrors"
"vitess.io/vitess/go/vt/vtexplain"

Expand Down Expand Up @@ -182,6 +183,11 @@ func NewAPI(clusters []*cluster.Cluster, opts Options) *API {
debugRouter.HandleFunc("/clusters", debug.Clusters(dapi))
}

if !opts.HTTPOpts.DisableWeb {
// Catch-all route for vtadmin-web
serv.Router().PathPrefix("/").Handler(web.Handler())
}

// Middlewares are executed in order of addition. Our ordering (all
// middlewares being optional) is:
// 1. CORS. CORS is a special case and is applied globally, the rest are applied only to the subrouter.
Expand Down
8 changes: 7 additions & 1 deletion go/vt/vtadmin/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ type Options struct {
DisableCompression bool
// DisableDebug specifies whether to omit the /debug/pprof/* and /debug/env
// routes.
DisableDebug bool
DisableDebug bool

// DisableWeb specifies whether to disable the web interface.
// This should be true when running VTAdmin as a standalone HTTP/gRPC API,
// as when running vtadmin-web and vtadmin-api as separate components.
DisableWeb bool

ExperimentalOptions struct {
TabletURLTmpl string
}
Expand Down
1 change: 1 addition & 0 deletions go/vt/vtadmin/web/build/200.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/vt/vtadmin/web/build/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions go/vt/vtadmin/web/build/asset-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading