spec

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2023 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentTiDB             = "tidb"
	ComponentTiKV             = "tikv"
	ComponentPD               = "pd"
	ComponentTiFlash          = "tiflash"
	ComponentGrafana          = "grafana"
	ComponentDrainer          = "drainer"
	ComponentPump             = "pump"
	ComponentCDC              = "cdc"
	ComponentTiSpark          = "tispark"
	ComponentSpark            = "spark"
	ComponentAlertmanager     = "alertmanager"
	ComponentDMMaster         = "dm-master"
	ComponentDMWorker         = "dm-worker"
	ComponentPrometheus       = "prometheus"
	ComponentPushwaygate      = "pushgateway"
	ComponentBlackboxExporter = "blackbox_exporter"
	ComponentNodeExporter     = "node_exporter"
	ComponentCheckCollector   = "insight"
	ComponentNginx            = "nginx"
)

Components names

View Source
const (
	TiUPPackageCacheDir = "packages"
	TiUPClusterDir      = "clusters"
	TiUPAuditDir        = "audit"
	TLSCertKeyDir       = "tls"
	TLSCACert           = "ca.crt"
	TLSCAKey            = "ca.pem"
	TLSClientCert       = "client.crt"
	TLSClientKey        = "client.pem"
	PFXClientCert       = "client.pfx"
)

sub directory names

View Source
const (
	// AnsibleImportedConfigPath is the sub path where all imported configs are stored
	AnsibleImportedConfigPath = "ansible-imported-configs"
	// TempConfigPath is the sub path where generated temporary configs are stored
	TempConfigPath = "config-cache"
)
View Source
const (

	// PatchDirName is the directory to store patch file eg. {PatchDirName}/tidb-hotfix.tar.gz
	PatchDirName = "patch"
	// BackupDirName is the directory to save backup files.
	BackupDirName = "backup"
)
View Source
const (
	TiFlashStorageKeyMainDirs   string = "storage.main.dir"
	TiFlashStorageKeyLatestDirs string = "storage.latest.dir"
	TiFlashStorageKeyRaftDirs   string = "storage.raft.dir"
)

key names for storage config

Variables

View Source
var (

	// ErrTopologyReadFailed is ErrTopologyReadFailed
	ErrTopologyReadFailed = errNSTopolohy.NewType("read_failed", utils.ErrTraitPreCheck)
	// ErrTopologyParseFailed is ErrTopologyParseFailed
	ErrTopologyParseFailed = errNSTopolohy.NewType("parse_failed", utils.ErrTraitPreCheck)
)
View Source
var (
	RoleMonitor       = "monitor"
	RoleTiSparkMaster = "tispark-master"
	RoleTiSparkWorker = "tispark-worker"
	TopoTypeTiDB      = "tidb-cluster"
	TopoTypeDM        = "dm-cluster"
)

general role names

View Source
var (

	// ErrCreateDirFailed is ErrCreateDirFailed
	ErrCreateDirFailed = errNS.NewType("create_dir_failed")
	// ErrSaveMetaFailed is ErrSaveMetaFailed
	ErrSaveMetaFailed = errNS.NewType("save_meta_failed")
)
View Source
var (
	ErrNoTiSparkMaster       = errors.New("there must be a Spark master node if you want to use the TiSpark component")
	ErrMultipleTiSparkMaster = errors.New("a TiSpark enabled cluster with more than 1 Spark master node is not supported")
	ErrMultipleTisparkWorker = errors.New("multiple TiSpark workers on the same host is not supported by Spark")
	ErrUserOrGroupInvalid    = errors.New(`linux username and groupname must start with a lower case letter or an underscore, ` +
		`followed by lower case letters, digits, underscores, or dashes. ` +
		`Usernames may only be up to 32 characters long. ` +
		`Groupnames may only be up to 16 characters long.`)
)

pre defined error types

View Source
var (
	// CopyConfigFile is the checkpoint to cache config file transfer action
	CopyConfigFile = checkpoint.Register(
		checkpoint.Field("config-file", reflect.DeepEqual),
	)
)
View Source
var ErrorCheckConfig = errors.New("check config failed")

ErrorCheckConfig represent error occurred in config check stage

Functions

func Abs

func Abs(user, path string) string

Abs returns the absolute path

func AlertManagerEndpoints

func AlertManagerEndpoints(alertmanager []*AlertmanagerSpec, user string, enableTLS bool) []*scripts.AlertManagerScript

AlertManagerEndpoints returns the AlertManager endpoints configurations

func AllComponentNames

func AllComponentNames() (roles []string)

AllComponentNames contains the names of all components. should include all components in ComponentsByStartOrder

func AuditDir

func AuditDir() string

AuditDir return the directory for saving audit log.

func CheckClusterDirConflict

func CheckClusterDirConflict(clusterList map[string]Metadata, clusterName string, topo Topology) error

CheckClusterDirConflict checks cluster dir conflict or overlap

func CheckClusterDirOverlap

func CheckClusterDirOverlap(entries []DirEntry) error

CheckClusterDirOverlap checks cluster dir overlaps with data or log. this should only be used across clusters. we don't allow to deploy log under data, and vise versa. ref https://github.com/luyomo/OhMyTiUP/issues/1047#issuecomment-761711508

func CheckClusterPortConflict

func CheckClusterPortConflict(clusterList map[string]Metadata, clusterName string, topo Topology) error

CheckClusterPortConflict checks cluster port conflict

func CheckTiKVLabels

func CheckTiKVLabels(pdLocLabels []string, slp TiKVLabelProvider) error

CheckTiKVLabels will check if tikv missing label or have wrong label

func ClusterPath

func ClusterPath(cluster string, subpath ...string) string

ClusterPath returns the full path to a subpath (file or directory) of a cluster, it is a subdir in the profile dir of the user, with the cluster name as its name. It is not guaranteed the path already exist.

func ComponentSubDir

func ComponentSubDir(comp, version string) string

ComponentSubDir maps a component with version to a subdir if needed

func ExpandRelativeDir

func ExpandRelativeDir(topo Topology)

ExpandRelativeDir fill DeployDir, DataDir and LogDir to absolute path

func FillHostArch

func FillHostArch(s interface{}, hostArch map[string]string) error

FillHostArch fills the topology with the given host->arch

func FlattenMap

func FlattenMap(ms map[string]interface{}) map[string]interface{}

FlattenMap convert mutil-layer map to single layer

func FoldMap

func FoldMap(ms map[string]interface{}) map[string]interface{}

FoldMap convert single layer map to multi-layer

func GetValueFromPath

func GetValueFromPath(m map[string]interface{}, p string) interface{}

GetValueFromPath try to find the value by path recursively

func HandleImportPathMigration

func HandleImportPathMigration(clsName string) error

HandleImportPathMigration tries to rename old configs file directory for imported clusters to the new name

func Initialize

func Initialize(base string) error

Initialize initializes the global variables of meta package. If the environment variable TIUP_COMPONENT_DATA_DIR is set, it is used as root of the profile directory, otherwise the `$HOME/.tiup` of current user is used. The directory will be created before return if it does not already exist.

func IterHost

func IterHost(topo Topology, fn func(instance Instance))

IterHost iterates one instance for each host

func LoadClientCert

func LoadClientCert(dir string) (*tls.Config, error)

LoadClientCert read and load the client cert key pair and CA cert

func Merge2Toml

func Merge2Toml(comp string, global, overwrite map[string]interface{}) ([]byte, error)

Merge2Toml merge the config of global.

func MergeConfig

func MergeConfig(orig map[string]interface{}, overwrites ...map[string]interface{}) map[string]interface{}

MergeConfig merge two or more config into one and unflat them config1:

a.b.a: 1
a.b.b: 2

config2:

a.b.a: 3
a.b.c: 4

config3:

b.c = 5

After MergeConfig(config1, config2, config3):

a:
  b:
    a: 3
    b: 2
    c: 4
b:
  c: 5

func MergeResourceControl

func MergeResourceControl(lhs, rhs meta.ResourceControl) meta.ResourceControl

MergeResourceControl merge the rhs into lhs and overwrite rhs if lhs has value for same field

func MultiDirAbs

func MultiDirAbs(user, paths string) []string

MultiDirAbs returns the absolute path for multi-dir separated by comma

func PackagePath

func PackagePath(comp string, version string, os string, arch string) string

PackagePath return the tar bar path

func ParseTopologyYaml

func ParseTopologyYaml(file string, out Topology) error

ParseTopologyYaml read yaml content from `file` and unmarshal it to `out`

func PortStarted

func PortStarted(ctx context.Context, e ctxt.Executor, port int, timeout uint64) error

PortStarted wait until a port is being listened

func PortStopped

func PortStopped(ctx context.Context, e ctxt.Executor, port int, timeout uint64) error

PortStopped wait until a port is being released

func ProfileDir

func ProfileDir() string

ProfileDir returns the full profile directory path of TiUP.

func ProfilePath

func ProfilePath(subpath ...string) string

ProfilePath joins a path under the profile dir

func ReadYamlFile

func ReadYamlFile(file string) ([]byte, error)

ReadYamlFile read yaml content from file`

func RelativePathDetect

func RelativePathDetect(topo interface{}, isSkipField func(reflect.Value) bool) error

RelativePathDetect detect if some specific path is relative path and report error

func SaveClusterMeta

func SaveClusterMeta(clusterName string, cmeta *ClusterMeta) error

SaveClusterMeta saves the cluster meta information to profile directory

func TiDBComponentVersion

func TiDBComponentVersion(comp, version string) string

TiDBComponentVersion maps the TiDB version to the third components binding version Empty version should be treate as the the last stable one

func UptimeByHost

func UptimeByHost(host string, port int, tlsCfg *tls.Config) time.Duration

UptimeByHost queries current uptime of the instance by http Prometheus metric api.

Types

type AlertManagerComponent

type AlertManagerComponent struct{ Topology }

AlertManagerComponent represents Alertmanager component.

func (*AlertManagerComponent) Instances

func (c *AlertManagerComponent) Instances() []Instance

Instances implements Component interface.

func (*AlertManagerComponent) Name

func (c *AlertManagerComponent) Name() string

Name implements Component interface.

func (*AlertManagerComponent) Role

func (c *AlertManagerComponent) Role() string

Role implements Component interface.

type AlertManagerInstance

type AlertManagerInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

AlertManagerInstance represent the alert manager instance

func (*AlertManagerInstance) InitConfig

func (i *AlertManagerInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*AlertManagerInstance) ScaleConfig

func (i *AlertManagerInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName string,
	clusterVersion string,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type AlertmanagerSpec

type AlertmanagerSpec struct {
	Host            string               `yaml:"host"`
	SSHPort         int                  `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported        bool                 `yaml:"imported,omitempty"`
	Patched         bool                 `yaml:"patched,omitempty"`
	IgnoreExporter  bool                 `yaml:"ignore_exporter,omitempty"`
	WebPort         int                  `yaml:"web_port" default:"9093"`
	ClusterPort     int                  `yaml:"cluster_port" default:"9094"`
	DeployDir       string               `yaml:"deploy_dir,omitempty"`
	DataDir         string               `yaml:"data_dir,omitempty"`
	LogDir          string               `yaml:"log_dir,omitempty"`
	NumaNode        string               `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	ResourceControl meta.ResourceControl `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string               `yaml:"arch,omitempty"`
	OS              string               `yaml:"os,omitempty"`
	ConfigFilePath  string               `yaml:"config_file,omitempty" validate:"config_file:editable"`
}

AlertmanagerSpec represents the AlertManager topology specification in topology.yaml

func (*AlertmanagerSpec) GetMainPort

func (s *AlertmanagerSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*AlertmanagerSpec) IgnoreMonitorAgent

func (s *AlertmanagerSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*AlertmanagerSpec) IsImported

func (s *AlertmanagerSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*AlertmanagerSpec) Role

func (s *AlertmanagerSpec) Role() string

Role returns the component role of the instance

func (*AlertmanagerSpec) SSH

func (s *AlertmanagerSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type AuroraConfig

type AuroraConfig struct {
	Name string `yaml:"name"`
}

type AwsAuroraConfigs

type AwsAuroraConfigs struct {
	InstanceType           string `yaml:"instance_type"`
	CIDR                   string `yaml:"cidr"`
	DBParameterFamilyGroup string `yaml:"db_parameter_family_group"`
	Engine                 string `yaml:"engine"`
	EngineVersion          string `yaml:"engine_version"`
	DBUserName             string `yaml:"db_username"`
	DBPassword             string `yaml:"db_password"`
	PubliclyAccessibleFlag bool   `yaml:"public_accessible_flag" default: false`
	S3BackupFolder         string `yaml:"s3backup_folder"`
}

type AwsCloudFormationConfigs

type AwsCloudFormationConfigs struct {
	Parameters           map[string]string `yaml:"parameters"`
	TemplateBodyFilePath string            `yaml:"template_body_file_path"`
	TemplateURL          string            `yaml:"template_url"`
}

type AwsDMSConfigs

type AwsDMSConfigs struct {
	CIDR         string `yaml:"cidr"`
	InstanceType string `yaml:"instance_type"`
}

type AwsESTopoConfigs

type AwsESTopoConfigs struct {
	General  AwsTopoConfigsGeneral `yaml:"general"`
	ESServer AwsNodeModal          `yaml:"es"`
}

type AwsKafkaTopoConfigs

type AwsKafkaTopoConfigs struct {
	General        AwsTopoConfigsGeneral `yaml:"general"`
	Zookeeper      AwsNodeModal          `yaml:"zookeeper"`
	Broker         AwsNodeModal          `yaml:"broker"`
	SchemaRegistry AwsNodeModal          `yaml:"schema_registry"`
	RestService    AwsNodeModal          `yaml:"rest_service"`
	Connector      AwsNodeModal          `yaml:"connector"`
}

type AwsMSConfigs

type AwsMSConfigs struct {
	ImageId                string `yaml:"imageid,omitempty"`
	CIDR                   string `yaml:"cidr"`
	InstanceType           string `yaml:"instance_type"`
	KeyName                string `yaml:"keyname"`
	DBParameterFamilyGroup string `yaml:"db_parameter_family_group"`
	Engine                 string `yaml:"engine"`
	EngineVerion           string `yaml:"engine_version"`
	DiskSize               int    `yaml:"disk_size"`
	DBMasterUser           string `yaml:"db_master_user"`
	DBMasterUserPass       string `yaml:"db_master_user_pass"`
}

type AwsMSKConnectPluginTopoConfigs

type AwsMSKConnectPluginTopoConfigs struct {
	Name     string `yaml:"name,omitempty"`
	URL      string `yaml:"url,omitempty"`
	S3Bucket string `yaml:"s3bucket,omitempty"`
	S3Folder string `yaml:"s3folder,omitempty"`
}

type AwsMSKTopoConfigs

type AwsMSKTopoConfigs struct {
	CIDR         string   `yaml:"cidr,omitempty"`
	InstanceType string   `yaml:"instance_type,omitempty"`
	ExcludedAZ   []string `yaml:"excluded_az,omitempty"`
	IncludedAZ   []string `yaml:"included_az,omitempty"`
	SubnetsNum   int      `yaml:"subnet_num,omitempty"`
}

type AwsMongoTopoConfigs

type AwsMongoTopoConfigs struct {
	General      AwsTopoConfigsGeneral `yaml:"general"`
	ConfigServer AwsNodeModal          `yaml:"config-server"`
	Mongos       AwsNodeModal          `yaml:"mongos"`
	ReplicaSet   []AwsNodeModal        `yaml:"replica-set"`
}

type AwsMySQLTopoConfigs

type AwsMySQLTopoConfigs struct {
	General AwsTopoConfigsGeneral `yaml:"general"`
	Worker  AwsNodeModal          `yaml:"worker"`
}

type AwsNodeModal

type AwsNodeModal struct {
	InstanceType    string `yaml:"instance_type"`
	Count           int    `yaml:"count"`
	VolumeSize      int    `yaml:"volumeSize,omitempty" default:"100"`
	VolumeType      string `yaml:"volumeType,omitempty" default:"gp3"`
	Iops            int    `yaml:"iops,omitempty" default:"3000"`
	DesiredCapacity int32  `yaml:"desired_capacity,omitempty" default:"0"`
	MinSize         int32  `yaml:"min_size,omitempty" default:"0"`
	MaxSize         int32  `yaml:"max_size,omitempty" default:"0"`
	Labels          []struct {
		Name  string `yaml:"Name,omitempty"`
		Value string `yaml:"Value,omitempty"`
	} `yaml:"labels"`
}

type AwsNodeVolume

type AwsNodeVolume struct {
	Size       int    `yaml:"size,omitempty" default:"100"`
	Iops       int    `yaml:"iops,omitempty" default:"3000"`
	VolumeType string `yaml:"volume-type,omitempty" default:"gp3"`
	Throughput int    `yaml:"throughput,omitempty"`
}

type AwsOracleConfigs

type AwsOracleConfigs struct {
	DBInstanceName string `yaml:"dbInstanceName" default:"orcl"`
	InstanceType   string `yaml:"instanceType"`
	VolumeSize     int    `yaml:"volumeSize"`
	DBUserName     string `yaml:"dbUserName"`
	DBPassword     string `yaml:"dbPassword"`
	CIDR           string `yaml:"cidr"`
}

type AwsPostgresConfigs

type AwsPostgresConfigs struct {
	InstanceType           string `yaml:"instance_type"`
	CIDR                   string `yaml:"cidr"`
	DBParameterFamilyGroup string `yaml:"db_parameter_family_group"`
	Engine                 string `yaml:"engine"`
	EngineVersion          string `yaml:"engine_version"`
	DBSize                 string `yaml:"db_size"`
	DBUserName             string `yaml:"db_username"`
	DBPassword             string `yaml:"db_password"`
	PubliclyAccessibleFlag bool   `yaml:"public_accessible_flag" default:"false"`
}

type AwsRedshiftTopoConfigs

type AwsRedshiftTopoConfigs struct {
	CIDR         string `yaml:"cidr,omitempty"`
	InstanceType string `yaml:"instance_type,omitempty"`
	AdminUser    string `yaml:"admin_user,omitempty"`
	Password     string `yaml:"password,omitempty"`
	ClusterType  string `yaml:"cluster_type,omitempty"`
}

type AwsTopoConfigs

type AwsTopoConfigs struct {
	General      AwsTopoConfigsGeneral `yaml:"general"`
	PD           AwsNodeModal          `yaml:"pd"`
	TiDB         AwsNodeModal          `yaml:"tidb"`
	TiKV         []AwsNodeModal        `yaml:"tikv"`
	TiFlash      AwsNodeModal          `yaml:"tiflash"`
	Monitor      AwsNodeModal          `yaml:"monitor"`
	Grafana      AwsNodeModal          `yaml:"grafana"`
	AlertManager AwsNodeModal          `yaml:"alert-manager"`
	DMMaster     AwsNodeModal          `yaml:"dm-master"`
	DMWorker     AwsNodeModal          `yaml:"dm-worker"`
	TiCDC        AwsNodeModal          `yaml:"ticdc"`
	Pump         AwsNodeModal          `yaml:"pump"`
	Drainer      AwsNodeModal          `yaml:"drainer"`
}

type AwsTopoConfigsGeneral

type AwsTopoConfigsGeneral struct {
	ImageId      string   `yaml:"imageid,omitempty"`
	Region       string   `yaml:"region,omitempty"`
	Name         string   `yaml:"name,omitempty"`
	KeyName      string   `yaml:"keyname,omitempty"`
	KeyFile      string   `yaml:"keyfile,omitempty"`
	CIDR         string   `yaml:"cidr,omitempty"`
	InstanceType string   `yaml:"instance_type,omitempty"`
	TiDBVersion  string   `yaml:"tidb_version"`
	ExcludedAZ   []string `yaml:"excluded_az,omitempty"`
	IncludedAZ   []string `yaml:"included_az,omitempty"`
	SubnetsNum   int      `yaml:"subnet_num,omitempty" default: 3`
	NetworkType  string   `yaml:"network_type" default:"private"`    // private/public/nat
	EnableThanos string   `yaml:"enable_thanos", default:"disabled"` // enabled/disabled
}

type AwsWSConfigs

type AwsWSConfigs struct {
	ImageId          string `yaml:"imageid,omitempty"`
	CIDR             string `yaml:"cidr"`
	InstanceType     string `yaml:"instance_type"`
	KeyName          string `yaml:"keyname" default:"jay.pingcap"`
	KeyFile          string `yaml:"keyfile" default:"/home/pi/.ssh/jaypingcap.pem"`
	UserName         string `yaml:"username" default:"admin"`
	VolumeSize       int    `yaml:"volumeSize,omitempty"`
	EnableMonitoring string `yaml:"enable_monitoring", default:"enabled"` // enabled/disabled
}

type BaseInstance

type BaseInstance struct {
	InstanceSpec

	Name       string
	Host       string
	ListenHost string
	Port       int
	SSHP       int

	Ports    []int
	Dirs     []string
	StatusFn func(tlsCfg *tls.Config, pdHosts ...string) string
	UptimeFn func(tlsCfg *tls.Config) time.Duration
}

BaseInstance implements some method of Instance interface..

func (*BaseInstance) Arch

func (i *BaseInstance) Arch() string

Arch implements Instance interface

func (*BaseInstance) ComponentName

func (i *BaseInstance) ComponentName() string

ComponentName implements Instance interface

func (*BaseInstance) DataDir

func (i *BaseInstance) DataDir() string

DataDir implements Instance interface

func (*BaseInstance) DeployDir

func (i *BaseInstance) DeployDir() string

DeployDir implements Instance interface

func (*BaseInstance) GetHost

func (i *BaseInstance) GetHost() string

GetHost implements Instance interface

func (*BaseInstance) GetListenHost

func (i *BaseInstance) GetListenHost() string

GetListenHost implements Instance interface

func (*BaseInstance) GetPort

func (i *BaseInstance) GetPort() int

GetPort implements Instance interface

func (*BaseInstance) GetSSHPort

func (i *BaseInstance) GetSSHPort() int

GetSSHPort implements Instance interface

func (*BaseInstance) ID

func (i *BaseInstance) ID() string

ID returns the identifier of this instance, the ID is constructed by host:port

func (*BaseInstance) InitConfig

func (i *BaseInstance) InitConfig(ctx context.Context, e ctxt.Executor, opt GlobalOptions, user string, paths meta.DirPaths) (err error)

InitConfig init the service configuration.

func (*BaseInstance) InstanceName

func (i *BaseInstance) InstanceName() string

InstanceName implements Instance interface

func (*BaseInstance) IsPatched

func (i *BaseInstance) IsPatched() bool

IsPatched implements Instance interface

func (*BaseInstance) IteratorLocalConfigDir

func (i *BaseInstance) IteratorLocalConfigDir(ctx context.Context, local string, filter func(string) bool, f func(string) error) error

IteratorLocalConfigDir iterators the local dir with filter, then invoke f for each found fileName

func (*BaseInstance) LogDir

func (i *BaseInstance) LogDir() string

LogDir implements Instance interface

func (*BaseInstance) MergeServerConfig

func (i *BaseInstance) MergeServerConfig(ctx context.Context, e ctxt.Executor, globalConf, instanceConf map[string]interface{}, paths meta.DirPaths) error

MergeServerConfig merges the server configuration and overwrite the global configuration

func (*BaseInstance) OS

func (i *BaseInstance) OS() string

OS implements Instance interface

func (*BaseInstance) PrepareStart

func (i *BaseInstance) PrepareStart(ctx context.Context, tlsCfg *tls.Config) error

PrepareStart checks instance requirements before starting

func (*BaseInstance) Ready

func (i *BaseInstance) Ready(ctx context.Context, e ctxt.Executor, timeout uint64) error

Ready implements Instance interface

func (*BaseInstance) ServiceName

func (i *BaseInstance) ServiceName() string

ServiceName implements Instance interface

func (*BaseInstance) SetPatched

func (i *BaseInstance) SetPatched(p bool)

SetPatched implements the Instance interface

func (*BaseInstance) Status

func (i *BaseInstance) Status(tlsCfg *tls.Config, pdList ...string) string

Status implements Instance interface

func (*BaseInstance) TransferLocalConfigDir

func (i *BaseInstance) TransferLocalConfigDir(ctx context.Context, e ctxt.Executor, local, remote string, filter func(string) bool) error

TransferLocalConfigDir scp local config directory to remote Precondition: the user on remote have right to access & mkdir of dest files

func (*BaseInstance) TransferLocalConfigFile

func (i *BaseInstance) TransferLocalConfigFile(ctx context.Context, e ctxt.Executor, local, remote string) error

TransferLocalConfigFile scp local config file to remote Precondition: the user on remote have permission to access & mkdir of dest files

func (*BaseInstance) Uptime

func (i *BaseInstance) Uptime(tlsCfg *tls.Config) time.Duration

Uptime implements Instance interface

func (*BaseInstance) UsedDirs

func (i *BaseInstance) UsedDirs() []string

UsedDirs implements Instance interface

func (*BaseInstance) UsedPorts

func (i *BaseInstance) UsedPorts() []int

UsedPorts implements Instance interface

type BaseMeta

type BaseMeta struct {
	User    string
	Group   string
	Version string
	OpsVer  *string `yaml:"last_ops_ver,omitempty"` // the version of ourself that updated the meta last time
}

BaseMeta is the base info of metadata.

type BaseTopo

type BaseTopo struct {
	GlobalOptions                  *GlobalOptions
	MonitoredOptions               *MonitoredOptions
	AwsWSConfigs                   *AwsWSConfigs
	AwsTopoConfigs                 *AwsTopoConfigs
	AwsKafkaTopoConfigs            *AwsKafkaTopoConfigs
	AwsMongoTopoConfigs            *AwsMongoTopoConfigs
	AwsESTopoConfigs               *AwsESTopoConfigs
	AwsAuroraConfigs               *AwsAuroraConfigs
	AwsMySQLConfigs                *AwsMySQLTopoConfigs
	AwsPostgresConfigs             *AwsPostgresConfigs
	AwsOracleConfigs               *AwsOracleConfigs
	AwsRedshiftTopoConfigs         *AwsRedshiftTopoConfigs
	AwsMSKConnectPluginTopoConfigs *AwsMSKConnectPluginTopoConfigs
	AwsMSKTopoConfigs              *AwsMSKTopoConfigs
	AwsMSConfigs                   *AwsMSConfigs
	AwsDMSConfigs                  *AwsDMSConfigs
	AwsCloudFormationConfigs       *AwsCloudFormationConfigs
	TiDBCloudConfigs               *TiDBCloudConfigs
	TiDBCloud                      *TiDBCloud
	DrainerReplicate               *DrainerReplicate
	MasterList                     []string

	Monitors      []*PrometheusSpec
	Grafanas      []*GrafanaSpec
	Alertmanagers []*AlertmanagerSpec
}

BaseTopo is the base info to topology.

type BindVersion

type BindVersion func(comp string, version string) (bindVersion string)

BindVersion map the cluster version to the third components binding version.

type CDCComponent

type CDCComponent struct{ Topology *Specification }

CDCComponent represents CDC component.

func (*CDCComponent) Instances

func (c *CDCComponent) Instances() []Instance

Instances implements Component interface.

func (*CDCComponent) Name

func (c *CDCComponent) Name() string

Name implements Component interface.

func (*CDCComponent) Role

func (c *CDCComponent) Role() string

Role implements Component interface.

type CDCInstance

type CDCInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

CDCInstance represent the CDC instance.

func (*CDCInstance) InitConfig

func (i *CDCInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implements Instance interface.

func (*CDCInstance) ScaleConfig

func (i *CDCInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	user string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type CDCSpec

type CDCSpec struct {
	Host            string                 `yaml:"host"`
	SSHPort         int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported        bool                   `yaml:"imported,omitempty"`
	Patched         bool                   `yaml:"patched,omitempty"`
	IgnoreExporter  bool                   `yaml:"ignore_exporter,omitempty"`
	Port            int                    `yaml:"port" default:"8300"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	Offline         bool                   `yaml:"offline,omitempty"`
	GCTTL           int64                  `yaml:"gc-ttl,omitempty" validate:"gc-ttl:editable"`
	TZ              string                 `yaml:"tz,omitempty" validate:"tz:editable"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

CDCSpec represents the Drainer topology specification in topology.yaml

func (*CDCSpec) GetMainPort

func (s *CDCSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*CDCSpec) IgnoreMonitorAgent

func (s *CDCSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*CDCSpec) IsImported

func (s *CDCSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*CDCSpec) Role

func (s *CDCSpec) Role() string

Role returns the component role of the instance

func (*CDCSpec) SSH

func (s *CDCSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type ClusterMeta

type ClusterMeta struct {
	User    string `yaml:"user"`         // the user to run and manage cluster on remote
	Version string `yaml:"tidb_version"` // the version of TiDB cluster
	// EnableFirewall bool   `yaml:"firewall"`
	OpsVer string `yaml:"last_ops_ver,omitempty"` // the version of ourself that updated the meta last time

	Topology *Specification `yaml:"topology"`
}

ClusterMeta is the specification of generic cluster metadata

func ClusterMetadata

func ClusterMetadata(clusterName string) (*ClusterMeta, error)

ClusterMetadata tries to read the metadata of a cluster from file

func (*ClusterMeta) GetBaseMeta

func (m *ClusterMeta) GetBaseMeta() *BaseMeta

GetBaseMeta implements Metadata interface.

func (*ClusterMeta) GetTopology

func (m *ClusterMeta) GetTopology() Topology

GetTopology implement Metadata interface.

func (*ClusterMeta) SetTopology

func (m *ClusterMeta) SetTopology(topo Topology)

SetTopology implement Metadata interface.

func (*ClusterMeta) SetUser

func (m *ClusterMeta) SetUser(s string)

SetUser implement UpgradableMetadata interface.

func (*ClusterMeta) SetVersion

func (m *ClusterMeta) SetVersion(s string)

SetVersion implement UpgradableMetadata interface.

type Component

type Component interface {
	Name() string
	Role() string
	Instances() []Instance
}

Component represents a component of the cluster.

func FindComponent

func FindComponent(topo Topology, name string) Component

FindComponent returns the Component corresponding the name

type DirAccessor

type DirAccessor struct {
	// contains filtered or unexported fields
}

DirAccessor stands for a directory accessor for an instance

type DirEntry

type DirEntry struct {
	// contains filtered or unexported fields
}

DirEntry stands for a directory with attributes and instance

type DrainerComponent

type DrainerComponent struct{ Topology *Specification }

DrainerComponent represents Drainer component.

func (*DrainerComponent) Instances

func (c *DrainerComponent) Instances() []Instance

Instances implements Component interface.

func (*DrainerComponent) Name

func (c *DrainerComponent) Name() string

Name implements Component interface.

func (*DrainerComponent) Role

func (c *DrainerComponent) Role() string

Role implements Component interface.

type DrainerInstance

type DrainerInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

DrainerInstance represent the Drainer instance.

func (*DrainerInstance) InitConfig

func (i *DrainerInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implements Instance interface.

func (*DrainerInstance) ScaleConfig

func (i *DrainerInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	user string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type DrainerReplicate

type DrainerReplicate struct {
	ReplicateDB string `yaml:"replicate_db"`
}

type DrainerSpec

type DrainerSpec struct {
	Host            string                 `yaml:"host"`
	SSHPort         int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported        bool                   `yaml:"imported,omitempty"`
	Patched         bool                   `yaml:"patched,omitempty"`
	IgnoreExporter  bool                   `yaml:"ignore_exporter,omitempty"`
	Port            int                    `yaml:"port" default:"8249"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	CommitTS        int64                  `yaml:"commit_ts,omitempty"`
	Offline         bool                   `yaml:"offline,omitempty"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

DrainerSpec represents the Drainer topology specification in topology.yaml

func (*DrainerSpec) GetMainPort

func (s *DrainerSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*DrainerSpec) IgnoreMonitorAgent

func (s *DrainerSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*DrainerSpec) IsImported

func (s *DrainerSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*DrainerSpec) Role

func (s *DrainerSpec) Role() string

Role returns the component role of the instance

func (*DrainerSpec) SSH

func (s *DrainerSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type ExternalAlertmanager

type ExternalAlertmanager struct {
	Host    string `yaml:"host"`
	WebPort int    `yaml:"web_port" default:"9093"`
}

ExternalAlertmanager configs prometheus to include alertmanagers not deployed in current cluster

type GlobalOptions

type GlobalOptions struct {
	User            string               `yaml:"user,omitempty" default:"tidb"`
	Group           string               `yaml:"group,omitempty"`
	Host            string               `yaml:"host,omitempty"`
	SSHKey          string               `yaml:"ssh_key,omitempty"`
	SSHPort         int                  `yaml:"ssh_port,omitempty" default:"22" validate:"ssh_port:editable"`
	SSHType         executor.SSHType     `yaml:"ssh_type,omitempty" default:"builtin"`
	TLSEnabled      bool                 `yaml:"enable_tls,omitempty"`
	DeployDir       string               `yaml:"deploy_dir,omitempty" default:"deploy"`
	DataDir         string               `yaml:"data_dir,omitempty" default:"data"`
	LogDir          string               `yaml:"log_dir,omitempty"`
	ResourceControl meta.ResourceControl `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	OS              string               `yaml:"os,omitempty" default:"linux"`
	Arch            string               `yaml:"arch,omitempty"`
	Custom          interface{}          `yaml:"custom,omitempty" validate:"custom:ignore"`
}

GlobalOptions represents the global options for all groups in topology specification in topology.yaml

type GrafanaComponent

type GrafanaComponent struct{ Topology }

GrafanaComponent represents Grafana component.

func (*GrafanaComponent) Instances

func (c *GrafanaComponent) Instances() []Instance

Instances implements Component interface.

func (*GrafanaComponent) Name

func (c *GrafanaComponent) Name() string

Name implements Component interface.

func (*GrafanaComponent) Role

func (c *GrafanaComponent) Role() string

Role implements Component interface.

type GrafanaInstance

type GrafanaInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

GrafanaInstance represent the grafana instance

func (*GrafanaInstance) InitConfig

func (i *GrafanaInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*GrafanaInstance) ScaleConfig

func (i *GrafanaInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName string,
	clusterVersion string,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type GrafanaSpec

type GrafanaSpec struct {
	Host            string               `yaml:"host"`
	SSHPort         int                  `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported        bool                 `yaml:"imported,omitempty"`
	Patched         bool                 `yaml:"patched,omitempty"`
	IgnoreExporter  bool                 `yaml:"ignore_exporter,omitempty"`
	Port            int                  `yaml:"port" default:"3000"`
	DeployDir       string               `yaml:"deploy_dir,omitempty"`
	ResourceControl meta.ResourceControl `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string               `yaml:"arch,omitempty"`
	OS              string               `yaml:"os,omitempty"`
	DashboardDir    string               `yaml:"dashboard_dir,omitempty" validate:"dashboard_dir:editable"`
	Username        string               `yaml:"username,omitempty" default:"admin" validate:"username:editable"`
	Password        string               `yaml:"password,omitempty" default:"admin" validate:"password:editable"`
	AnonymousEnable bool                 `yaml:"anonymous_enable" default:"false" validate:"anonymous_enable:editable"`
	RootURL         string               `yaml:"root_url" validate:"root_url:editable"`
	Domain          string               `yaml:"domain" validate:"domain:editable"`
}

GrafanaSpec represents the Grafana topology specification in topology.yaml

func (*GrafanaSpec) GetMainPort

func (s *GrafanaSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*GrafanaSpec) IgnoreMonitorAgent

func (s *GrafanaSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*GrafanaSpec) IsImported

func (s *GrafanaSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*GrafanaSpec) Role

func (s *GrafanaSpec) Role() string

Role returns the component role of the instance

func (*GrafanaSpec) SSH

func (s *GrafanaSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type Instance

type Instance interface {
	InstanceSpec
	ID() string
	Ready(context.Context, ctxt.Executor, uint64) error
	InitConfig(ctx context.Context, e ctxt.Executor, clusterName string, clusterVersion string, deployUser string, paths meta.DirPaths) error
	ScaleConfig(ctx context.Context, e ctxt.Executor, topo Topology, clusterName string, clusterVersion string, deployUser string, paths meta.DirPaths) error
	PrepareStart(ctx context.Context, tlsCfg *tls.Config) error
	ComponentName() string
	InstanceName() string
	ServiceName() string
	GetHost() string
	GetPort() int
	GetSSHPort() int
	DeployDir() string
	UsedPorts() []int
	UsedDirs() []string
	Status(tlsCfg *tls.Config, pdList ...string) string
	Uptime(tlsCfg *tls.Config) time.Duration
	DataDir() string
	LogDir() string
	OS() string // only linux supported now
	Arch() string
	IsPatched() bool
	SetPatched(bool)
}

Instance represents the instance.

type InstanceSpec

type InstanceSpec interface {
	Role() string
	SSH() (string, int)
	GetMainPort() int
	IsImported() bool
	IgnoreMonitorAgent() bool
}

InstanceSpec represent a instance specification

type Metadata

type Metadata interface {
	GetTopology() Topology
	SetTopology(topo Topology)
	GetBaseMeta() *BaseMeta

	UpgradableMetadata
}

Metadata of a cluster.

type MonitorComponent

type MonitorComponent struct{ Topology }

MonitorComponent represents Monitor component.

func (*MonitorComponent) Instances

func (c *MonitorComponent) Instances() []Instance

Instances implements Component interface.

func (*MonitorComponent) Name

func (c *MonitorComponent) Name() string

Name implements Component interface.

func (*MonitorComponent) Role

func (c *MonitorComponent) Role() string

Role implements Component interface.

type MonitorInstance

type MonitorInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

MonitorInstance represent the monitor instance

func (*MonitorInstance) InitConfig

func (i *MonitorInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*MonitorInstance) ScaleConfig

func (i *MonitorInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName string,
	clusterVersion string,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type MonitoredOptions

type MonitoredOptions struct {
	NodeExporterPort     int                  `yaml:"node_exporter_port,omitempty" default:"9100"`
	BlackboxExporterPort int                  `yaml:"blackbox_exporter_port,omitempty" default:"9115"`
	DeployDir            string               `yaml:"deploy_dir,omitempty"`
	DataDir              string               `yaml:"data_dir,omitempty"`
	LogDir               string               `yaml:"log_dir,omitempty"`
	NumaNode             string               `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	ResourceControl      meta.ResourceControl `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
}

MonitoredOptions represents the monitored node configuration

type NginxComponent

type NginxComponent struct{ Topology *Specification }

NginxComponent represents PD component.

func (*NginxComponent) Instances

func (c *NginxComponent) Instances() []Instance

Instances implements Component interface.

func (*NginxComponent) Name

func (c *NginxComponent) Name() string

Name implements Component interface.

func (*NginxComponent) Role

func (c *NginxComponent) Role() string

Role implements Component interface.

type NginxInstance

type NginxInstance struct {
	Name string
	BaseInstance
	// contains filtered or unexported fields
}

PDInstance represent the PD instance

func (*NginxInstance) InitConfig

func (i *NginxInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*NginxInstance) ScaleConfig

func (i *NginxInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type NginxSpec

type NginxSpec struct {
	Host           string `yaml:"host"`
	ListenHost     string `yaml:"listen_host,omitempty"`
	SSHPort        int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported       bool   `yaml:"imported,omitempty"`
	Patched        bool   `yaml:"patched,omitempty"`
	IgnoreExporter bool   `yaml:"ignore_exporter,omitempty"`
	// Use Name to get the name with a default value if it's empty.
	Name            string                 `yaml:"name"`
	ClientPort      int                    `yaml:"client_port" default:"18080"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

NginxSpec represents the PD topology specification in topology.yaml

func (*NginxSpec) GetMainPort

func (s *NginxSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*NginxSpec) IgnoreMonitorAgent

func (s *NginxSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*NginxSpec) IsImported

func (s *NginxSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*NginxSpec) Role

func (s *NginxSpec) Role() string

Role returns the component role of the instance

func (*NginxSpec) SSH

func (s *NginxSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (*NginxSpec) Status

func (s *NginxSpec) Status(tlsCfg *tls.Config, _ ...string) string

Status queries current status of the instance

type PDComponent

type PDComponent struct{ Topology *Specification }

PDComponent represents PD component.

func (*PDComponent) Instances

func (c *PDComponent) Instances() []Instance

Instances implements Component interface.

func (*PDComponent) Name

func (c *PDComponent) Name() string

Name implements Component interface.

func (*PDComponent) Role

func (c *PDComponent) Role() string

Role implements Component interface.

type PDInstance

type PDInstance struct {
	Name string
	BaseInstance
	// contains filtered or unexported fields
}

PDInstance represent the PD instance

func (*PDInstance) InitConfig

func (i *PDInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*PDInstance) IsLeader

func (i *PDInstance) IsLeader(topo Topology, apiTimeoutSeconds int, tlsCfg *tls.Config) (bool, error)

IsLeader checks if the instance is PD leader

func (*PDInstance) PostRestart

func (i *PDInstance) PostRestart(topo Topology, tlsCfg *tls.Config) error

PostRestart implements RollingUpdateInstance interface.

func (*PDInstance) PreRestart

func (i *PDInstance) PreRestart(topo Topology, apiTimeoutSeconds int, tlsCfg *tls.Config) error

PreRestart implements RollingUpdateInstance interface.

func (*PDInstance) ScaleConfig

func (i *PDInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type PDSpec

type PDSpec struct {
	Host                string `yaml:"host"`
	ListenHost          string `yaml:"listen_host,omitempty"`
	AdvertiseClientAddr string `yaml:"advertise_client_addr,omitempty"`
	AdvertisePeerAddr   string `yaml:"advertise_peer_addr,omitempty"`
	SSHPort             int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported            bool   `yaml:"imported,omitempty"`
	Patched             bool   `yaml:"patched,omitempty"`
	IgnoreExporter      bool   `yaml:"ignore_exporter,omitempty"`
	// Use Name to get the name with a default value if it's empty.
	Name            string                 `yaml:"name"`
	ClientPort      int                    `yaml:"client_port" default:"2379"`
	PeerPort        int                    `yaml:"peer_port" default:"2380"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

PDSpec represents the PD topology specification in topology.yaml

func (*PDSpec) GetMainPort

func (s *PDSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*PDSpec) IgnoreMonitorAgent

func (s *PDSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*PDSpec) IsImported

func (s *PDSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*PDSpec) Role

func (s *PDSpec) Role() string

Role returns the component role of the instance

func (*PDSpec) SSH

func (s *PDSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (*PDSpec) Status

func (s *PDSpec) Status(tlsCfg *tls.Config, _ ...string) string

Status queries current status of the instance

type PrometheusSpec

type PrometheusSpec struct {
	Host                  string                 `yaml:"host"`
	SSHPort               int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported              bool                   `yaml:"imported,omitempty"`
	Patched               bool                   `yaml:"patched,omitempty"`
	IgnoreExporter        bool                   `yaml:"ignore_exporter,omitempty"`
	Port                  int                    `yaml:"port" default:"9090"`
	DeployDir             string                 `yaml:"deploy_dir,omitempty"`
	DataDir               string                 `yaml:"data_dir,omitempty"`
	LogDir                string                 `yaml:"log_dir,omitempty"`
	NumaNode              string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	RemoteConfig          Remote                 `yaml:"remote_config,omitempty" validate:"remote_config:ignore"`
	ExternalAlertmanagers []ExternalAlertmanager `yaml:"external_alertmanagers" validate:"external_alertmanagers:ignore"`
	Retention             string                 `yaml:"storage_retention,omitempty" validate:"storage_retention:editable"`
	ResourceControl       meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch                  string                 `yaml:"arch,omitempty"`
	OS                    string                 `yaml:"os,omitempty"`
	RuleDir               string                 `yaml:"rule_dir,omitempty" validate:"rule_dir:editable"`
}

PrometheusSpec represents the Prometheus Server topology specification in topology.yaml

func (*PrometheusSpec) GetMainPort

func (s *PrometheusSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*PrometheusSpec) IgnoreMonitorAgent

func (s *PrometheusSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*PrometheusSpec) IsImported

func (s *PrometheusSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*PrometheusSpec) Role

func (s *PrometheusSpec) Role() string

Role returns the component role of the instance

func (*PrometheusSpec) SSH

func (s *PrometheusSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type PumpComponent

type PumpComponent struct{ Topology *Specification }

PumpComponent represents Pump component.

func (*PumpComponent) Instances

func (c *PumpComponent) Instances() []Instance

Instances implements Component interface.

func (*PumpComponent) Name

func (c *PumpComponent) Name() string

Name implements Component interface.

func (*PumpComponent) Role

func (c *PumpComponent) Role() string

Role implements Component interface.

type PumpInstance

type PumpInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

PumpInstance represent the Pump instance.

func (*PumpInstance) InitConfig

func (i *PumpInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implements Instance interface.

func (*PumpInstance) ScaleConfig

func (i *PumpInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type PumpSpec

type PumpSpec struct {
	Host            string                 `yaml:"host"`
	SSHPort         int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported        bool                   `yaml:"imported,omitempty"`
	Patched         bool                   `yaml:"patched,omitempty"`
	IgnoreExporter  bool                   `yaml:"ignore_exporter,omitempty"`
	Port            int                    `yaml:"port" default:"8250"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	DataDir         string                 `yaml:"data_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	Offline         bool                   `yaml:"offline,omitempty"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

PumpSpec represents the Pump topology specification in topology.yaml

func (*PumpSpec) GetMainPort

func (s *PumpSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*PumpSpec) IgnoreMonitorAgent

func (s *PumpSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*PumpSpec) IsImported

func (s *PumpSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*PumpSpec) Role

func (s *PumpSpec) Role() string

Role returns the component role of the instance

func (*PumpSpec) SSH

func (s *PumpSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type Remote

type Remote struct {
	RemoteWrite []map[string]interface{} `yaml:"remote_write,omitempty" validate:"remote_write:ignore"`
	RemoteRead  []map[string]interface{} `yaml:"remote_read,omitempty" validate:"remote_read:ignore"`
}

Remote prometheus remote config

type RollingUpdateInstance

type RollingUpdateInstance interface {
	PreRestart(topo Topology, apiTimeoutSeconds int, tlsCfg *tls.Config) error
	PostRestart(topo Topology, tlsCfg *tls.Config) error
}

RollingUpdateInstance represent a instance need to transfer state when restart. e.g transfer leader.

type ScaleOutTopology

type ScaleOutTopology interface {
	// Inherit existing global configuration. We must assign the inherited values before unmarshalling
	// because some default value rely on the global options and monitored options.
	// TODO: we should separate the  unmarshal and setting default value.
	NewPart() Topology
	MergeTopo(topo Topology) Topology
}

ScaleOutTopology represents a scale out metadata.

type ServerConfigs

type ServerConfigs struct {
	TiDB           map[string]interface{} `yaml:"tidb"`
	TiKV           map[string]interface{} `yaml:"tikv"`
	PD             map[string]interface{} `yaml:"pd"`
	TiFlash        map[string]interface{} `yaml:"tiflash"`
	TiFlashLearner map[string]interface{} `yaml:"tiflash-learner"`
	Pump           map[string]interface{} `yaml:"pump"`
	Drainer        map[string]interface{} `yaml:"drainer"`
	CDC            map[string]interface{} `yaml:"cdc"`
	Nginx          map[string]interface{} `yaml:"nginx"`
}

ServerConfigs represents the server runtime configuration

type SpecManager

type SpecManager struct {
	// contains filtered or unexported fields
}

SpecManager control management of spec meta data.

func GetSpecManager

func GetSpecManager() *SpecManager

GetSpecManager return the spec manager of tidb cluster.

func NewSpec

func NewSpec(base string, newMeta func() Metadata) *SpecManager

NewSpec create a spec instance.

func (*SpecManager) Exist

func (s *SpecManager) Exist(name string) (exist bool, err error)

Exist check if the cluster exist by checking the meta file.

func (*SpecManager) GetAllClusters

func (s *SpecManager) GetAllClusters() (map[string]Metadata, error)

GetAllClusters get a metadata list of all clusters deployed by current user

func (*SpecManager) List

func (s *SpecManager) List() (names []string, err error)

List return the cluster names.

func (*SpecManager) Metadata

func (s *SpecManager) Metadata(clusterName string, meta interface{}) error

Metadata tries to read the metadata of a cluster from file

func (*SpecManager) NewMetadata

func (s *SpecManager) NewMetadata() Metadata

NewMetadata alloc a Metadata according the type.

func (*SpecManager) Path

func (s *SpecManager) Path(cluster string, subpath ...string) string

Path returns the full path to a subpath (file or directory) of a cluster, it is a subdir in the profile dir of the user, with the cluster name as its name.

func (*SpecManager) Remove

func (s *SpecManager) Remove(name string) error

Remove remove the data with specified cluster name.

func (*SpecManager) SaveMeta

func (s *SpecManager) SaveMeta(clusterName string, meta Metadata) error

SaveMeta save the meta with specified cluster name.

type Specification

type Specification struct {
	GlobalOptions                  GlobalOptions                  `yaml:"global,omitempty" validate:"global:editable"`
	MonitoredOptions               MonitoredOptions               `yaml:"monitored,omitempty" validate:"monitored:editable"`
	ServerConfigs                  ServerConfigs                  `yaml:"server_configs,omitempty" validate:"server_configs:ignore"`
	AwsWSConfigs                   AwsWSConfigs                   `yaml:"workstation,omitempty"`
	AwsTopoConfigs                 AwsTopoConfigs                 `yaml:"aws_topo_configs"`
	AwsKafkaTopoConfigs            AwsKafkaTopoConfigs            `yaml:"aws_kafka_topo_configs"`
	AwsMongoTopoConfigs            AwsMongoTopoConfigs            `yaml:"aws_mongo_topo"`
	AwsESTopoConfigs               AwsESTopoConfigs               `yaml:"aws_es_topo"`
	AwsAuroraConfigs               AwsAuroraConfigs               `yaml:"aurora,omitempty"`
	AwsMySQLConfigs                AwsMySQLTopoConfigs            `yaml:"mysql,omitempty"`
	AwsPostgresConfigs             AwsPostgresConfigs             `yaml:"postgres,omitempty"`
	AwsOracleConfigs               AwsOracleConfigs               `yaml:"oracle,omitempty"`
	AwsRedshiftTopoConfigs         AwsRedshiftTopoConfigs         `yaml:"redshift,omitempty"`
	AwsMSKConnectPluginTopoConfigs AwsMSKConnectPluginTopoConfigs `yaml:"msk_connect_plugin,omitempty"`
	AwsMSKTopoConfigs              AwsMSKTopoConfigs              `yaml:"msk,omitempty"`
	AwsMSConfigs                   AwsMSConfigs                   `yaml:"sqlserver,omitempty"`
	AwsDMSConfigs                  AwsDMSConfigs                  `yaml:"dms,omitempty"`
	AwsCloudFormationConfigs       AwsCloudFormationConfigs       `yaml:"aws_cloud_formation_configs"`
	TiDBCloudConfigs               TiDBCloudConfigs               `yaml:"tidb_cloud,omitempty"`
	TiDBCloud                      TiDBCloud                      `yaml:"aws_tidbcloud,omitempty"`
	DrainerReplicate               DrainerReplicate               `yaml:"drainer_replicate,omitempty"`
	TiDBServers                    []*TiDBSpec                    `yaml:"tidb_servers"`
	TiKVServers                    []*TiKVSpec                    `yaml:"tikv_servers"`
	TiFlashServers                 []*TiFlashSpec                 `yaml:"tiflash_servers"`
	PDServers                      []*PDSpec                      `yaml:"pd_servers"`
	PumpServers                    []*PumpSpec                    `yaml:"pump_servers,omitempty"`
	Drainers                       []*DrainerSpec                 `yaml:"drainer_servers,omitempty"`
	CDCServers                     []*CDCSpec                     `yaml:"cdc_servers,omitempty"`
	TiSparkMasters                 []*TiSparkMasterSpec           `yaml:"tispark_masters,omitempty"`
	TiSparkWorkers                 []*TiSparkWorkerSpec           `yaml:"tispark_workers,omitempty"`
	Monitors                       []*PrometheusSpec              `yaml:"monitoring_servers"`
	Grafanas                       []*GrafanaSpec                 `yaml:"grafana_servers,omitempty"`
	Alertmanagers                  []*AlertmanagerSpec            `yaml:"alertmanager_servers,omitempty"`
	NginxServers                   []*NginxSpec                   `yaml:"nginx_servers"`
}

Specification represents the specification of topology.yaml

func (*Specification) AdjustByVersion

func (s *Specification) AdjustByVersion(clusterVersion string)

AdjustByVersion modify the spec by cluster version.

func (*Specification) BaseTopo

func (s *Specification) BaseTopo() *BaseTopo

BaseTopo implements Topology interface.

func (*Specification) ComponentsByStartOrder

func (s *Specification) ComponentsByStartOrder() (comps []Component)

ComponentsByStartOrder return component in the order need to start.

func (*Specification) ComponentsByStopOrder

func (s *Specification) ComponentsByStopOrder() (comps []Component)

ComponentsByStopOrder return component in the order need to stop.

func (*Specification) ComponentsByUpdateOrder

func (s *Specification) ComponentsByUpdateOrder() (comps []Component)

ComponentsByUpdateOrder return component in the order need to be updated.

func (*Specification) CountDir

func (s *Specification) CountDir(targetHost, dirPrefix string) int

CountDir counts for dir paths used by any instance in the cluster with the same prefix, useful to find potential path conflicts

func (*Specification) Endpoints

func (s *Specification) Endpoints(user string) []*scripts.PDScript

Endpoints returns the PD endpoints configurations

func (*Specification) FillHostArch

func (s *Specification) FillHostArch(hostArch map[string]string) error

FillHostArch fills the topology with the given host->arch

func (*Specification) GetDashboardAddress

func (s *Specification) GetDashboardAddress(tlsCfg *tls.Config, pdList ...string) (string, error)

GetDashboardAddress returns the cluster's dashboard addr

func (*Specification) GetEtcdClient

func (s *Specification) GetEtcdClient(tlsCfg *tls.Config) (*clientv3.Client, error)

GetEtcdClient loads EtcdClient of current cluster

func (*Specification) GetEtcdProxyClient

func (s *Specification) GetEtcdProxyClient(tlsCfg *tls.Config, tcpProxy *proxy.TCPProxy) (*clientv3.Client, chan struct{}, error)

GetEtcdProxyClient loads EtcdClient of current cluster with TCP proxy

func (*Specification) GetMonitoredOptions

func (s *Specification) GetMonitoredOptions() *MonitoredOptions

GetMonitoredOptions implements Topology interface.

func (*Specification) GetPDList

func (s *Specification) GetPDList() []string

GetPDList returns a list of PD API hosts of the current cluster

func (*Specification) GetTiKVLabels

func (s *Specification) GetTiKVLabels() (map[string]map[string]string, error)

GetTiKVLabels implements TiKVLabelProvider

func (*Specification) IterComponent

func (s *Specification) IterComponent(fn func(comp Component))

IterComponent iterates all components in component starting order

func (*Specification) IterInstance

func (s *Specification) IterInstance(fn func(instance Instance))

IterInstance iterates all instances in component starting order

func (*Specification) LocationLabels

func (s *Specification) LocationLabels() ([]string, error)

LocationLabels returns replication.location-labels in PD config

func (*Specification) Merge

func (s *Specification) Merge(that Topology) Topology

Merge returns a new Specification which sum old ones

func (*Specification) MergeTopo

func (s *Specification) MergeTopo(topo Topology) Topology

MergeTopo implements ScaleOutTopology interface.

func (*Specification) NewPart

func (s *Specification) NewPart() Topology

NewPart implements ScaleOutTopology interface.

func (*Specification) TLSConfig

func (s *Specification) TLSConfig(dir string) (*tls.Config, error)

TLSConfig generates a tls.Config for the specification as needed

func (*Specification) Type

func (s *Specification) Type() string

Type implements Topology interface.

func (*Specification) UnmarshalYAML

func (s *Specification) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface, it sets the default values when unmarshaling the topology file

func (*Specification) Validate

func (s *Specification) Validate() error

Validate validates the topology specification and produce error if the specification invalid (e.g: port conflicts or directory conflicts)

type TiDBCloud

type TiDBCloud struct {
	General TiDBCloudGeneral `yaml:general`
	TiDB    TiDBCloudNode    `yaml:tidb`
	TiKV    TiDBCloudNode    `yaml:tikv`
	TiFlash TiDBCloudNode    `yaml:tiflash`
}

type TiDBCloudComponent

type TiDBCloudComponent struct {
	TiDB    TiDBCloudComponentSpec `yaml:"tidb"`
	TiKV    TiDBCloudComponentSpec `yaml:"tikv"`
	TiFlash TiDBCloudComponentSpec `yaml:"tiflash"`
}

type TiDBCloudComponentSpec

type TiDBCloudComponentSpec struct {
	NodeQuantity   int32  `yaml:"node_quantity" default: 0`
	NodeSize       string `yaml:"node_size" default: "2C8G"`
	StorageSizeGib int32  `yaml:"storage_size_gib" default :0 `
}

type TiDBCloudConfigs

type TiDBCloudConfigs struct {
	Host               string                `yaml:"host"`
	Port               int32                 `yaml:"port" default: 4000`
	User               string                `yaml:"user"`
	Password           string                `yaml:"password"`
	Databases          []string              `yaml:"databases"`
	TiDBCloudProjectID string                `yaml:"tidbcloud_project_id"`
	CloudProvider      string                `yaml:"cloud_provider"`
	ClusterType        string                `yaml:"cluster_type"`
	Region             string                `yaml:"region"`
	Components         TiDBCloudComponent    `yaml:"components"`
	IPAccessList       TiDBCloudIPAccessList `yaml:"ip_access_list"`
}

type TiDBCloudGeneral

type TiDBCloudGeneral struct {
	ProjectID int64  `yaml:"project_id"`
	Region    string `yaml:"region"`
	Port      int32  `yaml:"port"`
	Password  string `yaml:"password"`
}

type TiDBCloudIPAccessList

type TiDBCloudIPAccessList struct {
	CIDR        string `yaml:"cidr"`
	Description string `yaml:"description"`
}

type TiDBCloudNode

type TiDBCloudNode struct {
	NodeSize string `yaml:"node_size"`
	Count    int    `yaml:"count"`
	Storage  int    `yaml:"Storage,omitempty"` // Only useful for TiKV
}

type TiDBComponent

type TiDBComponent struct{ Topology *Specification }

TiDBComponent represents TiDB component.

func (*TiDBComponent) Instances

func (c *TiDBComponent) Instances() []Instance

Instances implements Component interface.

func (*TiDBComponent) Name

func (c *TiDBComponent) Name() string

Name implements Component interface.

func (*TiDBComponent) Role

func (c *TiDBComponent) Role() string

Role implements Component interface.

type TiDBInstance

type TiDBInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

TiDBInstance represent the TiDB instance

func (*TiDBInstance) InitConfig

func (i *TiDBInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*TiDBInstance) ScaleConfig

func (i *TiDBInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type TiDBSpec

type TiDBSpec struct {
	Host            string                 `yaml:"host"`
	ListenHost      string                 `yaml:"listen_host,omitempty"`
	AdvertiseAddr   string                 `yaml:"advertise_address,omitempty"`
	SSHPort         int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported        bool                   `yaml:"imported,omitempty"`
	Patched         bool                   `yaml:"patched,omitempty"`
	IgnoreExporter  bool                   `yaml:"ignore_exporter,omitempty"`
	Port            int                    `yaml:"port" default:"4000"`
	StatusPort      int                    `yaml:"status_port" default:"10080"`
	DeployDir       string                 `yaml:"deploy_dir,omitempty"`
	LogDir          string                 `yaml:"log_dir,omitempty"`
	NumaNode        string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config          map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

TiDBSpec represents the TiDB topology specification in topology.yaml

func (*TiDBSpec) GetMainPort

func (s *TiDBSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*TiDBSpec) IgnoreMonitorAgent

func (s *TiDBSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*TiDBSpec) IsImported

func (s *TiDBSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*TiDBSpec) Role

func (s *TiDBSpec) Role() string

Role returns the component role of the instance

func (*TiDBSpec) SSH

func (s *TiDBSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type TiFlashComponent

type TiFlashComponent struct{ Topology *Specification }

TiFlashComponent represents TiFlash component.

func (*TiFlashComponent) Instances

func (c *TiFlashComponent) Instances() []Instance

Instances implements Component interface.

func (*TiFlashComponent) Name

func (c *TiFlashComponent) Name() string

Name implements Component interface.

func (*TiFlashComponent) Role

func (c *TiFlashComponent) Role() string

Role implements Component interface.

type TiFlashInstance

type TiFlashInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

TiFlashInstance represent the TiFlash instance

func (*TiFlashInstance) CheckIncorrectConfigs

func (i *TiFlashInstance) CheckIncorrectConfigs() error

CheckIncorrectConfigs checks incorrect settings

func (*TiFlashInstance) GetServicePort

func (i *TiFlashInstance) GetServicePort() int

GetServicePort returns the service port of TiFlash

func (*TiFlashInstance) InitConfig

func (i *TiFlashInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*TiFlashInstance) InitTiFlashLearnerConfig

func (i *TiFlashInstance) InitTiFlashLearnerConfig(cfg *scripts.TiFlashScript, clusterVersion string, src map[string]interface{}) (map[string]interface{}, error)

InitTiFlashLearnerConfig initializes TiFlash learner config file

func (*TiFlashInstance) PrepareStart

func (i *TiFlashInstance) PrepareStart(ctx context.Context, tlsCfg *tls.Config) error

PrepareStart checks TiFlash requirements before starting

func (*TiFlashInstance) ScaleConfig

func (i *TiFlashInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type TiFlashSpec

type TiFlashSpec struct {
	Host                 string                 `yaml:"host"`
	SSHPort              int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported             bool                   `yaml:"imported,omitempty"`
	Patched              bool                   `yaml:"patched,omitempty"`
	IgnoreExporter       bool                   `yaml:"ignore_exporter,omitempty"`
	TCPPort              int                    `yaml:"tcp_port" default:"9000"`
	HTTPPort             int                    `yaml:"http_port" default:"8123"`
	FlashServicePort     int                    `yaml:"flash_service_port" default:"3930"`
	FlashProxyPort       int                    `yaml:"flash_proxy_port" default:"20170"`
	FlashProxyStatusPort int                    `yaml:"flash_proxy_status_port" default:"20292"`
	StatusPort           int                    `yaml:"metrics_port" default:"8234"`
	DeployDir            string                 `yaml:"deploy_dir,omitempty"`
	DataDir              string                 `yaml:"data_dir,omitempty" validate:"data_dir:expandable"`
	LogDir               string                 `yaml:"log_dir,omitempty"`
	TmpDir               string                 `yaml:"tmp_path,omitempty"`
	Offline              bool                   `yaml:"offline,omitempty"`
	NumaNode             string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config               map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	LearnerConfig        map[string]interface{} `yaml:"learner_config,omitempty" validate:"learner_config:ignore"`
	ResourceControl      meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch                 string                 `yaml:"arch,omitempty"`
	OS                   string                 `yaml:"os,omitempty"`
}

TiFlashSpec represents the TiFlash topology specification in topology.yaml

func (*TiFlashSpec) GetMainPort

func (s *TiFlashSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*TiFlashSpec) GetOverrideDataDir

func (s *TiFlashSpec) GetOverrideDataDir() (string, error)

GetOverrideDataDir returns the data dir. If users have defined TiFlashStorageKeyMainDirs, then override "DataDir" with the directories defined in TiFlashStorageKeyMainDirs and TiFlashStorageKeyLatestDirs

func (*TiFlashSpec) IgnoreMonitorAgent

func (s *TiFlashSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*TiFlashSpec) IsImported

func (s *TiFlashSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*TiFlashSpec) Role

func (s *TiFlashSpec) Role() string

Role returns the component role of the instance

func (*TiFlashSpec) SSH

func (s *TiFlashSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (*TiFlashSpec) Status

func (s *TiFlashSpec) Status(tlsCfg *tls.Config, pdList ...string) string

Status queries current status of the instance

type TiKVComponent

type TiKVComponent struct{ Topology *Specification }

TiKVComponent represents TiKV component.

func (*TiKVComponent) Instances

func (c *TiKVComponent) Instances() []Instance

Instances implements Component interface.

func (*TiKVComponent) Name

func (c *TiKVComponent) Name() string

Name implements Component interface.

func (*TiKVComponent) Role

func (c *TiKVComponent) Role() string

Role implements Component interface.

type TiKVInstance

type TiKVInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

TiKVInstance represent the TiDB instance

func (*TiKVInstance) InitConfig

func (i *TiKVInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*TiKVInstance) PostRestart

func (i *TiKVInstance) PostRestart(topo Topology, tlsCfg *tls.Config) error

PostRestart implements RollingUpdateInstance interface.

func (*TiKVInstance) PreRestart

func (i *TiKVInstance) PreRestart(topo Topology, apiTimeoutSeconds int, tlsCfg *tls.Config) error

PreRestart implements RollingUpdateInstance interface.

func (*TiKVInstance) ScaleConfig

func (i *TiKVInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type TiKVLabelError

type TiKVLabelError struct {
	TiKVInstances map[string][]error
}

TiKVLabelError indicates that some TiKV servers don't have correct labels

func (*TiKVLabelError) Error

func (e *TiKVLabelError) Error() string

Error implements error

type TiKVLabelProvider

type TiKVLabelProvider interface {
	GetTiKVLabels() (map[string]map[string]string, error)
}

TiKVLabelProvider provides the store labels information

type TiKVSpec

type TiKVSpec struct {
	Host                string                 `yaml:"host"`
	ListenHost          string                 `yaml:"listen_host,omitempty"`
	AdvertiseAddr       string                 `yaml:"advertise_addr,omitempty"`
	SSHPort             int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported            bool                   `yaml:"imported,omitempty"`
	Patched             bool                   `yaml:"patched,omitempty"`
	IgnoreExporter      bool                   `yaml:"ignore_exporter,omitempty"`
	Port                int                    `yaml:"port" default:"20160"`
	StatusPort          int                    `yaml:"status_port" default:"20180"`
	AdvertiseStatusAddr string                 `yaml:"advertise_status_addr,omitempty"`
	DeployDir           string                 `yaml:"deploy_dir,omitempty"`
	DataDir             string                 `yaml:"data_dir,omitempty"`
	LogDir              string                 `yaml:"log_dir,omitempty"`
	Offline             bool                   `yaml:"offline,omitempty"`
	NumaNode            string                 `yaml:"numa_node,omitempty" validate:"numa_node:editable"`
	Config              map[string]interface{} `yaml:"config,omitempty" validate:"config:ignore"`
	ResourceControl     meta.ResourceControl   `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch                string                 `yaml:"arch,omitempty"`
	OS                  string                 `yaml:"os,omitempty"`
}

TiKVSpec represents the TiKV topology specification in topology.yaml

func (*TiKVSpec) GetMainPort

func (s *TiKVSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*TiKVSpec) IgnoreMonitorAgent

func (s *TiKVSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*TiKVSpec) IsImported

func (s *TiKVSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*TiKVSpec) Labels

func (s *TiKVSpec) Labels() (map[string]string, error)

Labels returns the labels of TiKV

func (*TiKVSpec) Role

func (s *TiKVSpec) Role() string

Role returns the component role of the instance

func (*TiKVSpec) SSH

func (s *TiKVSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (*TiKVSpec) Status

func (s *TiKVSpec) Status(tlsCfg *tls.Config, pdList ...string) string

Status queries current status of the instance

type TiSparkMasterComponent

type TiSparkMasterComponent struct{ Topology *Specification }

TiSparkMasterComponent represents TiSpark master component.

func (*TiSparkMasterComponent) Instances

func (c *TiSparkMasterComponent) Instances() []Instance

Instances implements Component interface.

func (*TiSparkMasterComponent) Name

func (c *TiSparkMasterComponent) Name() string

Name implements Component interface.

func (*TiSparkMasterComponent) Role

func (c *TiSparkMasterComponent) Role() string

Role implements Component interface.

type TiSparkMasterInstance

type TiSparkMasterInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

TiSparkMasterInstance represent the TiSpark master instance

func (*TiSparkMasterInstance) GetCustomEnvs

func (i *TiSparkMasterInstance) GetCustomEnvs() map[string]string

GetCustomEnvs get custom spark envionment variables of the instance

func (*TiSparkMasterInstance) GetCustomFields

func (i *TiSparkMasterInstance) GetCustomFields() map[string]interface{}

GetCustomFields get custom spark configs of the instance

func (*TiSparkMasterInstance) GetJavaHome

func (i *TiSparkMasterInstance) GetJavaHome() string

GetJavaHome returns the java_home value in spec

func (*TiSparkMasterInstance) InitConfig

func (i *TiSparkMasterInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) (err error)

InitConfig implement Instance interface

func (*TiSparkMasterInstance) ScaleConfig

func (i *TiSparkMasterInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type TiSparkMasterSpec

type TiSparkMasterSpec struct {
	Host           string                 `yaml:"host"`
	ListenHost     string                 `yaml:"listen_host,omitempty"`
	SSHPort        int                    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported       bool                   `yaml:"imported,omitempty"`
	Patched        bool                   `yaml:"patched,omitempty"`
	IgnoreExporter bool                   `yaml:"ignore_exporter,omitempty"`
	Port           int                    `yaml:"port" default:"7077"`
	WebPort        int                    `yaml:"web_port" default:"8080"`
	DeployDir      string                 `yaml:"deploy_dir,omitempty"`
	JavaHome       string                 `yaml:"java_home,omitempty" validate:"java_home:editable"`
	SparkConfigs   map[string]interface{} `yaml:"spark_config,omitempty" validate:"spark_config:ignore"`
	SparkEnvs      map[string]string      `yaml:"spark_env,omitempty" validate:"spark_env:ignore"`
	Arch           string                 `yaml:"arch,omitempty"`
	OS             string                 `yaml:"os,omitempty"`
}

TiSparkMasterSpec is the topology specification for TiSpark master node

func (*TiSparkMasterSpec) GetMainPort

func (s *TiSparkMasterSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*TiSparkMasterSpec) IgnoreMonitorAgent

func (s *TiSparkMasterSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*TiSparkMasterSpec) IsImported

func (s *TiSparkMasterSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*TiSparkMasterSpec) Role

func (s *TiSparkMasterSpec) Role() string

Role returns the component role of the instance

func (*TiSparkMasterSpec) SSH

func (s *TiSparkMasterSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type TiSparkWorkerComponent

type TiSparkWorkerComponent struct{ Topology *Specification }

TiSparkWorkerComponent represents TiSpark slave component.

func (*TiSparkWorkerComponent) Instances

func (c *TiSparkWorkerComponent) Instances() []Instance

Instances implements Component interface.

func (*TiSparkWorkerComponent) Name

func (c *TiSparkWorkerComponent) Name() string

Name implements Component interface.

func (*TiSparkWorkerComponent) Role

func (c *TiSparkWorkerComponent) Role() string

Role implements Component interface.

type TiSparkWorkerInstance

type TiSparkWorkerInstance struct {
	BaseInstance
	// contains filtered or unexported fields
}

TiSparkWorkerInstance represent the TiSpark slave instance

func (*TiSparkWorkerInstance) GetJavaHome

func (i *TiSparkWorkerInstance) GetJavaHome() string

GetJavaHome returns the java_home value in spec

func (*TiSparkWorkerInstance) InitConfig

func (i *TiSparkWorkerInstance) InitConfig(
	ctx context.Context,
	e ctxt.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) (err error)

InitConfig implement Instance interface

func (*TiSparkWorkerInstance) ScaleConfig

func (i *TiSparkWorkerInstance) ScaleConfig(
	ctx context.Context,
	e ctxt.Executor,
	topo Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type TiSparkWorkerSpec

type TiSparkWorkerSpec struct {
	Host           string `yaml:"host"`
	ListenHost     string `yaml:"listen_host,omitempty"`
	SSHPort        int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported       bool   `yaml:"imported,omitempty"`
	Patched        bool   `yaml:"patched,omitempty"`
	IgnoreExporter bool   `yaml:"ignore_exporter,omitempty"`
	Port           int    `yaml:"port" default:"7078"`
	WebPort        int    `yaml:"web_port" default:"8081"`
	DeployDir      string `yaml:"deploy_dir,omitempty"`
	JavaHome       string `yaml:"java_home,omitempty" validate:"java_home:editable"`
	Arch           string `yaml:"arch,omitempty"`
	OS             string `yaml:"os,omitempty"`
}

TiSparkWorkerSpec is the topology specification for TiSpark slave nodes

func (*TiSparkWorkerSpec) GetMainPort

func (s *TiSparkWorkerSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (*TiSparkWorkerSpec) IgnoreMonitorAgent

func (s *TiSparkWorkerSpec) IgnoreMonitorAgent() bool

IgnoreMonitorAgent returns if the node does not have monitor agents available

func (*TiSparkWorkerSpec) IsImported

func (s *TiSparkWorkerSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (*TiSparkWorkerSpec) Role

func (s *TiSparkWorkerSpec) Role() string

Role returns the component role of the instance

func (*TiSparkWorkerSpec) SSH

func (s *TiSparkWorkerSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

type Topology

type Topology interface {
	Type() string
	BaseTopo() *BaseTopo
	// Validate validates the topology specification and produce error if the
	// specification invalid (e.g: port conflicts or directory conflicts)
	Validate() error

	// Instances() []Instance
	ComponentsByStartOrder() []Component
	ComponentsByStopOrder() []Component
	ComponentsByUpdateOrder() []Component
	IterInstance(fn func(instance Instance))
	GetMonitoredOptions() *MonitoredOptions
	// count how many time a path is used by instances in cluster
	CountDir(host string, dir string) int
	TLSConfig(dir string) (*tls.Config, error)
	Merge(that Topology) Topology
	FillHostArch(hostArchmap map[string]string) error

	ScaleOutTopology
}

Topology represents specification of the cluster.

type UpgradableMetadata

type UpgradableMetadata interface {
	SetVersion(s string)
	SetUser(u string)
}

UpgradableMetadata represents a upgradable Metadata.

Jump to

Keyboard shortcuts

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