utils

package
v1.31.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 34 Imported by: 68

Documentation

Overview

Package utils contains shared data structures and functions.

Index

Constants

View Source
const (
	// Add used to record additions in a sync pool.
	Add = iota
	// Remove used to record removals from a sync pool.
	Remove
	// Sync used to record syncs of a sync pool.
	Sync
	// Get used to record Get from a sync pool.
	Get
	// Create used to record creations in a sync pool.
	Create
	// Update used to record updates in a sync pool.
	Update
	// Delete used to record deletions from a sync pool.
	Delete
	// AddInstances used to record a call to AddInstances.
	AddInstances
	// RemoveInstances used to record a call to RemoveInstances.
	RemoveInstances
	// LabelNodeRoleMaster specifies that a node is a master
	// This is a duplicate definition of the constant in:
	// kubernetes/kubernetes/pkg/controller/service/service_controller.go
	LabelNodeRoleMaster = "node-role.kubernetes.io/master"
	// LabelNodeRoleExcludeBalancer specifies that a node should be excluded from load-balancing
	// This is a duplicate definition of the constant in kubernetes core:
	//  https://github.com/kubernetes/kubernetes/blob/ea0764452222146c47ec826977f49d7001b0ea8c/staging/src/k8s.io/api/core/v1/well_known_labels.go#L67
	LabelNodeRoleExcludeBalancer = "node.kubernetes.io/exclude-from-external-load-balancers"
	// ToBeDeletedTaint is the taint that the autoscaler adds when a node is scheduled to be deleted
	// https://github.com/kubernetes/autoscaler/blob/cluster-autoscaler-0.5.2/cluster-autoscaler/utils/deletetaint/delete.go#L33
	ToBeDeletedTaint = "ToBeDeletedByClusterAutoscaler"
	// GKECurrentOperationLabel is added by the GKE control plane, to nodes that are about to be drained as a result of an upgrade/resize operation.
	// The operation value is "drain".
	GKECurrentOperationLabel = "operation.gke.io/type"
	// NodeDrain is the string used to indicate the Node Draining operation.
	NodeDrain               = "drain"
	L4ILBServiceDescKey     = "networking.gke.io/service-name"
	L4LBSharedResourcesDesc = "This resource is shared by all L4 %s Services using ExternalTrafficPolicy: Cluster."

	// LabelAlphaNodeRoleExcludeBalancer specifies that the node should be
	// exclude from load balancers created by a cloud provider. This label is deprecated and will
	// be removed in 1.18.
	LabelAlphaNodeRoleExcludeBalancer = "alpha.service-controller.kubernetes.io/exclude-balancer"
	DualStackSubnetStackType          = "IPV4_IPV6"

	// LabelNodeSubnet specifies the subnet name of this node.
	LabelNodeSubnet = "cloud.google.com/gke-node-pool-subnet"
)

Variables

Functions

func AddIPToLBStatus added in v1.21.0

func AddIPToLBStatus(status *api_v1.LoadBalancerStatus, ips ...string) *api_v1.LoadBalancerStatus

func BetaToAlphaHealthCheck added in v1.10.0

func BetaToAlphaHealthCheck(hc *computebeta.HealthCheck) (*computealpha.HealthCheck, error)

BetaToAlphaHealthCheck converts beta health check to alpha health check. There should be no information lost after conversion.

func DeepCopyComputeHealthCheck added in v1.23.0

func DeepCopyComputeHealthCheck(src *compute.HealthCheck) *compute.HealthCheck

func EqualCloudResourceIDs added in v1.28.0

func EqualCloudResourceIDs(a, b *cloud.ResourceID) bool

EqualCloudResourceIDs returns true if a and b have equal ResourceIDs which entail the project, location, resource type, and resource name.

func EqualMapping added in v1.2.2

func EqualMapping(a, b *GCEURLMap) bool

EqualMapping returns true if both maps point to the same ServicePortIDs. ServicePort settings are *not* included in this comparison.

func EqualResourceIDs added in v1.2.2

func EqualResourceIDs(a, b string) bool

EqualResourceIDs returns true if a and b have equal ResourceIDs which entail the project, location, resource type, and resource name.

func EqualResourcePaths added in v1.2.2

func EqualResourcePaths(a, b string) bool

EqualResourcePaths returns true if a and b have equal ResourcePaths. Resource paths entail the location, resource type, and resource name.

func EqualStringSets added in v1.9.0

func EqualStringSets(x, y []string) bool

EqualStringSets returns true if 2 given string slices contain the same elements, in any order.

func GetBasePath added in v1.13.0

func GetBasePath(cloud *gce.Cloud) string

GetBasePath returns the compute API endpoint with the `projects/<project-id>` element compute API v0.36 changed basepath and dropped the `projects/` suffix, therefore suffix must be added back when generating compute resource urls.

func GetDomainFromGABasePath added in v1.30.0

func GetDomainFromGABasePath(basePath string) string

GetDomainFromGABasePath takes a GA base path of the form <path>/compute/v1 and returns the path.

func GetErrorType added in v1.11.2

func GetErrorType(err error) string

func GetNetworkTier added in v1.15.0

func GetNetworkTier(service *api_v1.Service) (cloud.NetworkTier, bool)

GetNetworkTier returns Network Tier from service and stays if this is a service annotation. If the annotation is not present then default Network Tier is returned.

func GetNodeNames added in v1.30.0

func GetNodeNames(nodes []*api_v1.Node) []string

GetNodeNames extracts names from the given nodes

func GetNodePrimaryIP added in v1.9.0

func GetNodePrimaryIP(inputNode *api_v1.Node, logger klog.Logger) string

GetNodePrimaryIP returns a primary internal IP address of the node.

func GetPortRanges added in v1.9.0

func GetPortRanges(ports []int) (ranges []string)

GetPortRanges returns a list of port ranges, given a list of ports.

func GetPorts added in v1.20.0

func GetPorts(svcPorts []api_v1.ServicePort) []string

func GetProtocol added in v1.20.0

func GetProtocol(svcPorts []api_v1.ServicePort) api_v1.Protocol

func GetServicePortRanges added in v1.20.0

func GetServicePortRanges(svcPorts []api_v1.ServicePort) []string

func HasL4NetLBFinalizerV2 added in v1.16.0

func HasL4NetLBFinalizerV2(svc *api_v1.Service) bool

HasL4NetLBFinalizerV2 returns true if the given Service has NetLBFinalizerV2

func HasVIP added in v1.8.0

func HasVIP(ing *networkingv1.Ingress) bool

HasVIP returns true if given ingress has a vip.

func IPv4ServiceSourceRanges added in v1.21.0

func IPv4ServiceSourceRanges(service *v1.Service) ([]string, error)

func IPv6ServiceSourceRanges added in v1.21.0

func IPv6ServiceSourceRanges(service *v1.Service) ([]string, error)

func IgnoreHTTPNotFound

func IgnoreHTTPNotFound(err error) error

IgnoreHTTPNotFound returns the passed err if it's not a GoogleAPI error with a NotFound status code.

func IsForbiddenError

func IsForbiddenError(err error) bool

IsForbiddenError returns true if the operation was forbidden

func IsGCEIngress added in v1.3.0

func IsGCEIngress(ing *networkingv1.Ingress) bool

IsGCEIngress returns true if the Ingress matches the class managed by this controller.

func IsGCEL7ILBIngress added in v1.7.0

func IsGCEL7ILBIngress(ing *networkingv1.Ingress) bool

IsGCEL7ILBIngress returns true if the given Ingress has ingress.class annotation set to "gce-l7-ilb"

func IsGCEL7XLBRegionalIngress added in v1.26.0

func IsGCEL7XLBRegionalIngress(ing *networkingv1.Ingress) bool

IsGCEL7XLBRegionalIngress returns true if the given Ingress has ingress.class annotation set to "gce-regional-external"

func IsGCEMultiClusterIngress added in v1.3.0

func IsGCEMultiClusterIngress(ing *networkingv1.Ingress) bool

IsGCEMultiClusterIngress returns true if the given Ingress has ingress.class annotation set to "gce-multi-cluster".

func IsGCEServerError added in v1.24.0

func IsGCEServerError(err error) bool

IsGCEServerError returns true if the error is GCE server error

func IsGLBCIngress added in v1.3.2

func IsGLBCIngress(ing *networkingv1.Ingress) bool

IsGLBCIngress returns true if the given Ingress should be processed by GLBC

func IsHTTPErrorCode

func IsHTTPErrorCode(err error, code int) bool

IsHTTPErrorCode checks if the given error matches the given HTTP Error code. For this to work the error must be a googleapi Error.

func IsIPConfigurationError added in v1.20.3

func IsIPConfigurationError(err error) bool

IsIPConfigurationError checks if wrapped error is an IP configuration error.

func IsInUsedByError

func IsInUsedByError(err error) bool

IsInUsedByError returns true if the resource is being used by another GCP resource

func IsInvalidLoadBalancerSourceRangesAnnotationError added in v1.21.0

func IsInvalidLoadBalancerSourceRangesAnnotationError(err error) bool

IsInvalidLoadBalancerSourceRangesAnnotationError checks if wrapped error is an InvalidLoadBalancerSourceRangesAnnotationError error.

func IsInvalidLoadBalancerSourceRangesSpecError added in v1.21.0

func IsInvalidLoadBalancerSourceRangesSpecError(err error) bool

IsInvalidLoadBalancerSourceRangesSpecError checks if wrapped error is an InvalidLoadBalancerSourceRangesSpecError error.

func IsK8sServerError added in v1.24.0

func IsK8sServerError(err error) bool

IsK8sServerError returns true if the error is K8s server error

func IsLegacyL4ILBService added in v1.9.0

func IsLegacyL4ILBService(svc *api_v1.Service) bool

IsLegacyL4ILBService returns true if the given LoadBalancer service is managed by service controller.

func IsLoadBalancerServiceType added in v1.19.1

func IsLoadBalancerServiceType(service *api_v1.Service) bool

IsLoadBalancerServiceType checks if kubernetes service is type of LoadBalancer.

func IsMemberAlreadyExistsError added in v1.28.10

func IsMemberAlreadyExistsError(err error) bool

func IsNetworkTierError added in v1.17.0

func IsNetworkTierError(err error) bool

IsNetworkTierError checks if wrapped error is a Network Tier Mismatch error

func IsNetworkTierMismatchGCEError added in v1.17.0

func IsNetworkTierMismatchGCEError(err error) bool

IsNetworkTierMismatchGCEError checks if error is a GCE network tier mismatch for external IP

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if the resource does not exist

func IsQuotaExceededError added in v1.24.0

func IsQuotaExceededError(err error) bool

IsQuotaExceededError returns true if the quota was exceeded

func IsSubsettingL4ILBService added in v1.11.7

func IsSubsettingL4ILBService(svc *api_v1.Service) bool

IsSubsettingL4ILBService returns true if the given LoadBalancer service is managed by NEG and L4 controller.

func IsUnsupportedFeatureError added in v1.25.0

func IsUnsupportedFeatureError(err error, featureName string) bool

IsUnsupportedFeatureError returns true if the error has 400 number, and has information that `featureName` isn't supported

ex: ```Error 400: Invalid value for field
resource.connectionTrackingPolicy.enableStrongAffinity': 'true'.
EnableStrongAffinity is not supported., invalid```

func IsUserError added in v1.17.0

func IsUserError(err error) bool

IsUserError checks if given error is cause by User. Right now User Error might be caused by Network Tier misconfiguration or specifying non-existent or already used IP address.

func JoinErrs added in v1.4.0

func JoinErrs(errs []error) error

JoinErrs returns an aggregated error based on the passed in list of errors.

func KeyName added in v1.2.2

func KeyName(url string) (string, error)

KeyName returns the name portion from a full or partial GCP resource URL. Example:

Input:  https://googleapis.com/v1/compute/projects/my-project/global/backendServices/my-backend
Output: my-backend

func LegacyForwardingRuleName added in v1.11.7

func LegacyForwardingRuleName(svc *api_v1.Service) string

func MakeL4IPv6ForwardingRuleDescription added in v1.21.0

func MakeL4IPv6ForwardingRuleDescription(service *api_v1.Service) (string, error)

func MakeL4LBFirewallDescription added in v1.17.0

func MakeL4LBFirewallDescription(svcName, ip string, version meta.Version, shared bool) (string, error)

func MakeL4LBServiceDescription added in v1.15.0

func MakeL4LBServiceDescription(svcName, ip string, version meta.Version, shared bool, lbType L4LBType) (string, error)

func MinMaxPortRange added in v1.30.4

func MinMaxPortRange[T api_v1.ServicePort | string](svcPorts []T) string

func NeedsCleanup added in v1.7.0

func NeedsCleanup(ing *networkingv1.Ingress) bool

NeedsCleanup returns true if the ingress needs to have its associated resources deleted.

func NeedsIPv4 added in v1.21.0

func NeedsIPv4(service *v1.Service) bool

func NeedsIPv6 added in v1.21.0

func NeedsIPv6(service *v1.Service) bool

func NewInt64Pointer added in v1.9.9

func NewInt64Pointer(i int64) *int64

NewInt64Pointer returns a pointer to the provided int64 literal

func NewNamespaceIndexer added in v1.3.0

func NewNamespaceIndexer() cache.Indexers

NewNamespaceIndexer returns a new Indexer for use by SharedIndexInformers

func NewStringPointer added in v1.9.0

func NewStringPointer(s string) *string

NewStringPointer returns a pointer to the provided string literal

func NodeIsReady

func NodeIsReady(node *api_v1.Node) bool

NodeIsReady returns true if a node contains at least one condition of type "Ready"

func RelativeResourceName added in v1.2.2

func RelativeResourceName(url string) (string, error)

RelativeResourceName returns the project, location, resource, and name from a full/partial GCP resource URL. This removes the endpoint prefix and version. Example:

Input:  https://googleapis.com/v1/compute/projects/my-project/global/backendServices/my-backend
Output: projects/my-project/global/backendServices/my-backend

func ResourcePath added in v1.2.2

func ResourcePath(url string) (string, error)

ResourcePath returns the location, resource and name portion from a full or partial GCP resource URL. This removes the endpoint prefix, version, and project. Example:

Input:  https://googleapis.com/v1/compute/projects/my-project/global/backendServices/my-backend
Output: global/backendServices/my-backend

func ServiceKeyFunc added in v1.4.0

func ServiceKeyFunc(namespace, name string) string

func SplitAnnotation added in v1.4.0

func SplitAnnotation(annotation string) []string

SplitAnnotation splits annotation by separator and trims whitespace from each resulting token

func SubnetHasIPv6Range added in v1.25.0

func SubnetHasIPv6Range(cloud *gce.Cloud, subnetName, ipv6AccessType string) (bool, error)

func ToBetaHealthCheck added in v1.10.0

func ToBetaHealthCheck(hc *computealpha.HealthCheck) (*computebeta.HealthCheck, error)

ToBetaHealthCheck converts alpha health check to beta health check.

func ToNamespacedName added in v1.2.2

func ToNamespacedName(s string) (r types.NamespacedName, err error)

ToNamespacedName returns a types.NamespacedName struct parsed from namespace/name.

func ToV1HealthCheck added in v1.10.0

func ToV1HealthCheck(hc *computealpha.HealthCheck) (*compute.HealthCheck, error)

ToV1HealthCheck converts alpha health check to v1 health check. WARNING: alpha health check has a additional PORT_SPECIFICATION field. This field will be omitted after conversion.

func TranslateAffinityType added in v1.9.0

func TranslateAffinityType(affinityType string, logger klog.Logger) string

TranslateAffinityType converts the k8s affinity type to the GCE affinity type.

func TraverseIngressBackends added in v1.3.2

func TraverseIngressBackends(ing *networkingv1.Ingress, process func(id ServicePortID) bool)

TraverseIngressBackends traverse thru all backends specified in the input ingress and call process If process return true, then return and stop traversing the backends

func V1ToAlphaHealthCheck added in v1.10.0

func V1ToAlphaHealthCheck(hc *compute.HealthCheck) (*computealpha.HealthCheck, error)

V1ToAlphaHealthCheck converts v1 health check to alpha health check. There should be no information lost after conversion.

func VerifyDescription added in v1.10.8

func VerifyDescription(expectDesc NegDescription, descString, negName, zone string) (bool, error)

VerifyDescription returns whether the provided descString fields match Neg Description expectDesc. If an empty string or malformed description is provided, VerifyDescription will return true. When returning false, a detailed error will also be returned

Types

type Description added in v1.2.2

type Description struct {
	ServiceName string   `json:"kubernetes.io/service-name"`
	ServicePort string   `json:"kubernetes.io/service-port"`
	XFeatures   []string `json:"x-features,omitempty"`
}

Description stores the description for a BackendService.

func DescriptionFromString added in v1.2.2

func DescriptionFromString(descString string) *Description

DescriptionFromString gets a Description from string,

func (Description) String added in v1.2.2

func (desc Description) String() string

String returns the string representation of a Description.

type FrontendGCAlgorithm added in v1.8.0

type FrontendGCAlgorithm int

FrontendGCAlgorithm species GC algorithm used for ingress frontend resources.

const (
	// NoCleanUpNeeded specifies that frontend resources need not be deleted.
	NoCleanUpNeeded FrontendGCAlgorithm = iota
	// CleanupV1FrontendResources specifies that frontend resources for ingresses
	// that use v1 naming scheme need to be deleted.
	CleanupV1FrontendResources
	// CleanupV2FrontendResources specifies that frontend resources for ingresses
	// that use v2 naming scheme need to be deleted.
	CleanupV2FrontendResources
	// CleanupV2FrontendResourcesScopeChange specifies that frontend resources for ingresses
	// that use v2 naming scheme and have changed their LB scope (e.g. ILB -> ELB or vice versa)
	// need to be deleted
	CleanupV2FrontendResourcesScopeChange
)

type GCEURLMap

type GCEURLMap struct {
	DefaultBackend *ServicePort
	// HostRules is an ordered list of hostnames, path rule tuples.
	HostRules []HostRule
	// contains filtered or unexported fields
}

GCEURLMap is a simplified representation of a UrlMap somewhere in the middle of a compute.UrlMap and rules in an Ingress spec. This representation maintains three invariants/rules:

  1. All hostnames are unique
  2. All paths for a specific host are unique.
  3. Adding paths for a hostname replaces existing for that host.

func NewGCEURLMap added in v1.2.2

func NewGCEURLMap(logger klog.Logger) *GCEURLMap

NewGCEURLMap returns an empty GCEURLMap

func (*GCEURLMap) AllServicePorts added in v1.2.2

func (g *GCEURLMap) AllServicePorts() (svcPorts []ServicePort)

AllServicePorts return a list of all ServicePorts contained in the GCEURLMap.

func (*GCEURLMap) HostExists added in v1.2.2

func (g *GCEURLMap) HostExists(hostname string) bool

HostExists returns true if the given hostname is specified in the GCEURLMap.

func (*GCEURLMap) PathExists added in v1.2.2

func (g *GCEURLMap) PathExists(hostname, path string) (ServicePort, bool)

PathExists returns true if the given path exists for the given hostname. It will also return the backend associated with that path.

func (*GCEURLMap) PutPathRulesForHost added in v1.2.2

func (g *GCEURLMap) PutPathRulesForHost(hostname string, pathRules []PathRule)

PutPathRulesForHost adds path rules for a single hostname. This function ensures the invariants of the GCEURLMap are maintained. It will log if an invariant violation was found and reconciled. TODO(rramkumar): Surface an error instead of logging.

func (*GCEURLMap) String

func (g *GCEURLMap) String() string

String dumps a readable version of the GCEURLMap.

type HostRule added in v1.3.0

type HostRule struct {
	Hostname string
	Paths    []PathRule
}

HostRule encapsulates the Hostname and its list of PathRules.

type IPConfigurationError added in v1.20.3

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

IPConfigurationError is a struct to define error caused by User misconfiguration the Load Balancer IP.

func NewIPConfigurationError added in v1.20.3

func NewIPConfigurationError(ip, reason string) *IPConfigurationError

func (*IPConfigurationError) Error added in v1.20.3

func (e *IPConfigurationError) Error() string

type InvalidLoadBalancerSourceRangesAnnotationError added in v1.21.0

type InvalidLoadBalancerSourceRangesAnnotationError struct {
	LoadBalancerSourceRangesAnnotation string
	ParseErr                           error
}

InvalidLoadBalancerSourceRangesAnnotationError is a struct to define error caused by User misconfiguration of the Service.Annotations["service.beta.kubernetes.io/load-balancer-source-ranges"] field.

func NewInvalidLoadBalancerSourceRangesAnnotationError added in v1.21.0

func NewInvalidLoadBalancerSourceRangesAnnotationError(serviceLoadBalancerSourceRangesAnnotation string, err error) *InvalidLoadBalancerSourceRangesAnnotationError

func (*InvalidLoadBalancerSourceRangesAnnotationError) Error added in v1.21.0

type InvalidLoadBalancerSourceRangesSpecError added in v1.21.0

type InvalidLoadBalancerSourceRangesSpecError struct {
	LoadBalancerSourceRangesSpec []string
	ParseErr                     error
}

InvalidLoadBalancerSourceRangesSpecError is a struct to define error caused by User misconfiguration of the Service.Spec.LoadBalancerSourceRanges field.

func NewInvalidSpecLoadBalancerSourceRangesError added in v1.21.0

func NewInvalidSpecLoadBalancerSourceRangesError(specLoadBalancerSourceRanges []string, err error) *InvalidLoadBalancerSourceRangesSpecError

func (*InvalidLoadBalancerSourceRangesSpecError) Error added in v1.21.0

type L4LBResourceDescription added in v1.15.0

type L4LBResourceDescription struct {
	// ServiceName indicates the name of the service the resource is for.
	ServiceName string `json:"networking.gke.io/service-name"`
	// APIVersion stores the version og the compute API used to create this resource.
	APIVersion          meta.Version `json:"networking.gke.io/api-version,omitempty"`
	ServiceIP           string       `json:"networking.gke.io/service-ip,omitempty"`
	ResourceDescription string       `json:"networking.gke.io/resource-description,omitempty"`
}

L4LBResourceDescription stores the description fields for L4 ILB or NetLB resources. This is useful to identify which resources correspond to which L4 LB service.

func (*L4LBResourceDescription) Marshal added in v1.15.0

func (d *L4LBResourceDescription) Marshal() (string, error)

Marshal returns the description as a JSON-encoded string.

func (*L4LBResourceDescription) Unmarshal added in v1.15.0

func (d *L4LBResourceDescription) Unmarshal(desc string) error

Unmarshal converts the JSON-encoded description string into the struct.

type L4LBType added in v1.15.0

type L4LBType int

L4LBType indicates if L4 LoadBalancer is Internal or External

const (
	ILB L4LBType = iota
	XLB
)

func (L4LBType) ToString added in v1.15.0

func (lbType L4LBType) ToString() string

type NegDescription added in v1.10.0

type NegDescription struct {
	ClusterUID  string `json:"cluster-uid,omitempty"`
	Namespace   string `json:"namespace,omitempty"`
	ServiceName string `json:"service-name,omitempty"`
	Port        string `json:"port,omitempty"`
}

Description stores the description for a BackendService.

func NegDescriptionFromString added in v1.10.0

func NegDescriptionFromString(descString string) (*NegDescription, error)

DescriptionFromString gets a Description from string,

func (NegDescription) String added in v1.10.0

func (desc NegDescription) String() string

String returns the string representation of a Description.

type NetworkTierError added in v1.17.0

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

NetworkTierError is a struct to define error caused by User misconfiguration of Network Tier.

func NewNetworkTierErr added in v1.17.0

func NewNetworkTierErr(resourceInErr, desired, received string) *NetworkTierError

func (*NetworkTierError) Error added in v1.17.0

func (e *NetworkTierError) Error() string

Error function prints out Network Tier error.

type PathRule added in v1.2.2

type PathRule struct {
	Path    string
	Backend ServicePort
}

PathRule encapsulates the information for a single path -> backend mapping.

type PeriodicTaskQueue

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

PeriodicTaskQueue invokes the given sync function for every work item inserted. If the sync() function results in an error, the item is put on the work queue after a rate-limit.

func NewPeriodicTaskQueue

func NewPeriodicTaskQueue(name, resource string, syncFn func(string) error, logger klog.Logger) *PeriodicTaskQueue

NewPeriodicTaskQueue creates a new task queue with the default rate limiter.

func NewPeriodicTaskQueueWithLimiter added in v1.4.0

func NewPeriodicTaskQueueWithLimiter(name, resource string, syncFn func(string) error, rl workqueue.RateLimiter, logger klog.Logger) *PeriodicTaskQueue

NewPeriodicTaskQueueWithLimiter creates a new task queue with the given sync function and rate limiter. The sync function is called for every element inserted into the queue.

func (*PeriodicTaskQueue) Enqueue

func (t *PeriodicTaskQueue) Enqueue(objs ...interface{})

Enqueue adds one or more keys to the work queue.

func (*PeriodicTaskQueue) Len added in v1.11.0

func (t *PeriodicTaskQueue) Len() int

Len returns the length of the queue.

func (*PeriodicTaskQueue) NumRequeues added in v1.11.0

func (t *PeriodicTaskQueue) NumRequeues(obj interface{}) int

NumRequeues returns the number of times the given item was requeued.

func (*PeriodicTaskQueue) Run

func (t *PeriodicTaskQueue) Run()

Run runs the task queue. This will block until the Shutdown() has been called.

func (*PeriodicTaskQueue) Shutdown

func (t *PeriodicTaskQueue) Shutdown()

Shutdown shuts down the work queue and waits for the worker to ACK

type PeriodicTaskQueueWithMultipleWorkers added in v1.11.0

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

PeriodicTaskQueueWithMultipleWorkers invokes the given sync function for every work item inserted, while running n parallel worker routines. If the sync() function results in an error, the item is put on the work queue after a rate-limit.

func NewPeriodicTaskQueueWithMultipleWorkers added in v1.11.0

func NewPeriodicTaskQueueWithMultipleWorkers(name, resource string, numWorkers int, syncFn func(string) error, logger klog.Logger) *PeriodicTaskQueueWithMultipleWorkers

NewPeriodicTaskQueueWithMultipleWorkers creates a new task queue with the default rate limiter and the given number of worker goroutines.

func (*PeriodicTaskQueueWithMultipleWorkers) Enqueue added in v1.11.0

func (t *PeriodicTaskQueueWithMultipleWorkers) Enqueue(objs ...interface{})

Enqueue adds one or more keys to the work queue.

func (*PeriodicTaskQueueWithMultipleWorkers) Len added in v1.11.0

Len returns the length of the queue.

func (*PeriodicTaskQueueWithMultipleWorkers) NumRequeues added in v1.11.0

func (t *PeriodicTaskQueueWithMultipleWorkers) NumRequeues(obj interface{}) int

NumRequeues returns the number of times the given item was requeued.

func (*PeriodicTaskQueueWithMultipleWorkers) Run added in v1.11.0

Run spawns off n parallel worker routines and returns immediately.

func (*PeriodicTaskQueueWithMultipleWorkers) Shutdown added in v1.11.0

Shutdown shuts down the work queue and waits for all the workers to ACK

type ServicePort added in v1.2.2

type ServicePort struct {
	// Ingress backend-specified service name and port
	ID ServicePortID

	NodePort int64
	// Numerical port of the Service, retrieved from the Service
	Port int32
	// Name of the port of the Service, retrieved from the Service
	PortName             string
	Protocol             annotations.AppProtocol
	TargetPort           intstr.IntOrString
	NEGEnabled           bool
	VMIPNEGEnabled       bool
	L4RBSEnabled         bool
	L7ILBEnabled         bool
	L7XLBRegionalEnabled bool
	THCConfiguration     THCConfiguration
	BackendConfig        *backendconfigv1.BackendConfig
	BackendNamer         namer.BackendNamer
	// Traffic policy fields that apply if non-nil.
	MaxRatePerEndpoint *float64
	CapacityScaler     *float64
}

ServicePort maintains configuration for a single backend.

func (*ServicePort) BackendName added in v1.2.2

func (sp *ServicePort) BackendName() string

BackendName returns the name of the backend which would be used for this ServicePort.

func (*ServicePort) GetDescription added in v1.2.2

func (sp *ServicePort) GetDescription() Description

GetDescription returns a Description for this ServicePort.

func (*ServicePort) IGName added in v1.8.0

func (sp *ServicePort) IGName() string

IGName returns the name of the instance group which would be used for this ServicePort.

func (*ServicePort) NEGName added in v1.29.0

func (sp *ServicePort) NEGName() string

type ServicePortID added in v1.2.2

type ServicePortID struct {
	Service types.NamespacedName
	Port    v1.ServiceBackendPort
}

ServicePortID contains the Service and Port fields.

func BackendToServicePortID added in v1.2.2

func BackendToServicePortID(be v1.IngressBackend, namespace string) (ServicePortID, error)

BackendToServicePortID creates a ServicePortID from a given IngressBackend and namespace.

func (ServicePortID) String added in v1.2.3

func (id ServicePortID) String() string

type THCConfiguration added in v1.24.0

type THCConfiguration struct {
	THCOptInOnSvc bool
	THCEvents     THCEvents
}

type THCEvents added in v1.24.0

type THCEvents struct {
	THCConfigured             bool
	BackendConfigOverridesTHC bool
	THCAnnotationWithoutFlag  bool
	THCAnnotationWithoutNEG   bool
}

THCEvents stores information relevant for emitting Events when THC is configured or misconfigured.

type TaskQueue

type TaskQueue interface {
	Run()
	Enqueue(objs ...interface{})
	Shutdown()
	Len() int
	NumRequeues(obj interface{}) int
}

TaskQueue is a rate limited operation queue.

type TimeTracker added in v1.2.2

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

func NewTimeTracker added in v1.2.2

func NewTimeTracker() TimeTracker

func (*TimeTracker) Get added in v1.2.2

func (t *TimeTracker) Get() time.Time

Get returns previous recorded time

func (*TimeTracker) Set added in v1.2.2

func (t *TimeTracker) Set(timestamp time.Time)

Set records input timestamp

func (*TimeTracker) Track added in v1.2.2

func (t *TimeTracker) Track() time.Time

Track records the current time and returns it

type UserError added in v1.25.0

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

UserError is a struct to define error caused by User misconfiguration.

func NewUserError added in v1.25.0

func NewUserError(err error) *UserError

func (*UserError) Error added in v1.25.0

func (e *UserError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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