provider

package
v0.3.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Liveness

type Liveness struct {
	LatestHeartBeatTime time.Time
	// contains filtered or unexported fields
}

Liveness sync and check the status in provider

func (*Liveness) Close

func (liveness *Liveness) Close()

close because the base upload the deactive message

func (*Liveness) IsDead

func (liveness *Liveness) IsDead() bool

close by deactive message or timeout for module.NodeLeaseDurationSeconds, this may caused by base offline or leader changed

func (*Liveness) IsReachable

func (liveness *Liveness) IsReachable() bool

unReachable check the node is unreachable

func (*Liveness) UpdateHeartBeatTime

func (liveness *Liveness) UpdateHeartBeatTime()

type VNode

type VNode struct {
	Liveness Liveness // Liveness of the node from provider
	// contains filtered or unexported fields
}

VNode is the main struct for a virtual node

func NewVNode

func NewVNode(config *model.BuildVNodeConfig, tunnel tunnel.Tunnel) (kn *VNode, err error)

NewVNode creates a new virtual node

func (*VNode) AddKnowPod

func (vNode *VNode) AddKnowPod(pod *corev1.Pod)

AddKnowPod stores the pod in the node

func (*VNode) CheckAndUpdatePodStatus

func (vNode *VNode) CheckAndUpdatePodStatus(ctx context.Context, key string, pod *corev1.Pod)

CheckAndUpdatePodStatus checks and updates a pod in the node

func (*VNode) DeleteKnownPod

func (vNode *VNode) DeleteKnownPod(key string)

DeleteKnownPod deletes a pod from the node

func (*VNode) DeletePodsFromKubernetesForget

func (vNode *VNode) DeletePodsFromKubernetesForget(ctx context.Context, key string)

DeletePodsFromKubernetesForget deletes pods from Kubernetes in the node

func (*VNode) Done

func (vNode *VNode) Done() <-chan struct{}

Done returns a channel that will be closed when the vnode has exited.

func (*VNode) Err

func (vNode *VNode) Err() error

Err returns err which causes vnode exit

func (*VNode) ExitWhenLeaderChanged

func (vNode *VNode) ExitWhenLeaderChanged() <-chan struct{}

ExitWhenLeaderChanged returns a channel that will be closed when the vnode leader changed

func (*VNode) GetKnownPod

func (vNode *VNode) GetKnownPod(key string) (any, bool)

func (*VNode) GetLease

func (vNode *VNode) GetLease() *coordinationv1.Lease

func (*VNode) GetNodeName

func (vNode *VNode) GetNodeName() string

func (*VNode) IsLeader

func (vNode *VNode) IsLeader(clientId string) bool

IsLeader returns a bool marked current vnode is leader or not

func (*VNode) IsReady

func (vNode *VNode) IsReady() (bool, error)

func (*VNode) Run

func (vNode *VNode) Run(ctx context.Context, initData model.NodeInfo)

Run is the main function for a virtual node

func (*VNode) Shutdown

func (vNode *VNode) Shutdown()

Shutdown is the func of shutting down a vnode when base exit

func (*VNode) StartLeaderElection

func (vNode *VNode) StartLeaderElection(ctx context.Context, clientID string)

StartLeaderElection renews the lease of the node

func (*VNode) SyncAllContainerInfo

func (vNode *VNode) SyncAllContainerInfo(ctx context.Context, infos []model.BizStatusData)

SyncAllContainerInfo syncs the status of all containers

func (*VNode) SyncNodeStatus

func (vNode *VNode) SyncNodeStatus(data model.NodeStatusData)

SyncNodeStatus syncs the status of the node

func (*VNode) SyncOneContainerInfo

func (vNode *VNode) SyncOneContainerInfo(ctx context.Context, bizStatusData model.BizStatusData)

SyncOneContainerInfo syncs the status of a single container

func (*VNode) SyncPodsFromKubernetesEnqueue

func (vNode *VNode) SyncPodsFromKubernetesEnqueue(ctx context.Context, key string)

SyncPodsFromKubernetesEnqueue syncs pods from Kubernetes to the node

func (*VNode) WaitReady

func (vNode *VNode) WaitReady(ctx context.Context, timeout time.Duration) error

WaitReady waits for the node to be ready

type VNodeProvider

type VNodeProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

VNodeProvider is a struct that implements the NodeProvider interface.

func NewVNodeProvider

func NewVNodeProvider(config *model.BuildVNodeConfig) *VNodeProvider

NewVNodeProvider creates a new VNodeProvider instance.

func (*VNodeProvider) Notify

func (v *VNodeProvider) Notify(data model.NodeStatusData)

Notify updates the latest node status data and notifies about the change.

func (*VNodeProvider) NotifyNodeStatus

func (v *VNodeProvider) NotifyNodeStatus(_ context.Context, cb func(*corev1.Node))

NotifyNodeStatus sets a callback function to notify about node status changes.

func (*VNodeProvider) Ping

func (v *VNodeProvider) Ping(_ context.Context) error

Ping checks the health of the node provider.

type VNodeStore

type VNodeStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

VNodeStore provide the in memory runtime information.

func NewVNodeStore

func NewVNodeStore() *VNodeStore

NewVNodeStore creates a new instance of VNodeStore.

func (*VNodeStore) AddVNode

func (r *VNodeStore) AddVNode(nodeName string, vnode *VNode) error

AddVNode adds a VNode to the node name to VNode map.

func (*VNodeStore) AllNodeNum

func (r *VNodeStore) AllNodeNum() int

AllNodeNum returns the number of all nodes.

func (*VNodeStore) DeleteVNode

func (r *VNodeStore) DeleteVNode(nodeName string)

DeleteVNode removes a VNode from the node name to VNode map.

func (*VNodeStore) GetDeadVNodes

func (r *VNodeStore) GetDeadVNodes() []*VNode

GetDeadVNodes returns the node information of nodes that are not reachable.

func (*VNodeStore) GetLeaseOccupiedVNodes

func (r *VNodeStore) GetLeaseOccupiedVNodes(clientID string) []*VNode

func (*VNodeStore) GetLeaseOutdatedVNodeNames

func (r *VNodeStore) GetLeaseOutdatedVNodeNames(clientID string) []string

GetLeaseOutdatedVNodeNames returns the node ids of outdated leases.

func (*VNodeStore) GetUnReachableVNodes

func (r *VNodeStore) GetUnReachableVNodes() []*VNode

GetUnReachableVNodes returns the node information of nodes that are not reachable.

func (*VNodeStore) GetVNode

func (r *VNodeStore) GetVNode(nodeName string) *VNode

GetVNode returns a VNode for a given node ID.

func (*VNodeStore) GetVNodeByNodeName

func (r *VNodeStore) GetVNodeByNodeName(nodeName string) *VNode

GetVNodeByNodeName returns a VNode for a given node name.

func (*VNodeStore) GetVNodes

func (r *VNodeStore) GetVNodes() []*VNode

GetVNodes returns all VNodes.

func (*VNodeStore) NodeShutdown

func (r *VNodeStore) NodeShutdown(nodeName string)

NodeShutdown removes a node from the running node map.

func (*VNodeStore) RunningNodeNum

func (r *VNodeStore) RunningNodeNum() int

RunningNodeNum returns the number of running nodes.

func (*VNodeStore) UpdateNodeStateOnProviderArrived

func (r *VNodeStore) UpdateNodeStateOnProviderArrived(nodeName string, state model.NodeState)

UpdateNodeStateOnProviderArrived updates the latest message time for a given node ID.

type VPodProvider

type VPodProvider struct {
	Namespace string
	// contains filtered or unexported fields
}

VPodProvider is a struct that implements the nodeutil.Provider and virtual_kubelet.PodNotifier interfaces

func NewVPodProvider

func NewVPodProvider(namespace, localIP, nodeName string, client client.Client, tunnel tunnel.Tunnel) *VPodProvider

NewVPodProvider is a function that creates a new VPodProvider instance

func (*VPodProvider) CreatePod

func (b *VPodProvider) CreatePod(ctx context.Context, pod *corev1.Pod) error

CreatePod is a method of VPodProvider that creates a pod

func (*VPodProvider) DeletePod

func (b *VPodProvider) DeletePod(ctx context.Context, pod *corev1.Pod) error

DeletePod is a method of VPodProvider that deletes a pod

func (*VPodProvider) GetPod

func (b *VPodProvider) GetPod(_ context.Context, namespace, name string) (*corev1.Pod, error)

GetPod is a method of VPodProvider that gets a pod This method is simply used to return the observed defaultPod by local

so the outer control loop can call CreatePod / UpdatePod / DeletePod accordingly
just return the defaultPod from the local store

func (*VPodProvider) GetPodStatus

func (b *VPodProvider) GetPodStatus(ctx context.Context, pod *corev1.Pod, bizStatus model.BizStatusData) (*corev1.PodStatus, error)

GetPodStatus is a method of VPodProvider that gets the status of a pod This will be called repeatedly by virtual kubelet framework to get the defaultPod status we should query the actual runtime info and convert them in to V1PodStatus accordingly

func (*VPodProvider) GetPods

func (b *VPodProvider) GetPods(_ context.Context) ([]*corev1.Pod, error)

func (*VPodProvider) NotifyPods

func (b *VPodProvider) NotifyPods(_ context.Context, cb func(*corev1.Pod))

NotifyPods is a method of VPodProvider that sets the notify function

func (*VPodProvider) SyncAllBizStatusToKube

func (b *VPodProvider) SyncAllBizStatusToKube(ctx context.Context, bizStatusDatas []model.BizStatusData)

SyncAllBizStatusToKube is a method of VPodProvider that synchronizes the information of all containers

func (*VPodProvider) SyncBizStatusToKube

func (b *VPodProvider) SyncBizStatusToKube(ctx context.Context, bizStatusData model.BizStatusData)

SyncBizStatusToKube is a method of VPodProvider that synchronizes the information of a single container

func (*VPodProvider) UpdatePod

func (b *VPodProvider) UpdatePod(ctx context.Context, pod *corev1.Pod) error

UpdatePod is a method of VPodProvider that updates a pod

type VPodStore

type VPodStore struct {
	sync.RWMutex // This mutex is used for thread-safe access to the store.
	// contains filtered or unexported fields
}

VPodStore provides in-memory runtime information.

func NewVPodStore

func NewVPodStore() *VPodStore

func (*VPodStore) CheckContainerStatusNeedSync

func (r *VPodStore) CheckContainerStatusNeedSync(bizStatusData model.BizStatusData) bool

func (*VPodStore) DeletePod

func (r *VPodStore) DeletePod(podKey string)

DeletePod function removes a pod from the VPodStore.

func (*VPodStore) GetPodByKey

func (r *VPodStore) GetPodByKey(podKey string) *corev1.Pod

GetPodByKey function retrieves a pod by its key.

func (*VPodStore) GetPods

func (r *VPodStore) GetPods() []*corev1.Pod

GetPods function retrieves all pods in the VPodStore.

func (*VPodStore) PutPod

func (r *VPodStore) PutPod(pod *corev1.Pod)

PutPod function updates or adds a pod to the VPodStore.

Jump to

Keyboard shortcuts

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