vtadmin

package
v0.15.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

README

VTAdmin

VTAdmin is web UI and API that allows users to manage multiple Vitess clusters at once.

For a more detailed writeup, refer to the original RFC.

Setup

The simplest VTAdmin deployment involves a single Vitess cluster. You can look at the local example for a minimal invocation of the vtadmin-api and vtadmin-web binaries.

Important vtadmin-api flags

Please refer to vtadmin --help for the full listing, but a few flags warrant explanation here.

  • --http-origin — this flag sets up the allowed CORS origins that vtadmin-api will serve HTTP requests for, and is required if you are (very likely) running vtadmin-api and vtadmin-web on different domains.

  • --cluster, --cluster-defaults — A DSN-style flag that allows cluster configuration options to be specified on the command-line rather than needing a config file. When both command-line cluster configs and a config file are provided, any options for a given cluster on the command-line take precedence over options for that cluster in the config file.

    For a description of the cluster configuration options, see clusters.example.yaml.

  • --http-tablet-url-tmpl — Go template string to generate a reachable http(s) address for a tablet, used to make passthrough requests to /debug/vars endpoints.

Development

Building vtadmin-api

If you are making changes to .proto files, make sure you run

source dev.env
make proto grpcvtctldclient vtadmin_web_proto_types

Then, you can run make build, and run ./bin/vtadmin with any flags you need (see the local example, and also the section on flags above).

Building and running vtadmin-web

Make sure you are using node version 16.x.

Then, you may run:

cd ./web/vtadmin
npm install

# This should be the address you passed to `./vtadmin --addr`. For example,
# "http://127.0.0.1:14200".
export VITE_VTADMIN_API_ADDRESS="${vtadmin_api_addr}"
export VITE_ENABLE_EXPERIMENTAL_TABLET_DEBUG_VARS="true"
npm run start

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	vtadminpb.UnimplementedVTAdminServer
	// contains filtered or unexported fields
}

API is the main entrypoint for the vtadmin server. It implements vtadminpb.VTAdminServer.

func NewAPI

func NewAPI(env *vtenv.Environment, clusters []*cluster.Cluster, opts Options) *API

NewAPI returns a new API, configured to service the given set of clusters, and configured with the given options.

func (*API) ApplySchema

ApplySchema is part of the vtadminpb.VTAdminServer interface.

func (*API) CancelSchemaMigration

CancelSchemaMigration is part of the vtadminpb.VTAdminServer interface.

func (*API) CleanupSchemaMigration

CleanupSchemaMigration is part of the vtadminpb.VTAdminServer interface.

func (*API) Close

func (api *API) Close() error

Close closes all the clusters in an API concurrently. Its primary function is to gracefully shutdown cache background goroutines to avoid data races in tests, but needs to be exported to be called by those tests. It does not have any production use case.

func (*API) CompleteSchemaMigration

CompleteSchemaMigration is part of the vtadminpb.VTAdminServer interface.

func (*API) CreateKeyspace

CreateKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) CreateShard

CreateShard is part of the vtadminpb.VTAdminServer interface.

func (*API) DeleteKeyspace

DeleteKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) DeleteShards

DeleteShards is part of the vtadminpb.VTAdminServer interface.

func (*API) DeleteTablet

DeleteTablet is part of the vtadminpb.VTAdminServer interface.

func (*API) EjectDynamicCluster

func (api *API) EjectDynamicCluster(key string, value any)

func (*API) EmergencyFailoverShard

EmergencyFailoverShard is part of the vtadminpb.VTAdminServer interface.

func (*API) FindSchema

func (api *API) FindSchema(ctx context.Context, req *vtadminpb.FindSchemaRequest) (*vtadminpb.Schema, error)

FindSchema is part of the vtadminpb.VTAdminServer interface.

func (*API) GetBackups

GetBackups is part of the vtadminpb.VTAdminServer interface.

func (*API) GetCellInfos

GetCellInfos is part of the vtadminpb.VTAdminServer interface.

func (*API) GetCellsAliases

GetCellsAliases is part of the vtadminpb.VTAdminServer interface.

func (*API) GetClusters

GetClusters is part of the vtadminpb.VTAdminServer interface.

func (*API) GetFullStatus

GetFullStatus is part of the vtadminpb.VTAdminServer interface.

func (*API) GetGates

GetGates is part of the vtadminpb.VTAdminServer interface.

func (*API) GetKeyspace

func (api *API) GetKeyspace(ctx context.Context, req *vtadminpb.GetKeyspaceRequest) (*vtadminpb.Keyspace, error)

GetKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) GetKeyspaces

GetKeyspaces is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSchema

func (api *API) GetSchema(ctx context.Context, req *vtadminpb.GetSchemaRequest) (*vtadminpb.Schema, error)

GetSchema is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSchemaMigrations

GetSchemaMigrations is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSchemas

GetSchemas is part of the vtadminpb.VTAdminServer interface.

func (*API) GetShardReplicationPositions

GetShardReplicationPositions is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSrvKeyspace

GetSrvKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSrvKeyspaces

GetSrvKeyspaces is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSrvVSchema

func (api *API) GetSrvVSchema(ctx context.Context, req *vtadminpb.GetSrvVSchemaRequest) (*vtadminpb.SrvVSchema, error)

GetSrvVSchema is part of the vtadminpb.VTAdminServer interface.

func (*API) GetSrvVSchemas

GetSrvVSchemas is part of the vtadminpb.VTAdminServer interface.

func (*API) GetTablet

func (api *API) GetTablet(ctx context.Context, req *vtadminpb.GetTabletRequest) (*vtadminpb.Tablet, error)

GetTablet is part of the vtadminpb.VTAdminServer interface.

func (*API) GetTablets

GetTablets is part of the vtadminpb.VTAdminServer interface.

func (*API) GetTopologyPath

GetTopologyPath is part of the vtadminpb.VTAdminServer interface.

func (*API) GetVSchema

func (api *API) GetVSchema(ctx context.Context, req *vtadminpb.GetVSchemaRequest) (*vtadminpb.VSchema, error)

GetVSchema is part of the vtadminpb.VTAdminServer interface.

func (*API) GetVSchemas

GetVSchemas is part of the vtadminpb.VTAdminServer interface.

func (*API) GetVtctlds

GetVtctlds is part of the vtadminpb.VTAdminServer interface.

func (*API) GetWorkflow

func (api *API) GetWorkflow(ctx context.Context, req *vtadminpb.GetWorkflowRequest) (*vtadminpb.Workflow, error)

GetWorkflow is part of the vtadminpb.VTAdminServer interface.

func (*API) GetWorkflows

GetWorkflows is part of the vtadminpb.VTAdminServer interface.

func (*API) Handler

func (api *API) Handler() http.Handler

Handler handles all routes under "/api" (see above)

func (*API) LaunchSchemaMigration

LaunchSchemaMigration is part of the vtadminpb.VTAdminServer interface.

func (*API) ListenAndServe

func (api *API) ListenAndServe() error

ListenAndServe starts serving this API on the configured Addr (see grpcserver.Options) until shutdown or irrecoverable error occurs.

func (*API) PingTablet

PingTablet is part of the vtadminpb.VTAdminServer interface.

func (*API) PlannedFailoverShard

PlannedFailoverShard is part of the vtadminpb.VTAdminServer interface.

func (*API) RebuildKeyspaceGraph

RebuildKeyspaceGraph is a part of the vtadminpb.VTAdminServer interface.

func (*API) RefreshState

RefreshState is part of the vtadminpb.VTAdminServer interface.

func (*API) RefreshTabletReplicationSource

RefreshTabletReplicationSource is part of the vtadminpb.VTAdminServer interface.

func (*API) ReloadSchemaShard

ReloadSchemaShard is part of the vtadminpb.VTAdminServer interface.

func (*API) ReloadSchemas

ReloadSchemas is part of the vtadminpb.VTAdminServer interface.

func (*API) RemoveKeyspaceCell

RemoveKeyspaceCell is a part of the vtadminpb.VTAdminServer interface.

func (*API) RetrySchemaMigration

RetrySchemaMigration is part of the vtadminpb.VTAdminServer interface.

func (*API) RunHealthCheck

RunHealthCheck is part of the vtadminpb.VTAdminServer interface.

func (*API) ServeHTTP

func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves all routes matching path "/api" (see above) It first processes cookies, and acts accordingly Primarily, it sets up a dynamic API if HttpOpts.EnableDynamicClusters is set to true.

func (*API) SetReadOnly

SetReadOnly is part of the vtadminpb.VTAdminServer interface.

func (*API) SetReadWrite

SetReadWrite is part of the vtadminpb.VTAdminServer interface.

func (*API) StartReplication

StartReplication is part of the vtadminpb.VTAdminServer interface.

func (*API) StopReplication

StopReplication is part of the vtadminpb.VTAdminServer interface.

func (*API) TabletExternallyPromoted

TabletExternallyPromoted is part of the vtadminpb.VTAdminServer interface.

func (*API) VTExplain

VTExplain is part of the vtadminpb.VTAdminServer interface.

func (*API) Validate

Validate is part of the vtadminpb.VTAdminServer interface.

func (*API) ValidateKeyspace

ValidateKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) ValidateSchemaKeyspace

ValidateSchemaKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) ValidateShard

ValidateShard is part of the vtadminpb.VTAdminServer interface.

func (*API) ValidateVersionKeyspace

ValidateVersionKeyspace is part of the vtadminpb.VTAdminServer interface.

func (*API) ValidateVersionShard

ValidateVersionShard is part of the vtadminpb.VTAdminServer interface.

func (*API) WithCluster

func (api *API) WithCluster(c *cluster.Cluster, id string) dynamic.API

WithCluster returns a dynamic API with the given cluster. If `c` is non-nil, it is used as the selected cluster. If the cluster is nil, then a cluster with the given id is retrieved from the API and used in the dynamic API.

Callers must ensure that: 1. If c is non-nil, c.ID == id. 2. id is non-empty.

Note that using dynamic.ClusterFromString ensures both of these preconditions.

type Options

type Options struct {
	GRPCOpts grpcserver.Options
	HTTPOpts vtadminhttp.Options
	RBAC     *rbac.Config
	// EnableDynamicClusters makes it so that clients can pass clusters dynamically
	// in a session-like way, either via HTTP cookies or gRPC metadata.
	EnableDynamicClusters bool
}

Options wraps the configuration options for different components of the vtadmin API.

Directories

Path Synopsis
Package cache provides a generic key/value cache with support for background filling.
Package cache provides a generic key/value cache with support for background filling.
discovery/fakediscovery
Package fakediscovery provides a fake, in-memory discovery implementation.
Package fakediscovery provides a fake, in-memory discovery implementation.
internal/caches/schemacache
Package schemacache provides wrapper functions for interacting with instances of the generic (vtadmin/cache).Cache that store schemas.
Package schemacache provides wrapper functions for interacting with instances of the generic (vtadmin/cache).Cache that store schemas.
resolver
Package resolver provides a discovery-based resolver for VTAdmin clusters.
Package resolver provides a discovery-based resolver for VTAdmin clusters.
internal
backoff
Package backoff implements different backoff strategies for retrying failed operations in VTAdmin.
Package backoff implements different backoff strategies for retrying failed operations in VTAdmin.
Package rbac provides role-based access control for vtadmin API endpoints.
Package rbac provides role-based access control for vtadmin API endpoints.
Package sort provides convenience wrappers for sorting various vtadmin types.
Package sort provides convenience wrappers for sorting various vtadmin types.
Package vtadminproto provides helper functions for working with vtadminpb protobuf types.
Package vtadminproto provides helper functions for working with vtadminpb protobuf types.
fakevtsql
Package fakevtsql provides an interface for mocking out sql.DB responses in tests that depend on a vtsql.DB instance.
Package fakevtsql provides an interface for mocking out sql.DB responses in tests that depend on a vtsql.DB instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL