watch

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WaitBeforeReportEnv = "WAIT_BEFORE_REPORT"
)

Variables

View Source
var (
	FirstReportEmptyBytes  = []byte("{\"firstReport\":true}")
	FirstReportEmptyLength = len(FirstReportEmptyBytes)
)

Functions

func Clone

func Clone(src, dst interface{}) error

Clone uses "encoding/gob" package

func CreateID

func CreateID() int

func DeepCopy

func DeepCopy(src, dst interface{}) error

DeepCopy uses "encoding/json" package

func DeepCopyObj

func DeepCopyObj(src, dst interface{}) error

DeepCopyObj uses "encoding/json" package

func DeleteID

func DeleteID(id int)

func GetOwnerData

func GetOwnerData(ctx context.Context, name string, kind string, apiVersion string, namespace string, wh *WatchHandler) interface{}

GetOwnerData - get the data of pod owner

func HashByteArray

func HashByteArray(text []byte) []byte

func IDCreator

func IDCreator() int

static function

func IsPodExist

func IsPodExist(pod *core.Pod, pdm map[int]*list.List) bool

IsPodExist check

func NewJsonFormat added in v0.1.26

func NewJsonFormat() jsonFormat

func RemoveNode

func RemoveNode(node *core.Node, ndm map[int]*list.List) string

func WaitTillNewDataArrived

func WaitTillNewDataArrived(wh *WatchHandler) bool

WaitTillNewDataArrived -

Types

type CRDOwnerData

type CRDOwnerData struct {
	metav1.TypeMeta
}

type DataSocket

type DataSocket struct {
	RType ReqType
	// contains filtered or unexported fields
}

type EventObjectData added in v0.1.26

type EventObjectData struct {
	sync.Map
	ProcessedData []string `json:"-"`
}

func NewEventObjectData added in v0.1.26

func NewEventObjectData() EventObjectData

func (*EventObjectData) MarshalJSON added in v0.1.26

func (e *EventObjectData) MarshalJSON() ([]byte, error)

type EventProcessor

type EventProcessor interface {
	ProcessEventData(data []byte)
}

EventProcessor to process data

type IDDataBase

type IDDataBase struct {
	Ids   *list.List
	Mutex sync.RWMutex
	// contains filtered or unexported fields
}

type JsonType

type JsonType int
const (
	NODE          JsonType = 1
	SERVICES      JsonType = 2
	MICROSERVICES JsonType = 3
	PODS          JsonType = 4
	SECRETS       JsonType = 5
	NAMESPACES    JsonType = 6
)

type MicroServiceData

type MicroServiceData struct {
	*core.Pod `json:",inline"`
	Owner     OwnerDet `json:"uptreeOwner"`
	PodSpecId int      `json:"podSpecId"`
}

type NodeData

type NodeData struct {
	// core.NodeSystemInfo
	core.NodeStatus `json:",inline"`
	Name            string    `json:"name"`
	UID             types.UID `json:"uid"`
	ResourceVersion string    `json:"resourceVersion"`
}

func UpdateNode

func UpdateNode(node *core.Node, ndm map[int]*list.List) *NodeData

func (*NodeData) UpdateNodeData

func (updateNode *NodeData) UpdateNodeData(node *core.Node)

type ObjectData

type ObjectData struct {
	Created EventObjectData `json:"create,omitempty"`
	Deleted EventObjectData `json:"delete,omitempty"`
	Updated EventObjectData `json:"update,omitempty"`
}

func NewObjectData added in v0.1.26

func NewObjectData() *ObjectData

func (*ObjectData) AddToJsonFormatByState

func (obj *ObjectData) AddToJsonFormatByState(NewData interface{}, stype StateType)

type OwnerDet

type OwnerDet struct {
	Name      string      `json:"name"`
	Kind      string      `json:"kind"`
	OwnerData interface{} `json:"ownerData,omitempty"`
}

func GetAncestorFromLocalPodsList

func GetAncestorFromLocalPodsList(pod *core.Pod, wh *WatchHandler) (*OwnerDet, error)

func GetAncestorOfPod

func GetAncestorOfPod(ctx context.Context, pod *core.Pod, wh *WatchHandler) (OwnerDet, error)

type OwnerDetNameAndKindOnly

type OwnerDetNameAndKindOnly struct {
	Name string `json:"name"`
	Kind string `json:"kind"`
}

type PodDataForExistMicroService

type PodDataForExistMicroService struct {
	UID               types.UID               `json:"uid"`
	ResourceVersion   string                  `json:"resourceVersion"`
	PodName           string                  `json:"podName"`
	NodeName          string                  `json:"nodeName"`
	PodIP             string                  `json:"podIP"`
	Namespace         string                  `json:"namespace,omitempty"`
	Owner             OwnerDetNameAndKindOnly `json:"uptreeOwner"`
	PodStatus         string                  `json:"podStatus"`
	CreationTimestamp string                  `json:"startedAt"`
	DeletionTimestamp string                  `json:"terminatedAt,omitempty"`
}

type ReqType

type ReqType int
const (
	PING    ReqType = 0
	MESSAGE ReqType = 1
	EXIT    ReqType = 2
)

type ScanNewImageData

type ScanNewImageData struct {
	Pod        *core.Pod
	Owner      *OwnerDet
	PodsNumber int
}

type StateType

type StateType int
const (
	CREATED StateType = 1
	DELETED StateType = 2
	UPDATED StateType = 3
)

type WatchHandler

type WatchHandler struct {
	RestAPIClient   kubernetes.Interface
	K8sApi          *k8sinterface.KubernetesApi
	WebSocketHandle *WebSocketHandler
	// contains filtered or unexported fields
}

func CreateWatchHandler

func CreateWatchHandler(config config.IConfig) (*WatchHandler, error)

func (*WatchHandler) Cancel added in v0.1.26

func (wh *WatchHandler) Cancel()

func (*WatchHandler) CheckInstanceMetadataAPIVendor added in v0.1.26

func (wh *WatchHandler) CheckInstanceMetadataAPIVendor() string

func (*WatchHandler) ClusterVersion added in v0.1.26

func (wh *WatchHandler) ClusterVersion() *version.Info

func (*WatchHandler) CronJobWatch

func (wh *WatchHandler) CronJobWatch(ctx context.Context)

CronJobWatch watch over services

func (*WatchHandler) DeletePod

func (wh *WatchHandler) DeletePod(ctx context.Context, pod *core.Pod, podName string)

DeletePod delete a pod

func (*WatchHandler) ListenAndProcess

func (wh *WatchHandler) ListenAndProcess(ctx context.Context, processor EventProcessor)

func (*WatchHandler) NamespaceEventHandler

func (wh *WatchHandler) NamespaceEventHandler(ctx context.Context, event *watch.Event, lastWatchEventCreationTime time.Time) error

func (*WatchHandler) NamespaceWatch

func (wh *WatchHandler) NamespaceWatch(ctx context.Context)

namespaceWatch watch over namespaces

func (*WatchHandler) NodeWatch

func (wh *WatchHandler) NodeWatch(ctx context.Context)

NodeWatch Watching over nodes

func (*WatchHandler) PodWatch

func (wh *WatchHandler) PodWatch(ctx context.Context)

PodWatch - an infinite loop which will observe changes in pods and acts accordingly

func (*WatchHandler) RemoveNamespace

func (wh *WatchHandler) RemoveNamespace(namespace *corev1.Namespace) string

RemoveNamespace update websocket when namespace is removed

func (*WatchHandler) RemovePod

func (wh *WatchHandler) RemovePod(pod *core.Pod, pdm map[int]*list.List) (int, bool, OwnerDet)

RemovePod remove pod and check if has parents. Returns 3 elements: 1. pod spec ID, 2. is owner removed, 3. owner

func (*WatchHandler) Reset added in v0.1.26

func (wh *WatchHandler) Reset()

func (*WatchHandler) RetrieveClusterInfo added in v0.1.26

func (wh *WatchHandler) RetrieveClusterInfo()

func (*WatchHandler) SecretWatch

func (wh *WatchHandler) SecretWatch(ctx context.Context)

SecretWatch watch over secrets

func (*WatchHandler) SendMessageToWebSocket

func (wh *WatchHandler) SendMessageToWebSocket(jsonData []byte)

func (*WatchHandler) ServiceWatch

func (wh *WatchHandler) ServiceWatch(ctx context.Context)

ServiceWatch watch over services

func (*WatchHandler) SetFirstReportFlag

func (wh *WatchHandler) SetFirstReportFlag(first bool)

SetFirstReportFlag set first report flag

func (*WatchHandler) UpdateNamespace

func (wh *WatchHandler) UpdateNamespace(namespace *corev1.Namespace)

UpdateNamespace update websocket when namespace is updated

type WebSocketHandler

type WebSocketHandler struct {
	SignalChan chan os.Signal
	// contains filtered or unexported fields
}

func (*WebSocketHandler) SendReportRoutine

func (wsh *WebSocketHandler) SendReportRoutine(ctx context.Context, isServerReady *bool, reconnectCallback func(bool)) error

SendReportRoutine function sending updates

type WebSocketProcessor

type WebSocketProcessor struct {
	WatchHandler *WatchHandler
}

func (*WebSocketProcessor) ProcessEventData

func (wsh *WebSocketProcessor) ProcessEventData(data []byte)

Jump to

Keyboard shortcuts

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