vadmin

package
v1.11.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// The name of the IP map file that is used by re_ip.  re_ip is only ever used if the entire cluster is down.
	AdminToolsMapFile = "/opt/vertica/config/ipMap.txt"
)
View Source
const (
	// Constant for an up node, this is taken from the STATE column in NODES table
	StateUp = "UP"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Admintools

type Admintools struct {
	PRunner  cmds.PodRunner
	Log      logr.Logger
	EVWriter events.EVWriter
	VDB      *vapi.VerticaDB
	DevMode  bool // true to include verbose logging for some operations
}

Admintools is the legacy style of running admin commands. All commands are sent to a process that runs admintools. The output is then parsed out of the stdout/stderr output that is captured.

func (*Admintools) AddNode

func (a *Admintools) AddNode(ctx context.Context, opts ...addnode.Option) error

AddNode will add a new vertica node to the cluster. If add node fails due to a license limit, the error will be of type addnode.LicenseLimitError.

func (*Admintools) AddSubcluster

func (a *Admintools) AddSubcluster(ctx context.Context, opts ...addsc.Option) error

AddSubcluster will create a subcluster in the vertica cluster.

func (*Admintools) CreateDB

func (a *Admintools) CreateDB(ctx context.Context, opts ...createdb.Option) (ctrl.Result, error)

CreateDB will create a brand new database using the admintools API (-t create_db).

func (*Admintools) DescribeDB

func (a *Admintools) DescribeDB(ctx context.Context, opts ...describedb.Option) (string, ctrl.Result, error)

DescribeDB will get information about a database from communal storage. For the admintools implementation, this is running the revive with the --display-only option.

func (*Admintools) FetchNodeState

func (a *Admintools) FetchNodeState(ctx context.Context, opts ...fetchnodestate.Option) (map[string]string, ctrl.Result, error)

FetchNodeState will determine if the given set of nodes are considered UP or DOWN in our consensus state. It returns a map of vnode and its node state.

func (*Admintools) ReIP

func (a *Admintools) ReIP(ctx context.Context, opts ...reip.Option) (ctrl.Result, error)

ReIP will update the catalog on disk with new IPs for all of the nodes given.

func (*Admintools) RemoveNode

func (a *Admintools) RemoveNode(ctx context.Context, opts ...removenode.Option) error

RemoveNode will remove an existng vrtica node from the cluster.

func (*Admintools) RemoveSubcluster

func (a *Admintools) RemoveSubcluster(ctx context.Context, opts ...removesc.Option) error

RemoveSubcluster will remove the given subcluster from the vertica cluster.

func (*Admintools) RestartNode

func (a *Admintools) RestartNode(ctx context.Context, opts ...restartnode.Option) (ctrl.Result, error)

RestartNode will restart a subset of nodes. Use this when vertica has not lost cluster quorum. The IP given for each vnode may not match the current IP in the vertica catalogs.

func (*Admintools) ReviveDB

func (a *Admintools) ReviveDB(ctx context.Context, opts ...revivedb.Option) (ctrl.Result, error)

ReviveDB will initialize a database from an existing communal path. Admintools is used to run the revive.

func (*Admintools) StartDB

func (a *Admintools) StartDB(ctx context.Context, opts ...startdb.Option) (ctrl.Result, error)

StartDB will start a subset of nodes. Use this when vertica has lost cluster quorum. The IP given for each vnode *must* match the current IP in the vertica catalog. If they aren't a call to ReIP is necessary.

func (*Admintools) StopDB

func (a *Admintools) StopDB(ctx context.Context, opts ...stopdb.Option) error

StopDB will stop all the vertica hosts of a running cluster

type DBCreator

type DBCreator struct {
	Admintools *Admintools
	Parms      createdb.Parms
}

func (*DBCreator) GenCmd

func (d *DBCreator) GenCmd() []string

GenCmd will return the command line options for calling admintools -t create_db.

func (*DBCreator) GetConfigParms

func (d *DBCreator) GetConfigParms() map[string]string

GetConfigParms returns the configuration parameters map.

func (*DBCreator) GetInitiator

func (d *DBCreator) GetInitiator() types.NamespacedName

GetInitiator returns the initiator pod name.

func (*DBCreator) LogFailure

func (d *DBCreator) LogFailure(stdout string, err error) (ctrl.Result, error)

LogFailure will log and record an event for an admintools -t create_db failure

type DBInitializer

type DBInitializer interface {
	GenCmd() []string
	GetInitiator() types.NamespacedName
	GetConfigParms() map[string]string
	LogFailure(string, error) (ctrl.Result, error)
}

type DBReviver

type DBReviver struct {
	Admintools *Admintools
	Parms      revivedb.Parms
}

func (*DBReviver) GenCmd

func (d *DBReviver) GenCmd() []string

GenCmd will return the command line options for calling admintools -t revive_db.

func (*DBReviver) GetConfigParms

func (d *DBReviver) GetConfigParms() map[string]string

GetConfigParms returns the configuration parameters map.

func (*DBReviver) GetInitiator

func (d *DBReviver) GetInitiator() types.NamespacedName

GetInitiator returns the initiator pod name.

func (*DBReviver) LogFailure

func (d *DBReviver) LogFailure(stdout string, err error) (ctrl.Result, error)

LogFailure will log and record an event for an admintools -t revive_db failure

type Dispatcher

type Dispatcher interface {
	// CreateDB will create a brand new database. It assumes the communal
	// storage location is empty.
	CreateDB(ctx context.Context, opts ...createdb.Option) (ctrl.Result, error)

	// ReviveDB will initialize a database using a pre-populated communal path.
	ReviveDB(ctx context.Context, opts ...revivedb.Option) (ctrl.Result, error)

	// DescribeDB will read state information about the database in communal
	// storage and return it back to the caller.
	DescribeDB(ctx context.Context, opts ...describedb.Option) (string, ctrl.Result, error)

	// FetchNodeState will determine if the given set of nodes are considered UP
	// or DOWN in our consensous state. It returns a map of vnode to its node state.
	FetchNodeState(ctx context.Context, opts ...fetchnodestate.Option) (map[string]string, ctrl.Result, error)

	// ReIP will update the catalog on disk with new IPs for all of the nodes given.
	ReIP(ctx context.Context, opts ...reip.Option) (ctrl.Result, error)

	// StopDB will stop all the vertica hosts of a running cluster.
	StopDB(ctx context.Context, opts ...stopdb.Option) error

	// AddNode will add a new vertica node to the cluster. If add node fails due to
	// a license limit, the error will be of type addnode.LicenseLimitError.
	AddNode(ctx context.Context, opts ...addnode.Option) error

	// AddSubcluster will create a subcluster in the vertica cluster.
	AddSubcluster(ctx context.Context, opts ...addsc.Option) error

	// RemoveNode will remove an existng vertica node from the cluster.
	RemoveNode(ctx context.Context, opts ...removenode.Option) error

	// RemoveSubcluster will remove the given subcluster from the vertica cluster.
	RemoveSubcluster(ctx context.Context, opts ...removesc.Option) error

	// RestartNode will restart a subset of nodes. Use this when vertica has not
	// lost cluster quorum. The IP given for each vnode may not match the current IP
	// in the vertica catalogs.
	RestartNode(ctx context.Context, opts ...restartnode.Option) (ctrl.Result, error)

	// StartDB will start a subset of nodes. Use this when vertica has lost
	// cluster quorum. The IP given for each vnode *must* match the current IP
	// in the vertica catalog. If they aren't a call to ReIP is necessary.
	StartDB(ctx context.Context, opts ...startdb.Option) (ctrl.Result, error)
}

func MakeAdmintools

func MakeAdmintools(log logr.Logger, vdb *vapi.VerticaDB, prunner cmds.PodRunner, evWriter events.EVWriter, devMode bool) Dispatcher

MakeAdmintools will create a dispatcher that uses admintools to call the admin commands.

func MakeVClusterOps

func MakeVClusterOps(log logr.Logger, vdb *vapi.VerticaDB, cli client.Client, vopsi VClusterProvider,
	passwd string, evWriter events.EVWriter) Dispatcher

MakeVClusterOps will create a dispatcher that uses the vclusterops library for admin commands.

type HTTPSCerts

type HTTPSCerts struct {
	Key    string
	Cert   string
	CaCert string
}

type VClusterOps

type VClusterOps struct {
	Log    logr.Logger
	VDB    *vapi.VerticaDB
	Client client.Client
	VClusterProvider
	Password string
	EVWriter events.EVWriter
}

VClusterOps is the new style of running admin commands. It makes use of the vclusterops library to perform all of the admin operations via RESTful interfaces.

func (*VClusterOps) AddNode

func (v *VClusterOps) AddNode(ctx context.Context, opts ...addnode.Option) error

AddNode will add a new vertica node to the cluster

func (*VClusterOps) AddSubcluster

func (v *VClusterOps) AddSubcluster(ctx context.Context, opts ...addsc.Option) error

AddSubcluster will create a subcluster in the vertica cluster.

func (*VClusterOps) CreateDB

func (v *VClusterOps) CreateDB(ctx context.Context, opts ...createdb.Option) (ctrl.Result, error)

CreateDB will construct a new DB using the vcluster-ops library

func (*VClusterOps) DescribeDB

func (v *VClusterOps) DescribeDB(ctx context.Context, opts ...describedb.Option) (string, ctrl.Result, error)

DescribeDB will get information about a database from communal storage.

func (*VClusterOps) FetchNodeState

func (v *VClusterOps) FetchNodeState(ctx context.Context, opts ...fetchnodestate.Option) (map[string]string, ctrl.Result, error)

FetchNodeState will determine if the given set of nodes are considered UP or DOWN in our consensous state. It returns a map of vnode to its node state.

func (*VClusterOps) ReIP

func (v *VClusterOps) ReIP(ctx context.Context, opts ...reip.Option) (ctrl.Result, error)

ReIP will update the catalog on disk with new IPs for all of the nodes given.

func (*VClusterOps) RemoveNode

func (v *VClusterOps) RemoveNode(ctx context.Context, opts ...removenode.Option) error

RemoveNode will remove an existng vertica node from the cluster.

func (*VClusterOps) RemoveSubcluster

func (v *VClusterOps) RemoveSubcluster(ctx context.Context, opts ...removesc.Option) error

RemoveSubcluster will remove the given subcluster from the vertica cluster.

func (*VClusterOps) RestartNode

func (v *VClusterOps) RestartNode(ctx context.Context, opts ...restartnode.Option) (ctrl.Result, error)

RestartNode will restart a subset of nodes. Use this when vertica has not lost cluster quorum. The IP given for each vnode may not match the current IP in the vertica catalogs.

func (*VClusterOps) ReviveDB

func (v *VClusterOps) ReviveDB(ctx context.Context, opts ...revivedb.Option) (ctrl.Result, error)

ReviveDB will initialized a database using an existing communal path. It does this using the vclusterops library.

func (*VClusterOps) StartDB

func (v *VClusterOps) StartDB(ctx context.Context, opts ...startdb.Option) (ctrl.Result, error)

StartDB will start a subset of nodes of the database

func (*VClusterOps) StopDB

func (v *VClusterOps) StopDB(ctx context.Context, opts ...stopdb.Option) error

StopDB will stop all the vertica hosts of a running cluster

type VClusterProvider

type VClusterProvider interface {
	VCreateDatabase(options *vops.VCreateDatabaseOptions) (vops.VCoordinationDatabase, error)
	VStopDatabase(options *vops.VStopDatabaseOptions) error
	VStartDatabase(options *vops.VStartDatabaseOptions) error
	VFetchNodeState(options *vops.VFetchNodeStateOptions) ([]vops.NodeInfo, error)
	VAddSubcluster(options *vops.VAddSubclusterOptions) error
	VAddNode(options *vops.VAddNodeOptions) (vops.VCoordinationDatabase, error)
	VReIP(options *vops.VReIPOptions) error
}

VClusterProvider is for mocking test We will have two concrete implementations for the interface

  1. real implementation in vcluster-ops library
  2. mock implementation for unit test

Directories

Path Synopsis
opts

Jump to

Keyboard shortcuts

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