Documentation ¶
Index ¶
- Variables
- type Cache
- type Manager
- type Metadata
- type Nodes
- func (nodes *Nodes) GetAllNodes(ctx context.Context) ([]*cnsvsphere.VirtualMachine, error)
- func (nodes *Nodes) GetNodeNameByUUID(ctx context.Context, nodeUUID string) (string, error)
- func (nodes *Nodes) GetNodeVMByName(ctx context.Context, nodeName string) (*cnsvsphere.VirtualMachine, error)
- func (nodes *Nodes) GetNodeVMByNameAndUpdateCache(ctx context.Context, nodeName string) (*cnsvsphere.VirtualMachine, error)
- func (nodes *Nodes) GetNodeVMByUuid(ctx context.Context, nodeUuid string) (*cnsvsphere.VirtualMachine, error)
- func (nodes *Nodes) GetSharedDatastoresInK8SCluster(ctx context.Context) ([]*cnsvsphere.DatastoreInfo, error)
- func (nodes *Nodes) GetSharedDatastoresInTopology(ctx context.Context, topologyRequirement *csi.TopologyRequirement, ...) ([]*cnsvsphere.DatastoreInfo, map[string][]map[string]string, error)
- func (nodes *Nodes) Initialize(ctx context.Context, useNodeUuid bool) error
Constants ¶
This section is empty.
Variables ¶
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.
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.
type Manager ¶
type Manager interface { // SetKubernetesClient sets kubernetes client for node manager. SetKubernetesClient(client clientset.Interface) // SetUseNodeUuid sets whether the node manager should use // K8s CSINode API object or the K8s Node API object to retrieve // the node UUID. SetUseNodeUuid(useNodeUuid bool) // 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) // GetNodeVMAndUpdateCache 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) // GetNodeVMByName returns the VirtualMachine for a registered node // given its name without refreshing cache the nodes. GetNodeVMByName(ctx context.Context, nodeName 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) // UnregisterNode unregisters a registered node given its name. UnregisterNode(ctx context.Context, nodeName string) error }
Manager provides functionality to manage nodes.
func GetManager ¶
GetManager returns the Manager singleton.
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 for all registered. This is called by ControllerExpandVolume to check if volume is attached to a node.
func (*Nodes) GetNodeNameByUUID ¶
GetNodeNameByUUID fetches the name of the node given the VM UUID.
func (*Nodes) GetNodeVMByName ¶ added in v2.6.4
func (nodes *Nodes) GetNodeVMByName(ctx context.Context, nodeName string) ( *cnsvsphere.VirtualMachine, error)
GetNodeVMByName returns VirtualMachine object for given nodeName. This is called by ControllerPublishVolume and ControllerUnpublishVolume to perform attach and detach operations.
func (*Nodes) GetNodeVMByNameAndUpdateCache ¶ added in v2.6.4
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) GetNodeVMByUuid ¶ added in v2.6.4
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) GetSharedDatastoresInTopology ¶
func (nodes *Nodes) GetSharedDatastoresInTopology( ctx context.Context, topologyRequirement *csi.TopologyRequirement, tagManager *tags.Manager, zoneCategoryName string, regionCategoryName string) ( []*cnsvsphere.DatastoreInfo, map[string][]map[string]string, error)
GetSharedDatastoresInTopology returns shared accessible datastores for specified topologyRequirement along with the map of datastore URL and array of accessibleTopology map for each datastore returned from this function.
Here in this function, argument topologyRequirement can be passed in following form: topologyRequirement [requisite:<segments:<key:"failure-domain.beta.kubernetes.io/region" value:"k8s-region-us" >
segments:<key:"failure-domain.beta.kubernetes.io/zone" value:"k8s-zone-us-east" > > requisite:<segments:<key:"failure-domain.beta.kubernetes.io/region" value:"k8s-region-us" > segments:<key:"failure-domain.beta.kubernetes.io/zone" value:"k8s-zone-us-west" > > preferred:<segments:<key:"failure-domain.beta.kubernetes.io/region" value:"k8s-region-us" > segments:<key:"failure-domain.beta.kubernetes.io/zone" value:"k8s-zone-us-west" > > preferred:<segments:<key:"failure-domain.beta.kubernetes.io/region" value:"k8s-region-us" > segments:<key:"failure-domain.beta.kubernetes.io/zone" value:"k8s-zone-us-east" > > ]
Return map datastoreTopologyMap looks like as below map[ ds:///vmfs/volumes/5d119112-7b28fe05-f51d-02000b3a3f4b/:
[map [ failure-domain.beta.kubernetes.io/region:k8s-region-us failure-domain.beta.kubernetes.io/zone:k8s-zone-us-east ]] ds:///vmfs/volumes/e54abc3f-f6a5bb1f-0000-000000000000/: [map [ failure-domain.beta.kubernetes.io/region:k8s-region-us failure-domain.beta.kubernetes.io/zone:k8s-zone-us-east ]] ds:///vmfs/volumes/vsan:524fae1aaca129a5-1ee55a87f26ae626/: [map [ failure-domain.beta.kubernetes.io/region:k8s-region-us failure-domain.beta.kubernetes.io/zone:k8s-zone-us-west ] map [ failure-domain.beta.kubernetes.io/region:k8s-region-us failure-domain.beta.kubernetes.io/zone:k8s-zone-us-east ]] ]