node

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeAlreadyExists = errors.New("another node with the same name exists")

ErrNodeAlreadyExists is returned if there's exists a node with the same name but different UUID.

View Source
var (
	// ErrNodeNotFound is returned when a node isn't found in the node manager cache.
	ErrNodeNotFound = errors.New("node wasn't found")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// DeleteNodeByUUID deletes a node entry by its UUID and returns its current name.
	DeleteNodeByUUID(ctx context.Context, nodeUUID string) (string, error)
	// DeleteNodeByName deletes a node entry by its name and returns its current UUID.
	DeleteNodeByName(ctx context.Context, nodeName string) (string, error)
	// LoadNodeNameByUUID returns a node's name given its UUID.
	LoadNodeNameByUUID(ctx context.Context, nodeUUID string) (string, error)
	// LoadNodeUUIDByName returns a node's UUID given its name.
	LoadNodeUUIDByName(ctx context.Context, nodeName string) (string, error)
	// Range calls f sequentially for each node entry.
	Range(ctx context.Context, f func(nodeUUID, nodeName string) bool)
	// Store associates the node UUID with its name. If the node UUID already
	// exists in the Cache, the name associated with it is updated.
	Store(ctx context.Context, nodeUUID, nodeName string) error
}

Cache provides thread-safe functionality to cache node information. Note that node names are handled in a case sensitive manner, and must be unique.

func GetCache

func GetCache(ctx context.Context) Cache

GetCache returns the Cache singleton.

type Manager

type Manager interface {
	// SetKubernetesClient sets kubernetes client for node manager.
	SetKubernetesClient(client clientset.Interface)
	// RegisterNode registers a node given its UUID, name.
	RegisterNode(ctx context.Context, nodeUUID string, nodeName string) error
	// DiscoverNode discovers a registered node given its UUID. This method
	// scans all virtual centers registered on the VirtualCenterManager for a
	// virtual machine with the given UUID.
	DiscoverNode(ctx context.Context, nodeUUID string) error
	// GetK8sNode returns Kubernetes Node object for the given node name
	GetK8sNode(ctx context.Context, nodename string) (*v1.Node, error)
	// GetNode refreshes and returns the VirtualMachine for a registered node
	// given its UUID. If datacenter is present, GetNode will search within this
	// datacenter given its UUID. If not, it will search in all registered
	// datacenters.
	GetNodeVMAndUpdateCache(ctx context.Context, nodeUUID string, dc *vsphere.Datacenter) (*vsphere.VirtualMachine, error)
	// GetNodeVMByUuid returns the VirtualMachine for a registered node
	// given its UUID.
	GetNodeVMByUuid(ctx context.Context, nodeUUID string) (*vsphere.VirtualMachine, error)
	// GetNodeVMByNameAndUpdateCache refreshes and returns the VirtualMachine for a registered
	// node given its name.
	GetNodeVMByNameAndUpdateCache(ctx context.Context, nodeName string) (*vsphere.VirtualMachine, error)
	// GetNodeVMByNameOrUUID refreshes and returns VirtualMachine for a registered node
	// using either its name or UUID.
	GetNodeVMByNameOrUUID(ctx context.Context, nodeNameOrUuid string) (*vsphere.VirtualMachine, error)
	// GetNodeNameByUUID fetches the name of the node given the VM UUID.
	GetNodeNameByUUID(ctx context.Context, nodeUUID string) (string, error)
	// GetAllNodes refreshes and returns VirtualMachine for all registered
	// nodes. If nodes are added or removed concurrently, they may or may not be
	// reflected in the result of a call to this method.
	GetAllNodes(ctx context.Context) ([]*vsphere.VirtualMachine, error)
	// GetAllNodesByVC refreshes and returns VirtualMachine for all registered
	// nodes in the given VC. If nodes are added or removed concurrently, they
	// may or may not be reflected in the result of a call to this method.
	GetAllNodesByVC(ctx context.Context, vcHost string) ([]*vsphere.VirtualMachine, error)
	// UnregisterNode unregisters a registered node given its name.
	UnregisterNode(ctx context.Context, nodeName string) error
}

Manager provides functionality to manage nodes.

func GetManager

func GetManager(ctx context.Context) Manager

GetManager returns the Manager singleton.

type Metadata

type Metadata interface{}

Metadata represents node metadata.

type Nodes

type Nodes struct {
	// contains filtered or unexported fields
}

Nodes comprises cns node manager and kubernetes informer.

func (*Nodes) GetAllNodes

func (nodes *Nodes) GetAllNodes(ctx context.Context) (
	[]*cnsvsphere.VirtualMachine, error)

GetAllNodes returns VirtualMachine objects for all registered nodes in cluster.

func (*Nodes) GetAllNodesByVC

func (nodes *Nodes) GetAllNodesByVC(ctx context.Context, vcHost string) ([]*cnsvsphere.VirtualMachine, error)

GetAllNodesByVC returns VirtualMachine objects for all registered nodes for a particular VC.

func (*Nodes) GetNodeNameByUUID

func (nodes *Nodes) GetNodeNameByUUID(ctx context.Context, nodeUUID string) (
	string, error)

GetNodeNameByUUID fetches the name of the node given the VM UUID.

func (*Nodes) GetNodeVMByNameAndUpdateCache added in v3.0.3

func (nodes *Nodes) GetNodeVMByNameAndUpdateCache(ctx context.Context, nodeName string) (
	*cnsvsphere.VirtualMachine, error)

GetNodeVMByNameAndUpdateCache returns VirtualMachine object for given nodeName. This is called by ControllerPublishVolume and ControllerUnpublishVolume to perform attach and detach operations.

func (*Nodes) GetNodeVMByNameOrUUID added in v3.0.3

func (nodes *Nodes) GetNodeVMByNameOrUUID(
	ctx context.Context, nodeNameOrUUID string) (*cnsvsphere.VirtualMachine, error)

GetNodeVMByNameOrUUID returns VirtualMachine object for given nodeName This function can be called either using nodeName or nodeUID.

func (*Nodes) GetNodeVMByUuid added in v3.0.3

func (nodes *Nodes) GetNodeVMByUuid(ctx context.Context, nodeUuid string) (*cnsvsphere.VirtualMachine, error)

GetNodeVMByUuid returns VirtualMachine object for given nodeUuid. This is called by ControllerPublishVolume and ControllerUnpublishVolume to perform attach and detach operations.

func (*Nodes) GetSharedDatastoresInK8SCluster

func (nodes *Nodes) GetSharedDatastoresInK8SCluster(ctx context.Context) (
	[]*cnsvsphere.DatastoreInfo, error)

GetSharedDatastoresInK8SCluster returns list of DatastoreInfo objects for datastores accessible to all kubernetes nodes in the cluster.

func (*Nodes) Initialize

func (nodes *Nodes) Initialize(ctx context.Context) error

Initialize helps initialize node manager and node informer manager.

Jump to

Keyboard shortcuts

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