operator

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Copyright © 2020 Marvin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteGlobalDirs

func DeleteGlobalDirs(ctx context.Context, host string, options *cluster.GlobalOptions) error

DeleteGlobalDirs deletes all global directories if they are empty

func DeletePublicKey

func DeletePublicKey(ctx context.Context, host string) error

DeletePublicKey deletes the SSH public key from host

func Destroy

func Destroy(
	ctx context.Context,
	topo *cluster.Topology,
	options *Options,
) error

Destroy the cluster.

func DestroyComponent

func DestroyComponent(ctx context.Context, instances []cluster.Instance, cls *cluster.Topology, options *Options) error

DestroyComponent destroy the instances.

func Enable

func Enable(
	ctx context.Context,
	topo *cluster.Topology,
	options *Options,
	isEnable bool,
) error

Enable will enable/disable the cluster

func EnableComponent

func EnableComponent(ctx context.Context, instances []cluster.Instance, options *Options, isEnable bool, systemdMode string) error

EnableComponent enable/disable the instances

func FilterComponent

func FilterComponent(comps []cluster.Component, components stringutil.StringSet) (res []cluster.Component)

FilterComponent filter components by set

func FilterInstance

func FilterInstance(instances []cluster.Instance, nodes stringutil.StringSet) (res []cluster.Instance)

FilterInstance filter instances by set

func GetServiceStatus

func GetServiceStatus(ctx context.Context, e executor.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 Restart

func Restart(
	ctx context.Context,
	cluster *cluster.Topology,
	options *Options,
	tlsCfg *tls.Config,
) error

Restart the cluster.

func Start

func Start(
	ctx context.Context,
	cluster *cluster.Topology,
	options *Options,
	tlsCfg *tls.Config,
) error

Start the cluster.

func StartComponent

func StartComponent(ctx context.Context, instances []cluster.Instance, options *Options, tlsCfg *tls.Config, systemdMode string) error

StartComponent start the instances.

func Stop

func Stop(
	ctx context.Context,
	cluster *cluster.Topology,
	options *Options,
) error

Stop the cluster.

func StopComponent

func StopComponent(ctx context.Context,
	topo *cluster.Topology,
	instances []cluster.Instance,
	options *Options,
) error

StopComponent stop the instances.

func Upgrade

func Upgrade(
	ctx context.Context,
	topo *cluster.Topology,
	options *Options,
	tlsCfg *tls.Config,
) error

Upgrade the cluster. (actually, it's rolling restart)

Types

type Operation

type Operation byte

Operation represents the type of cluster operation

const (
	// StartOperation Operation = iota
	// StopOperation
	RestartOperation Operation = iota
	DestroyOperation
	UpgradeOperation
	ScaleInOperation
	ScaleOutOperation
	DestroyTombstoneOperation
)

Operation represents the kind of cluster operation

func (Operation) String

func (op Operation) String() string

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
	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

	MetaDir     string // the metadata dir
	MirrorDir   string // the mirror dir
	SkipConfirm bool
	Operation   Operation
}

Options represents the operation options

type SSHConnectionProps

type SSHConnectionProps struct {
	Password               string
	IdentityFile           string
	IdentityFilePassphrase string
}

SSHConnectionProps is SSHConnectionProps

func ReadIdentityFileOrPassword

func ReadIdentityFileOrPassword(identityFilePath string, usePass bool) (*SSHConnectionProps, error)

ReadIdentityFileOrPassword is ReadIdentityFileOrPassword

type SSHCustomScript

type SSHCustomScript struct {
	Raw string
}

SSHCustomScript represents a custom ssh script to be executed during cluster operations

func (SSHCustomScript) Command

func (s SSHCustomScript) Command() string

Command returns the ssh command in string format

type SSHCustomScripts

type SSHCustomScripts struct {
	BeforeRestartInstance SSHCustomScript
	AfterRestartInstance  SSHCustomScript
}

SSHCustomScripts represents the custom ssh script set to be executed during cluster operations

Jump to

Keyboard shortcuts

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