Documentation
¶
Index ¶
- Constants
- Variables
- func Addr(ins spec.Instance) string
- func AsyncNodes(spec *spec.Specification, nodes []string, async bool) []string
- func CleanupComponent(ctx context.Context, delFileMaps map[string]set.StringSet, sudo bool) error
- func DeleteGlobalDirs(ctx context.Context, host string, options *spec.GlobalOptions) error
- func DeletePublicKey(ctx context.Context, host string) error
- func Destroy(ctx context.Context, cluster spec.Topology, options Options) error
- func DestroyClusterTombstone(ctx context.Context, cluster *spec.Specification, returNodesOnly bool, ...) (nodes []string, err error)
- func DestroyComponent(ctx context.Context, instances []spec.Instance, cls spec.Topology, ...) error
- func DestroyMonitored(ctx context.Context, inst spec.Instance, options *spec.MonitoredOptions, ...) error
- func DestroyTombstone(ctx context.Context, cluster *spec.Specification, returNodesOnly bool, ...) (nodes []string, err error)
- func Download(component, nodeOS, arch string, version string) error
- func Enable(ctx context.Context, cluster spec.Topology, options Options, isEnable bool) error
- func EnableComponent(ctx context.Context, instances []spec.Instance, noAgentHosts set.StringSet, ...) error
- func EnableMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, ...) error
- func FilterComponent(comps []spec.Component, components set.StringSet) (res []spec.Component)
- func FilterInstance(instances []spec.Instance, nodes set.StringSet) (res []spec.Instance)
- func GetNodeInfo(ctx context.Context, topo spec.Topology) (nodes []*telemetry.NodeInfo, err error)
- func GetServiceStatus(ctx context.Context, e ctxt.Executor, name string, scope string, ...) (active, memory string, since time.Duration, err error)
- func NeedCheckTombstone(topo *spec.Specification) bool
- func Restart(ctx context.Context, cluster spec.Topology, options Options, ...) error
- func RestartMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, ...) error
- func ScaleIn(ctx context.Context, cluster *spec.Specification, options Options, ...) error
- func ScaleInCluster(ctx context.Context, cluster *spec.Specification, options Options, ...) error
- func SetPDMember(ctx context.Context, clusterName string, enable bool, tlsCfg *tls.Config, ...) error
- func Start(ctx context.Context, cluster spec.Topology, options Options, ...) error
- func StartComponent(ctx context.Context, instances []spec.Instance, noAgentHosts set.StringSet, ...) error
- func StartMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, ...) error
- func Stop(ctx context.Context, cluster spec.Topology, options Options, evictLeader bool, ...) error
- func StopAndDestroyInstance(ctx context.Context, cluster spec.Topology, instance spec.Instance, ...) error
- func StopComponent(ctx context.Context, topo spec.Topology, instances []spec.Instance, ...) error
- func StopMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, ...) error
- func Upgrade(ctx context.Context, topo spec.Topology, options Options, tlsCfg *tls.Config, ...) error
- type CheckOptions
- type CheckResult
- func CheckDirIsExist(ctx context.Context, e ctxt.Executor, path string) []*CheckResult
- func CheckDirPermission(ctx context.Context, e ctxt.Executor, user, path string) []*CheckResult
- func CheckFIOResult(rr, rw, lat []byte) []*CheckResult
- func CheckJRE(ctx context.Context, e ctxt.Executor, host string, topo *spec.Specification) []*CheckResult
- func CheckKernelParameters(opt *CheckOptions, p []byte) []*CheckResult
- func CheckListeningPort(opt *CheckOptions, host string, topo *spec.Specification, rawData []byte) []*CheckResult
- func CheckPartitions(opt *CheckOptions, host string, topo *spec.Specification, rawData []byte) []*CheckResult
- func CheckSELinux(ctx context.Context, e ctxt.Executor, sudo bool) *CheckResult
- func CheckServices(ctx context.Context, e ctxt.Executor, host, service string, disable bool, ...) *CheckResult
- func CheckSysLimits(opt *CheckOptions, user string, l []byte) []*CheckResult
- func CheckSystemInfo(opt *CheckOptions, rawData []byte) []*CheckResult
- func CheckTHP(ctx context.Context, e ctxt.Executor, sudo bool) *CheckResult
- func CheckTimeZone(ctx context.Context, topo *spec.Specification, host string, rawData []byte) []*CheckResult
- type Operation
- type Options
- type SSHCustomScript
- type SSHCustomScripts
- type UpdatePDMember
Constants ¶
const ( EnvNameSkipScaleInTopoCheck = "SKIP_SCALEIN_TOPO_CHECK" EnvNamePDEndpointOverwrite = "FORCE_PD_ENDPOINTS" )
environment variable names that used to interrupt operations
Variables ¶
var ( CheckNameGeneral = "general" // errors that don't fit any specific check CheckNameNTP = "ntp" CheckNameChrony = "chrony" CheckNameOSVer = "os-version" CheckNameSwap = "swap" CheckNameSysctl = "sysctl" CheckNameCPUThreads = "cpu-cores" CheckNameCPUGovernor = "cpu-governor" CheckNameDisks = "disk" CheckNamePortListen = "listening-port" CheckNameEpoll = "epoll-exclusive" CheckNameMem = "memory" CheckNameNet = "network" CheckNameLimits = "limits" CheckNameSysService = "service" CheckNameSELinux = "selinux" CheckNameCommand = "command" CheckNameFio = "fio" CheckNameTHP = "thp" CheckNameDirPermission = "permission" CheckNameDirExist = "exist" CheckNameTimeZone = "timezone" )
Names of checks
Functions ¶
func AsyncNodes ¶
func AsyncNodes(spec *spec.Specification, nodes []string, async bool) []string
AsyncNodes return all nodes async destroy or not.
func CleanupComponent ¶ added in v1.1.0
CleanupComponent cleanup the instances
func DeleteGlobalDirs ¶
DeleteGlobalDirs deletes all global directories if they are empty
func DeletePublicKey ¶ added in v1.3.0
DeletePublicKey deletes the SSH public key from host
func DestroyClusterTombstone ¶
func DestroyClusterTombstone( ctx context.Context, cluster *spec.Specification, returNodesOnly bool, options Options, tlsCfg *tls.Config, ) (nodes []string, err error)
DestroyClusterTombstone remove the tombstone node in spec and destroy them. If returNodesOnly is true, it will only return the node id that can be destroy.
func DestroyComponent ¶
func DestroyComponent(ctx context.Context, instances []spec.Instance, cls spec.Topology, options Options) error
DestroyComponent destroy the instances.
func DestroyMonitored ¶
func DestroyMonitored(ctx context.Context, inst spec.Instance, options *spec.MonitoredOptions, timeout uint64, systemdMode spec.SystemdMode) error
DestroyMonitored destroy the monitored service.
func DestroyTombstone ¶
func DestroyTombstone( ctx context.Context, cluster *spec.Specification, returNodesOnly bool, options Options, tlsCfg *tls.Config, ) (nodes []string, err error)
DestroyTombstone remove the tombstone node in spec and destroy them. If returNodesOnly is true, it will only return the node id that can be destroy.
func Download ¶
Download the specific version of a component from the repository, there is nothing to do if the specified version exists.
func EnableComponent ¶ added in v1.2.0
func EnableComponent(ctx context.Context, instances []spec.Instance, noAgentHosts set.StringSet, options Options, isEnable bool, systemdMode string) error
EnableComponent enable/disable the instances
func EnableMonitored ¶ added in v1.2.0
func EnableMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, options *spec.MonitoredOptions, timeout uint64, isEnable bool, systemdMode string) error
EnableMonitored enable/disable monitor service in a cluster
func FilterComponent ¶
FilterComponent filter components by set
func FilterInstance ¶
FilterInstance filter instances by set
func GetNodeInfo ¶
func GetNodeInfo( ctx context.Context, topo spec.Topology, ) (nodes []*telemetry.NodeInfo, err error)
GetNodeInfo the node info in topology.
func GetServiceStatus ¶
func GetServiceStatus(ctx context.Context, e ctxt.Executor, name string, scope string, systemdMode string) (active, memory string, since time.Duration, err error)
GetServiceStatus return the Acitive line of status.
[tidb@ip-172-16-5-70 deploy]$ sudo systemctl status drainer-8249.service ● drainer-8249.service - drainer-8249 service
Loaded: loaded (/etc/systemd/system/drainer-8249.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2020-03-09 13:56:19 CST; 1 weeks 3 days ago Main PID: 36718 (drainer) CGroup: /system.slice/drainer-8249.service └─36718 bin/drainer --addr=172.16.5.70:8249 --pd-urls=http://172.16.5.70:2379 --data-dir=/data1/deploy/data.drainer --log-file=/data1/deploy/log/drainer.log --config=conf/drainer.toml --initial-commit-ts=408375872006389761
Mar 09 13:56:19 ip-172-16-5-70 systemd[1]: Started drainer-8249 service.
func NeedCheckTombstone ¶ added in v1.2.4
func NeedCheckTombstone(topo *spec.Specification) bool
NeedCheckTombstone return true if we need to check and destroy some node.
func Restart ¶
func Restart( ctx context.Context, cluster spec.Topology, options Options, tlsCfg *tls.Config, ) error
Restart the cluster.
func RestartMonitored ¶ added in v1.9.1
func RestartMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, options *spec.MonitoredOptions, timeout uint64, systemdMode string) error
RestartMonitored stop BlackboxExporter and NodeExporter
func ScaleIn ¶
func ScaleIn( ctx context.Context, cluster *spec.Specification, options Options, tlsCfg *tls.Config, ) error
ScaleIn scales in the cluster
func ScaleInCluster ¶
func ScaleInCluster( ctx context.Context, cluster *spec.Specification, options Options, tlsCfg *tls.Config, ) error
ScaleInCluster scales in the cluster
func SetPDMember ¶ added in v1.9.0
func SetPDMember(ctx context.Context, clusterName string, enable bool, tlsCfg *tls.Config, meta spec.Metadata) error
SetPDMember set the member of pd-etcd
func Start ¶
func Start( ctx context.Context, cluster spec.Topology, options Options, restoreLeader bool, tlsCfg *tls.Config, ) error
Start the cluster.
func StartComponent ¶
func StartComponent(ctx context.Context, instances []spec.Instance, noAgentHosts set.StringSet, options Options, tlsCfg *tls.Config, systemdMode string) error
StartComponent start the instances.
func StartMonitored ¶
func StartMonitored(ctx context.Context, hosts []string, noAgentHosts set.StringSet, options *spec.MonitoredOptions, timeout uint64, systemdMode string) error
StartMonitored start BlackboxExporter and NodeExporter
func Stop ¶
func Stop( ctx context.Context, cluster spec.Topology, options Options, evictLeader bool, tlsCfg *tls.Config, ) error
Stop the cluster.
func StopAndDestroyInstance ¶ added in v1.2.4
func StopAndDestroyInstance( ctx context.Context, cluster spec.Topology, instance spec.Instance, options Options, forceStop bool, destroyNode bool, tlsCfg *tls.Config, ) error
StopAndDestroyInstance stop and destroy the instance, if this instance is the host's last one, and the host has monitor deployed, we need to destroy the monitor, too
func StopComponent ¶
func StopComponent(ctx context.Context, topo spec.Topology, instances []spec.Instance, noAgentHosts set.StringSet, options Options, forceStop bool, evictLeader bool, tlsCfg *tls.Config, ) error
StopComponent stop the instances.
Types ¶
type CheckOptions ¶
type CheckOptions struct { // checks that are disabled by default EnableCPU bool EnableMem bool EnableDisk bool }
CheckOptions control the list of checks to be performed
type CheckResult ¶
type CheckResult struct { Name string // Name of the check Err error // An embedded error Warn bool // The check didn't pass, but not a big problem Msg string // A message or description }
CheckResult is the result of a check
func CheckDirIsExist ¶ added in v1.9.0
CheckDirIsExist check if the directory exists
func CheckDirPermission ¶ added in v1.4.0
CheckDirPermission checks if the user can write to given path
func CheckFIOResult ¶
func CheckFIOResult(rr, rw, lat []byte) []*CheckResult
CheckFIOResult parses and checks the result of fio test
func CheckJRE ¶ added in v1.4.0
func CheckJRE(ctx context.Context, e ctxt.Executor, host string, topo *spec.Specification) []*CheckResult
CheckJRE checks if java command is available for TiSpark nodes
func CheckKernelParameters ¶
func CheckKernelParameters(opt *CheckOptions, p []byte) []*CheckResult
CheckKernelParameters checks kernel parameter values
func CheckListeningPort ¶
func CheckListeningPort(opt *CheckOptions, host string, topo *spec.Specification, rawData []byte) []*CheckResult
CheckListeningPort checks if the ports are already binded by some process on host
func CheckPartitions ¶
func CheckPartitions(opt *CheckOptions, host string, topo *spec.Specification, rawData []byte) []*CheckResult
CheckPartitions checks partition info of data directories
func CheckSELinux ¶
CheckSELinux checks if SELinux is enabled on the host
func CheckServices ¶
func CheckServices(ctx context.Context, e ctxt.Executor, host, service string, disable bool, systemdMode spec.SystemdMode) *CheckResult
CheckServices checks if a service is running on the host
func CheckSysLimits ¶
func CheckSysLimits(opt *CheckOptions, user string, l []byte) []*CheckResult
CheckSysLimits checks limits in /etc/security/limits.conf
func CheckSystemInfo ¶
func CheckSystemInfo(opt *CheckOptions, rawData []byte) []*CheckResult
CheckSystemInfo performs checks with basic system info
func CheckTimeZone ¶ added in v1.10.0
func CheckTimeZone(ctx context.Context, topo *spec.Specification, host string, rawData []byte) []*CheckResult
CheckTimeZone performs checks if time zone is the same
func (CheckResult) IsWarning ¶
func (c CheckResult) IsWarning() bool
IsWarning checks if the result is a warning error
func (CheckResult) Passed ¶
func (c CheckResult) Passed() bool
Passed checks if the result is a success
func (CheckResult) String ¶
func (c CheckResult) String() string
String returns a readable string of the error
func (CheckResult) Unwrap ¶
func (c CheckResult) Unwrap() error
Unwrap implements the Wrapper interface
type Operation ¶
type Operation byte
Operation represents the type of cluster operation
type Options ¶
type Options struct { Roles []string Nodes []string Force bool // Option for upgrade/tls subcommand SSHTimeout uint64 // timeout in seconds when connecting an SSH server OptTimeout uint64 // timeout in seconds for operations that support it, not to confuse with SSH timeout APITimeout uint64 // timeout in seconds for API operations that support it, like transferring store leader IgnoreConfigCheck bool // should we ignore the config check result after init config NativeSSH bool // should use native ssh client or builtin easy ssh (deprecated, shoule use SSHType) SSHType executor.SSHType // the ssh type: 'builtin', 'system', 'none' Concurrency int // max number of parallel tasks to run SSHProxyHost string // the ssh proxy host SSHProxyPort int // the ssh proxy port SSHProxyUser string // the ssh proxy user SSHProxyIdentity string // the ssh proxy identity file SSHProxyUsePassword bool // use password instead of identity file for ssh proxy connection SSHProxyTimeout uint64 // timeout in seconds when connecting the proxy host SSHCustomScripts SSHCustomScripts // custom scripts to be executed during the operation // What type of things should we cleanup in clean command CleanupData bool // should we cleanup data CleanupLog bool // should we clenaup log CleanupAuditLog bool // should we clenaup tidb server auit log // Some data will be retained when destroying instances RetainDataRoles []string RetainDataNodes []string DisplayMode string // the output format Operation Operation }
Options represents the operation options
type SSHCustomScript ¶ added in v1.12.0
type SSHCustomScript struct {
Raw string
}
SSHCustomScript represents a custom ssh script to be executed during cluster operations
func (SSHCustomScript) Command ¶ added in v1.12.0
func (s SSHCustomScript) Command() string
Command returns the ssh command in string format
type SSHCustomScripts ¶ added in v1.12.0
type SSHCustomScripts struct { BeforeRestartInstance SSHCustomScript AfterRestartInstance SSHCustomScript }
SSHCustomScripts represents the custom ssh script set to be executed during cluster operations
type UpdatePDMember ¶ added in v1.9.0
type UpdatePDMember struct {
// contains filtered or unexported fields
}
UpdatePDMember is used to update pd cluster member