spec

package
v1.2.0-tmp Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ComponentDMMaster     = "dm-master"
	ComponentDMWorker     = "dm-worker"
	ComponentPrometheus   = spec.ComponentPrometheus
	ComponentGrafana      = spec.ComponentGrafana
	ComponentAlertManager = spec.ComponentAlertManager
)

Components names supported by TiOps

Variables

This section is empty.

Functions

func AllDMComponentNames

func AllDMComponentNames() (roles []string)

AllDMComponentNames contains the names of all dm components. should include all components in ComponentsByStartOrder

func DMComponentVersion added in v1.1.0

func DMComponentVersion(comp, version string) string

DMComponentVersion maps the dm version to the third components binding version

func GetSpecManager

func GetSpecManager() *cspec.SpecManager

GetSpecManager return the spec manager of dm cluster.

Types

type AlertManagerComponent added in v1.1.0

type AlertManagerComponent struct{ *Topology }

AlertManagerComponent represents Alertmanager component.

func (*AlertManagerComponent) Instances added in v1.1.0

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

Instances implements Component interface.

func (*AlertManagerComponent) Name added in v1.1.0

func (c *AlertManagerComponent) Name() string

Name implements Component interface.

func (*AlertManagerComponent) Role added in v1.1.0

func (c *AlertManagerComponent) Role() string

Role implements Component interface.

type AlertManagerInstance added in v1.1.0

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

AlertManagerInstance represent the alert manager instance

func (*AlertManagerInstance) Deploy added in v1.1.0

func (i *AlertManagerInstance) Deploy(t *task.Builder, srcPath string, deployDir string, version string, clusterName string, clusterVersion string)

Deploy implements DeployerInstance interface.

func (*AlertManagerInstance) InitConfig added in v1.1.0

func (i *AlertManagerInstance) InitConfig(
	e executor.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*AlertManagerInstance) ScaleConfig added in v1.1.0

func (i *AlertManagerInstance) ScaleConfig(
	e executor.Executor,
	topo spec.Topology,
	clusterName string,
	clusterVersion string,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type AlertManagerSpec

type AlertManagerSpec = spec.AlertManagerSpec

AlertManagerSpec is the spec of Alertmanager

type Component

type Component = spec.Component

Component represents a component of the cluster.

type DMMasterComponent

type DMMasterComponent struct{ *Topology }

DMMasterComponent represents TiDB component.

func (*DMMasterComponent) Instances

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

Instances implements Component interface.

func (*DMMasterComponent) Name

func (c *DMMasterComponent) Name() string

Name implements Component interface.

func (*DMMasterComponent) Role added in v1.1.0

func (c *DMMasterComponent) Role() string

Role implements Component interface.

type DMServerConfigs

type DMServerConfigs struct {
	Master map[string]interface{} `yaml:"master"`
	Worker map[string]interface{} `yaml:"worker"`
}

DMServerConfigs represents the server runtime configuration

type DMWorkerComponent

type DMWorkerComponent struct {
	*Topology
}

DMWorkerComponent represents DM worker component.

func (*DMWorkerComponent) Instances

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

Instances implements Component interface.

func (*DMWorkerComponent) Name

func (c *DMWorkerComponent) Name() string

Name implements Component interface.

func (*DMWorkerComponent) Role added in v1.1.0

func (c *DMWorkerComponent) Role() string

Role implements Component interface.

type GlobalOptions

type GlobalOptions = spec.GlobalOptions

GlobalOptions of spec.

type GrafanaComponent added in v1.1.0

type GrafanaComponent struct{ *Topology }

GrafanaComponent represents Grafana component.

func (*GrafanaComponent) Instances added in v1.1.0

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

Instances implements Component interface.

func (*GrafanaComponent) Name added in v1.1.0

func (c *GrafanaComponent) Name() string

Name implements Component interface.

func (*GrafanaComponent) Role added in v1.1.0

func (c *GrafanaComponent) Role() string

Role implements Component interface.

type GrafanaInstance added in v1.1.0

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

GrafanaInstance represent the grafana instance

func (*GrafanaInstance) Deploy added in v1.1.0

func (i *GrafanaInstance) Deploy(t *task.Builder, srcPath string, deployDir string, version string, clusterName string, clusterVersion string)

Deploy implements DeployerInstance interface.

func (*GrafanaInstance) InitConfig added in v1.1.0

func (i *GrafanaInstance) InitConfig(
	e executor.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*GrafanaInstance) ScaleConfig added in v1.1.0

func (i *GrafanaInstance) ScaleConfig(
	e executor.Executor,
	topo spec.Topology,
	clusterName string,
	clusterVersion string,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type GrafanaSpec

type GrafanaSpec = spec.GrafanaSpec

GrafanaSpec is the spec of Grafana

type Instance

type Instance = spec.Instance

Instance represents an instance

type InstanceSpec

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

InstanceSpec represent a instance specification

type MasterInstance added in v1.1.0

type MasterInstance struct {
	Name string
	spec.BaseInstance
	// contains filtered or unexported fields
}

MasterInstance represent the TiDB instance

func (*MasterInstance) InitConfig added in v1.1.0

func (i *MasterInstance) InitConfig(
	e executor.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*MasterInstance) ScaleConfig added in v1.1.0

func (i *MasterInstance) ScaleConfig(
	e executor.Executor,
	topo spec.Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type MasterSpec

type MasterSpec struct {
	Host     string `yaml:"host"`
	SSHPort  int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported bool   `yaml:"imported,omitempty"`
	// Use Name to get the name with a default value if it's empty.
	Name            string                 `yaml:"name,omitempty"`
	Port            int                    `yaml:"port,omitempty" default:"8261"`
	PeerPort        int                    `yaml:"peer_port,omitempty" default:"8291"`
	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 ResourceControl        `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
	V1SourcePath    string                 `yaml:"v1_source_path,omitempty"`
}

MasterSpec represents the Master topology specification in topology.yaml

func (MasterSpec) GetMainPort

func (s MasterSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (MasterSpec) IsImported

func (s MasterSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (MasterSpec) Role

func (s MasterSpec) Role() string

Role returns the component role of the instance

func (MasterSpec) SSH

func (s MasterSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (MasterSpec) Status

func (s MasterSpec) Status(tlsCfg *tls.Config, masterList ...string) string

Status queries current status of the instance

type Metadata

type Metadata struct {
	User    string `yaml:"user"`       // the user to run and manage cluster on remote
	Version string `yaml:"dm_version"` // the version of TiDB cluster

	Topology *Topology `yaml:"topology"`
}

Metadata is the specification of generic cluster metadata

func (*Metadata) GetBaseMeta

func (m *Metadata) GetBaseMeta() *cspec.BaseMeta

GetBaseMeta implements Metadata interface.

func (*Metadata) GetTopology

func (m *Metadata) GetTopology() cspec.Topology

GetTopology implements Metadata interface.

func (*Metadata) SetTopology

func (m *Metadata) SetTopology(topo cspec.Topology)

SetTopology implements Metadata interface.

func (*Metadata) SetUser

func (m *Metadata) SetUser(s string)

SetUser implement UpgradableMetadata interface.

func (*Metadata) SetVersion

func (m *Metadata) SetVersion(s string)

SetVersion implement UpgradableMetadata interface.

type MonitorComponent added in v1.1.0

type MonitorComponent struct{ *Topology }

MonitorComponent represents Monitor component.

func (*MonitorComponent) Instances added in v1.1.0

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

Instances implements Component interface.

func (*MonitorComponent) Name added in v1.1.0

func (c *MonitorComponent) Name() string

Name implements Component interface.

func (*MonitorComponent) Role added in v1.1.0

func (c *MonitorComponent) Role() string

Role implements Component interface.

type MonitorInstance added in v1.1.0

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

MonitorInstance represent the monitor instance

func (*MonitorInstance) Deploy added in v1.1.0

func (i *MonitorInstance) Deploy(t *task.Builder, srcPath string, deployDir string, version string, _ string, clusterVersion string)

Deploy implements DeployerInstance interface.

func (*MonitorInstance) InitConfig added in v1.1.0

func (i *MonitorInstance) InitConfig(
	e executor.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*MonitorInstance) ScaleConfig added in v1.1.0

func (i *MonitorInstance) ScaleConfig(
	e executor.Executor,
	topo spec.Topology,
	clusterName string,
	clusterVersion string,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type PrometheusSpec

type PrometheusSpec = spec.PrometheusSpec

PrometheusSpec is the spec of Prometheus

type ResourceControl

type ResourceControl = meta.ResourceControl

ResourceControl is the spec of ResourceControl

type Topology

type Topology struct {
	GlobalOptions GlobalOptions `yaml:"global,omitempty" validate:"global:editable"`
	// MonitoredOptions MonitoredOptions   `yaml:"monitored,omitempty" validate:"monitored:editable"`
	ServerConfigs DMServerConfigs    `yaml:"server_configs,omitempty" validate:"server_configs:ignore"`
	Masters       []MasterSpec       `yaml:"master_servers"`
	Workers       []WorkerSpec       `yaml:"worker_servers"`
	Monitors      []PrometheusSpec   `yaml:"monitoring_servers"`
	Grafana       []GrafanaSpec      `yaml:"grafana_servers,omitempty"`
	Alertmanager  []AlertManagerSpec `yaml:"alertmanager_servers,omitempty"`
}

Topology represents the specification of topology.yaml

func (*Topology) BaseTopo

func (topo *Topology) BaseTopo() *spec.BaseTopo

BaseTopo implements Topology interface.

func (*Topology) ComponentsByStartOrder

func (topo *Topology) ComponentsByStartOrder() (comps []Component)

ComponentsByStartOrder return component in the order need to start.

func (*Topology) ComponentsByStopOrder

func (topo *Topology) ComponentsByStopOrder() (comps []Component)

ComponentsByStopOrder return component in the order need to stop.

func (*Topology) ComponentsByUpdateOrder

func (topo *Topology) ComponentsByUpdateOrder() (comps []Component)

ComponentsByUpdateOrder return component in the order need to be updated.

func (*Topology) CountDir

func (topo *Topology) 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 (*Topology) Endpoints

func (topo *Topology) Endpoints(user string) []*scripts.DMMasterScript

Endpoints returns the PD endpoints configurations

func (*Topology) GetGlobalOptions

func (topo *Topology) GetGlobalOptions() spec.GlobalOptions

GetGlobalOptions returns cluster topology

func (*Topology) GetMasterList

func (topo *Topology) GetMasterList() []string

GetMasterList returns a list of Master API hosts of the current cluster

func (*Topology) GetMonitoredOptions

func (topo *Topology) GetMonitoredOptions() *spec.MonitoredOptions

GetMonitoredOptions returns MonitoredOptions

func (*Topology) IterComponent

func (topo *Topology) IterComponent(fn func(comp Component))

IterComponent iterates all components in component starting order

func (*Topology) IterHost

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

IterHost iterates one instance for each host

func (*Topology) IterInstance

func (topo *Topology) IterInstance(fn func(instance Instance))

IterInstance iterates all instances in component starting order

func (*Topology) Merge

func (topo *Topology) Merge(that *Topology) *Topology

Merge returns a new Topology which sum old ones

func (*Topology) MergeTopo

func (topo *Topology) MergeTopo(rhs spec.Topology) spec.Topology

MergeTopo implements ScaleOutTopology interface.

func (*Topology) NewPart

func (topo *Topology) NewPart() spec.Topology

NewPart implements ScaleOutTopology interface.

func (*Topology) TLSConfig added in v1.2.0

func (topo *Topology) TLSConfig(dir string) (*tls.Config, error)

TLSConfig generates a tls.Config for the specification as needed

func (*Topology) UnmarshalYAML

func (topo *Topology) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML sets default values when unmarshaling the topology file

func (*Topology) Validate

func (topo *Topology) Validate() error

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

type WorkerInstance added in v1.1.0

type WorkerInstance struct {
	Name string
	spec.BaseInstance
	// contains filtered or unexported fields
}

WorkerInstance represent the DM worker instance

func (*WorkerInstance) InitConfig added in v1.1.0

func (i *WorkerInstance) InitConfig(
	e executor.Executor,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

InitConfig implement Instance interface

func (*WorkerInstance) ScaleConfig added in v1.1.0

func (i *WorkerInstance) ScaleConfig(
	e executor.Executor,
	topo spec.Topology,
	clusterName,
	clusterVersion,
	deployUser string,
	paths meta.DirPaths,
) error

ScaleConfig deploy temporary config on scaling

type WorkerSpec

type WorkerSpec struct {
	Host     string `yaml:"host"`
	SSHPort  int    `yaml:"ssh_port,omitempty" validate:"ssh_port:editable"`
	Imported bool   `yaml:"imported,omitempty"`
	// Use Name to get the name with a default value if it's empty.
	Name            string                 `yaml:"name,omitempty"`
	Port            int                    `yaml:"port,omitempty" default:"8262"`
	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 ResourceControl        `yaml:"resource_control,omitempty" validate:"resource_control:editable"`
	Arch            string                 `yaml:"arch,omitempty"`
	OS              string                 `yaml:"os,omitempty"`
}

WorkerSpec represents the Master topology specification in topology.yaml

func (WorkerSpec) GetMainPort

func (s WorkerSpec) GetMainPort() int

GetMainPort returns the main port of the instance

func (WorkerSpec) IsImported

func (s WorkerSpec) IsImported() bool

IsImported returns if the node is imported from TiDB-Ansible

func (WorkerSpec) Role

func (s WorkerSpec) Role() string

Role returns the component role of the instance

func (WorkerSpec) SSH

func (s WorkerSpec) SSH() (string, int)

SSH returns the host and SSH port of the instance

func (WorkerSpec) Status

func (s WorkerSpec) Status(tlsCfg *tls.Config, masterList ...string) string

Status queries current status of the instance

Jump to

Keyboard shortcuts

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