node

package
v0.0.0-...-4c0c8b4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotSupportedDriver = &notSupportedDriver{}

NotSupportedDriver provides the default driver with none of the operations supported

Functions

func AddNode

func AddNode(n Node) error

AddNode adds a node to the node collection

func Contains

func Contains(nodes []Node, n Node) bool

Contains checks if the node is present in the given list of nodes

func GetNodesByName

func GetNodesByName() map[string]Node

GetNodesByName returns map of nodes where the node name is the key

func Register

func Register(name string, d Driver) error

Register registers the given node driver

func UpdateNode

func UpdateNode(n Node) error

UpdateNode updates a given node if it exists in the node collection

Types

type ConnectionOpts

type ConnectionOpts struct {
	Timeout         time.Duration
	TimeBeforeRetry time.Duration
}

ConnectionOpts provide basic options for all operations and can be embedded by other options

type Driver

type Driver interface {
	// Init initializes the node driver under the given scheduler
	Init() error

	// String returns the string name of this driver.
	String() string

	// RebootNode reboots the given node
	RebootNode(node Node, options RebootNodeOpts) error

	// RunCommand runs the given command on the node and returns the output
	RunCommand(node Node, command string, options ConnectionOpts) (string, error)

	// ShutdownNode shuts down the given node
	ShutdownNode(node Node, options ShutdownNodeOpts) error

	// FindFiles finds and returns the files for the given path regex and the node
	FindFiles(path string, node Node, options FindOpts) (string, error)

	// Systemctl runs a systemctl command for the given service on the node
	Systemctl(node Node, service string, options SystemctlOpts) error

	// TestConnection tests connection to given node. returns nil if driver can connect to given node
	TestConnection(node Node, options ConnectionOpts) error

	// YankDrive simulates a failure on the provided drive on the given node.
	// It returns the bus ID of the drive which can be used to recover it back
	YankDrive(node Node, driveNameToFail string, options ConnectionOpts) (string, error)

	// RecoverDrive recovers the given drive from failure on the given node.
	RecoverDrive(node Node, driveNameToRecover string, driveUUID string, options ConnectionOpts) error

	// SystemCheck checks whether core files are present on the given node.
	SystemCheck(node Node) (string, error)
}

Driver provides the node driver interface

func Get

func Get(name string) (Driver, error)

Get returns a registered node driver

type ErrFailedToFindFileOnNode

type ErrFailedToFindFileOnNode struct {
	Node  Node
	Cause string
}

ErrFailedToFindFileOnNode error type when failing to run find on the node

func (*ErrFailedToFindFileOnNode) Error

func (e *ErrFailedToFindFileOnNode) Error() string

type ErrFailedToRebootNode

type ErrFailedToRebootNode struct {
	Node  Node
	Cause string
}

ErrFailedToRebootNode error type when failing to reboot a node

func (*ErrFailedToRebootNode) Error

func (e *ErrFailedToRebootNode) Error() string

type ErrFailedToRecoverDrive

type ErrFailedToRecoverDrive struct {
	Node  Node
	Cause string
}

ErrFailedToRecoverDrive error type when we fail to simulate drive failure

func (*ErrFailedToRecoverDrive) Error

func (e *ErrFailedToRecoverDrive) Error() string

type ErrFailedToRunCommand

type ErrFailedToRunCommand struct {
	Addr  string
	Cause string
}

ErrFailedToRunCommand error type when failing to run command

func (*ErrFailedToRunCommand) Error

func (e *ErrFailedToRunCommand) Error() string

type ErrFailedToRunSystemctlOnNode

type ErrFailedToRunSystemctlOnNode struct {
	Node  Node
	Cause string
}

ErrFailedToRunSystemctlOnNode error type when failing to run systemctl on the node

func (*ErrFailedToRunSystemctlOnNode) Error

type ErrFailedToShutdownNode

type ErrFailedToShutdownNode struct {
	Node  Node
	Cause string
}

ErrFailedToShutdownNode error type when failing to shutdown the node

func (*ErrFailedToShutdownNode) Error

func (e *ErrFailedToShutdownNode) Error() string

type ErrFailedToSystemCheck

type ErrFailedToSystemCheck struct {
	Node  Node
	Cause string
}

ErrFailedToSystemCheck error type when we fail to check for core files

func (*ErrFailedToSystemCheck) Error

func (e *ErrFailedToSystemCheck) Error() string

type ErrFailedToTestConnection

type ErrFailedToTestConnection struct {
	Node  Node
	Cause string
}

ErrFailedToTestConnection error type when failing to test connection

func (*ErrFailedToTestConnection) Error

func (e *ErrFailedToTestConnection) Error() string

type ErrFailedToYankDrive

type ErrFailedToYankDrive struct {
	Node  Node
	Cause string
}

ErrFailedToYankDrive error type when we fail to simulate drive failure

func (*ErrFailedToYankDrive) Error

func (e *ErrFailedToYankDrive) Error() string

type FindOpts

type FindOpts struct {
	Name     string
	MinDepth int
	MaxDepth int
	Type     FindType
	ConnectionOpts
}

FindOpts provide additional options for find operation

type FindType

type FindType string

FindType identifies the type of find command

const (
	// File identifies a search on find command to look for files only
	File FindType = "f"
	// Directory identifies a search on find command to look for directories only
	Directory FindType = "d"
)

type Node

type Node struct {
	VolDriverNodeID          string
	Name                     string
	Addresses                []string
	UsableAddr               string
	Type                     Type
	IsStorageDriverInstalled bool
	// contains filtered or unexported fields
}

Node encapsulates a node in the cluster

func GetNodes

func GetNodes() []Node

GetNodes returns all the nodes from the node collection

func GetStorageDriverNodes

func GetStorageDriverNodes() []Node

GetStorageDriverNodes returns only the worker node where storage driver is installed

func GetWorkerNodes

func GetWorkerNodes() []Node

GetWorkerNodes returns only the worker nodes/agent nodes

type RebootNodeOpts

type RebootNodeOpts struct {
	Force bool
	ConnectionOpts
}

RebootNodeOpts provide additional options for reboot operation

type ShutdownNodeOpts

type ShutdownNodeOpts struct {
	Force bool
	ConnectionOpts
}

ShutdownNodeOpts provide additional options for shutdown operation

type SystemctlOpts

type SystemctlOpts struct {
	Action string
	ConnectionOpts
}

SystemctlOpts provide options for systemctl operation

type TestConnectionOpts

type TestConnectionOpts struct {
	ConnectionOpts
}

TestConnectionOpts provide additional options for test connection operation

type Type

type Type string

Type identifies the type of the cluster node

const (
	// TypeMaster identifies a cluster node that is a master/manager
	TypeMaster Type = "Master"
	// TypeWorker identifies a cluster node that is a worker
	TypeWorker Type = "Worker"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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