utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 32 Imported by: 5

Documentation

Index

Constants

View Source
const NoiseLogLel = 5

NoiseLogLel - information inside "important functions"

View Source
const QuiteLogLel = 4

QuiteLogLel - "important" information

View Source
const VeryNoisy = 10

VeryNoisy = show call stack, routine and everything

Variables

View Source
var ClusterPredicateFunc = predicate.Funcs{
	UpdateFunc: func(e event.UpdateEvent) bool {
		oldcl := e.ObjectOld.(*clusterv1alpha1.Cluster)
		newcl := e.ObjectNew.(*clusterv1alpha1.Cluster)

		if !reflect.DeepEqual(oldcl.Labels, newcl.Labels) {
			return true
		}

		oldcondMap := make(map[clusterv1alpha1.ClusterConditionType]corev1.ConditionStatus)
		for _, cond := range oldcl.Status.Conditions {
			oldcondMap[cond.Type] = cond.Status
		}
		for _, cond := range newcl.Status.Conditions {
			oldcondst, ok := oldcondMap[cond.Type]
			if !ok || oldcondst != cond.Status {
				return true
			}
			delete(oldcondMap, cond.Type)
		}

		if len(oldcondMap) > 0 {
			return true
		}

		klog.V(10).Info("Out Cluster Predicate Func ", oldcl.Name, " with false possitive")
		return false
	},
}

ClusterPredicateFunc defines predicate function for cluster related watch, main purpose is to ignore heartbeat without change

Functions

func CheckAndInstallCRD

func CheckAndInstallCRD(crdconfig *rest.Config, pathname string) error

CheckAndInstallCRD checks if deployable belongs to this cluster managed cluster annotation matches or no managed cluster annotation (local)

func ConvertLabels

func ConvertLabels(labelSelector *metav1.LabelSelector) (labels.Selector, error)

ConvertLabels coverts label selector to lables.Selector

func DetectClusterRegistry

func DetectClusterRegistry(clReader client.Reader, s <-chan struct{})

DetectClusterRegistry - Detect the ACM cluster API service every 10 seconds. the controller will be exited when it is ready The controller will be auto restarted by the multicluster-operators-application deployment CR later.

func EnterFnString

func EnterFnString() string

EnterFnString - called when enter a function

func ExitFuString

func ExitFuString(s string)

ExitFuString - called when exiting a function

func FilteClustersByIdentity

func FilteClustersByIdentity(authClient kubernetes.Interface, object runtime.Object, clmap map[string]*clusterv1alpha1.Cluster) error

func GetFnName

func GetFnName() string

GetFnName - get name of function

func InstanceDeepCopy

func InstanceDeepCopy(a, b interface{}) error

func IsReadyACMClusterRegistry

func IsReadyACMClusterRegistry(clReader client.Reader) bool

IsReadyACMClusterRegistry check if ACM Cluster API service is ready or not.

func PlaceByGenericPlacmentFields

func PlaceByGenericPlacmentFields(kubeclient client.Client, placement appv1alpha1.GenericPlacementFields,
	authclient kubernetes.Interface, object runtime.Object) (map[string]*clusterv1alpha1.Cluster, error)

PlaceByGenericPlacmentFields search with basic placement criteria Top priority: clusterNames, ignore selector Bottomline: Use label selector

func ToPlaceLocal

func ToPlaceLocal(placement *appv1alpha1.Placement) bool

Types

type EventRecorder

type EventRecorder struct {
	record.EventRecorder
}

EventRecorder - record kubernetes event

func NewEventRecorder

func NewEventRecorder(cfg *rest.Config, scheme *apiruntime.Scheme) (*EventRecorder, error)

NewEventRecorder - create new event recorder from rect config

func (*EventRecorder) RecordEvent

func (rec *EventRecorder) RecordEvent(obj apiruntime.Object, reason, msg string, err error)

RecordEvent - record kuberentes event

Jump to

Keyboard shortcuts

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