Documentation ¶
Overview ¶
Package controller contains the router controller.
Index ¶
- Variables
- func HostForRoute(route *routeapi.Route) string
- type ContentionTracker
- type ExtendedValidator
- func (p *ExtendedValidator) Commit() error
- func (p *ExtendedValidator) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error
- func (p *ExtendedValidator) HandleNamespaces(namespaces sets.String) error
- func (p *ExtendedValidator) HandleNode(eventType watch.EventType, node *kapi.Node) error
- func (p *ExtendedValidator) HandleRoute(eventType watch.EventType, route *routeapi.Route) error
- type HostAdmitter
- func (p *HostAdmitter) Commit() error
- func (p *HostAdmitter) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error
- func (p *HostAdmitter) HandleNamespaces(namespaces sets.String) error
- func (p *HostAdmitter) HandleNode(eventType watch.EventType, node *kapi.Node) error
- func (p *HostAdmitter) HandleRoute(eventType watch.EventType, route *routeapi.Route) error
- type RejectionRecorder
- type RouteAdmissionFunc
- type RouteHostFunc
- type RouteMap
- type RouterController
- func (c *RouterController) Commit()
- func (c *RouterController) GetFilteredProjectNames() (sets.String, error)
- func (c *RouterController) HandleEndpoints(eventType watch.EventType, obj interface{})
- func (c *RouterController) HandleNamespace(eventType watch.EventType, obj interface{})
- func (c *RouterController) HandleNode(eventType watch.EventType, obj interface{})
- func (c *RouterController) HandleProjects()
- func (c *RouterController) HandleRoute(eventType watch.EventType, obj interface{})
- func (c *RouterController) RecordNamespaceEndpoints(eventType watch.EventType, ep *kapi.Endpoints)
- func (c *RouterController) RecordNamespaceRoutes(eventType watch.EventType, rt *routeapi.Route)
- func (c *RouterController) Run()
- func (c *RouterController) UpdateNamespaces()
- type SimpleContentionTracker
- func (t *SimpleContentionTracker) Changed(id string, current *routeapi.RouteIngress)
- func (t *SimpleContentionTracker) Clear(id string, current *routeapi.RouteIngress)
- func (t *SimpleContentionTracker) IsChangeContended(id string, now time.Time, current *routeapi.RouteIngress) bool
- func (t *SimpleContentionTracker) Run(stopCh <-chan struct{})
- func (t *SimpleContentionTracker) SetConflictMessage(message string)
- type StatusAdmitter
- func (a *StatusAdmitter) Commit() error
- func (a *StatusAdmitter) HandleEndpoints(eventType watch.EventType, route *kapi.Endpoints) error
- func (a *StatusAdmitter) HandleNamespaces(namespaces sets.String) error
- func (a *StatusAdmitter) HandleNode(eventType watch.EventType, node *kapi.Node) error
- func (a *StatusAdmitter) HandleRoute(eventType watch.EventType, route *routeapi.Route) error
- func (a *StatusAdmitter) RecordRouteRejection(route *routeapi.Route, reason, message string)
- type UniqueHost
- func (p *UniqueHost) Commit() error
- func (p *UniqueHost) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error
- func (p *UniqueHost) HandleNamespaces(namespaces sets.String) error
- func (p *UniqueHost) HandleNode(eventType watch.EventType, node *kapi.Node) error
- func (p *UniqueHost) HandleRoute(eventType watch.EventType, route *routeapi.Route) error
- func (p *UniqueHost) HostLen() int
- func (p *UniqueHost) RoutesForHost(host string) ([]*routeapi.Route, bool)
Constants ¶
This section is empty.
Variables ¶
var LogRejections = logRecorder{}
LogRejections writes rejection messages to the log.
Functions ¶
func HostForRoute ¶
HostForRoute returns the host set on the route.
Types ¶
type ContentionTracker ¶
type ContentionTracker interface { // IsContended should be invoked when the state of the object in storage differs // from the desired state. It will return true if the provided id was recently // reset from the correct state to an incorrect state. The current ingress is the // expected state of the object at this time and may be used by the tracker to // determine if the most recent update was a contention. This method does not // update the state of the tracker. IsChangeContended(id string, now time.Time, current *routeapi.RouteIngress) bool // Clear informs the tracker that the provided ingress state was confirmed to // match the current state of this process. If a subsequent call to IsChangeContended // is made within the expiration window, the object will be considered as contended. Clear(id string, current *routeapi.RouteIngress) }
ContentionTracker records modifications to a particular entry to prevent endless loops when multiple routers are configured with conflicting info. A given router process tracks whether the ingress status is change from a correct value to any other value (by invoking IsContended when the state has diverged).
type ExtendedValidator ¶
type ExtendedValidator struct {
// contains filtered or unexported fields
}
ExtendedValidator implements the router.Plugin interface to provide extended config validation for template based, backend-agnostic routers.
func NewExtendedValidator ¶
func NewExtendedValidator(plugin router.Plugin, recorder RejectionRecorder) *ExtendedValidator
NewExtendedValidator creates a plugin wrapper that ensures only routes that pass extended validation are relayed to the next plugin in the chain. Recorder is an interface for indicating why a route was rejected.
func (*ExtendedValidator) Commit ¶
func (p *ExtendedValidator) Commit() error
func (*ExtendedValidator) HandleEndpoints ¶
func (p *ExtendedValidator) HandleEndpoints(eventType watch.EventType, endpoints *kapi.Endpoints) error
HandleEndpoints processes watch events on the Endpoints resource.
func (*ExtendedValidator) HandleNamespaces ¶
func (p *ExtendedValidator) HandleNamespaces(namespaces sets.String) error
HandleNamespaces limits the scope of valid routes to only those that match the provided namespace list.
func (*ExtendedValidator) HandleNode ¶
HandleNode processes watch events on the node resource
func (*ExtendedValidator) HandleRoute ¶
HandleRoute processes watch events on the Route resource.
type HostAdmitter ¶
type HostAdmitter struct {
// contains filtered or unexported fields
}
HostAdmitter implements the router.Plugin interface to add admission control checks for routes in template based, backend-agnostic routers.
func NewHostAdmitter ¶
func NewHostAdmitter(plugin router.Plugin, fn RouteAdmissionFunc, allowWildcards, disableNamespaceCheck bool, recorder RejectionRecorder) *HostAdmitter
NewHostAdmitter creates a plugin wrapper that checks whether or not to admit routes and relay them to the next plugin in the chain. Recorder is an interface for indicating why a route was rejected.
func (*HostAdmitter) Commit ¶
func (p *HostAdmitter) Commit() error
func (*HostAdmitter) HandleEndpoints ¶
HandleEndpoints processes watch events on the Endpoints resource.
func (*HostAdmitter) HandleNamespaces ¶
func (p *HostAdmitter) HandleNamespaces(namespaces sets.String) error
HandleNamespaces limits the scope of valid routes to only those that match the provided namespace list.
func (*HostAdmitter) HandleNode ¶
HandleNode processes watch events on the Node resource.
func (*HostAdmitter) HandleRoute ¶
HandleRoute processes watch events on the Route resource.
type RejectionRecorder ¶
type RejectionRecorder interface {
RecordRouteRejection(route *routeapi.Route, reason, message string)
}
RejectionRecorder is an object capable of recording why a route was rejected
type RouteAdmissionFunc ¶
RouteAdmissionFunc determines whether or not to admit a route.
type RouteHostFunc ¶
RouteHostFunc returns a host for a route. It may return an empty string.
type RouterController ¶
type RouterController struct { Plugin router.Plugin FilteredNamespaceNames sets.String NamespaceLabels labels.Selector // Holds Namespace --> RouteName --> RouteObject NamespaceRoutes map[string]map[string]*routeapi.Route // Holds Namespace --> EndpointsName --> EndpointsObject NamespaceEndpoints map[string]map[string]*kapi.Endpoints ProjectClient projectclient.ProjectInterface ProjectLabels labels.Selector ProjectSyncInterval time.Duration ProjectWaitInterval time.Duration ProjectRetries int WatchNodes bool // contains filtered or unexported fields }
RouterController abstracts the details of watching resources like Routes, Endpoints, etc. used by the plugin implementation.
func (*RouterController) Commit ¶
func (c *RouterController) Commit()
Commit notifies the plugin that it is safe to commit state.
func (*RouterController) GetFilteredProjectNames ¶
func (c *RouterController) GetFilteredProjectNames() (sets.String, error)
func (*RouterController) HandleEndpoints ¶
func (c *RouterController) HandleEndpoints(eventType watch.EventType, obj interface{})
HandleEndpoints handles a single Endpoints event and refreshes the router backend.
func (*RouterController) HandleNamespace ¶
func (c *RouterController) HandleNamespace(eventType watch.EventType, obj interface{})
func (*RouterController) HandleNode ¶
func (c *RouterController) HandleNode(eventType watch.EventType, obj interface{})
HandleNode handles a single Node event and synchronizes the router backend
func (*RouterController) HandleProjects ¶
func (c *RouterController) HandleProjects()
func (*RouterController) HandleRoute ¶
func (c *RouterController) HandleRoute(eventType watch.EventType, obj interface{})
HandleRoute handles a single Route event and synchronizes the router backend.
func (*RouterController) RecordNamespaceEndpoints ¶
func (c *RouterController) RecordNamespaceEndpoints(eventType watch.EventType, ep *kapi.Endpoints)
func (*RouterController) RecordNamespaceRoutes ¶
func (c *RouterController) RecordNamespaceRoutes(eventType watch.EventType, rt *routeapi.Route)
func (*RouterController) UpdateNamespaces ¶
func (c *RouterController) UpdateNamespaces()
type SimpleContentionTracker ¶
type SimpleContentionTracker struct {
// contains filtered or unexported fields
}
SimpleContentionTracker tracks whether a given identifier is changed from a correct state (set by Clear) to an incorrect state (inferred by calling IsContended).
func NewSimpleContentionTracker ¶
func NewSimpleContentionTracker(informer cache.SharedInformer, routerName string, interval time.Duration) *SimpleContentionTracker
NewSimpleContentionTracker creates a ContentionTracker that will prevent writing to the same route more often than once per interval. A background process will periodically flush old entries (at twice interval) in order to prevent the list growing unbounded if routes are created and deleted frequently. The informer detects changes to ingress records for routerName and will advance the tracker state from candidate to contended if the host, wildcardPolicy, or canonical host name fields are repeatedly updated.
func (*SimpleContentionTracker) Changed ¶
func (t *SimpleContentionTracker) Changed(id string, current *routeapi.RouteIngress)
Changed records that a change to an ingress value was detected. This is called from a separate goroutine and may have seen newer events than the current route controller plugins, so we don't do direct time comparisons. Instead we count edge transitions on a given id.
func (*SimpleContentionTracker) Clear ¶
func (t *SimpleContentionTracker) Clear(id string, current *routeapi.RouteIngress)
func (*SimpleContentionTracker) IsChangeContended ¶
func (t *SimpleContentionTracker) IsChangeContended(id string, now time.Time, current *routeapi.RouteIngress) bool
func (*SimpleContentionTracker) Run ¶
func (t *SimpleContentionTracker) Run(stopCh <-chan struct{})
Run starts the background cleanup process for expired items.
func (*SimpleContentionTracker) SetConflictMessage ¶
func (t *SimpleContentionTracker) SetConflictMessage(message string)
SetConflictMessage will print message whenever contention with another writer is detected.
type StatusAdmitter ¶
type StatusAdmitter struct {
// contains filtered or unexported fields
}
StatusAdmitter ensures routes added to the plugin have status set.
func NewStatusAdmitter ¶
func NewStatusAdmitter(plugin router.Plugin, client client.RoutesGetter, lister routelisters.RouteLister, name, hostName string, lease writerlease.Lease, tracker ContentionTracker) *StatusAdmitter
NewStatusAdmitter creates a plugin wrapper that ensures every accepted route has a status field set that matches this router. The admitter manages an LRU of recently seen conflicting updates to handle when two router processes with differing configurations are writing updates at the same time.
func (*StatusAdmitter) Commit ¶
func (a *StatusAdmitter) Commit() error
func (*StatusAdmitter) HandleEndpoints ¶
func (*StatusAdmitter) HandleNamespaces ¶
func (a *StatusAdmitter) HandleNamespaces(namespaces sets.String) error
func (*StatusAdmitter) HandleNode ¶
func (*StatusAdmitter) HandleRoute ¶
HandleRoute attempts to admit the provided route on watch add / modifications.
func (*StatusAdmitter) RecordRouteRejection ¶
func (a *StatusAdmitter) RecordRouteRejection(route *routeapi.Route, reason, message string)
RecordRouteRejection attempts to update the route status with a reason for a route being rejected.
type UniqueHost ¶
type UniqueHost struct {
// contains filtered or unexported fields
}
UniqueHost implements the router.Plugin interface to provide a template based, backend-agnostic router.
func NewUniqueHost ¶
func NewUniqueHost(plugin router.Plugin, disableOwnershipCheck bool, recorder RejectionRecorder) *UniqueHost
NewUniqueHost creates a plugin wrapper that ensures only unique routes are passed into the underlying plugin. Recorder is an interface for indicating why a route was rejected.
func (*UniqueHost) Commit ¶
func (p *UniqueHost) Commit() error
Commit invokes the nested plugin to commit.
func (*UniqueHost) HandleEndpoints ¶
HandleEndpoints processes watch events on the Endpoints resource.
func (*UniqueHost) HandleNamespaces ¶
func (p *UniqueHost) HandleNamespaces(namespaces sets.String) error
HandleNamespaces limits the scope of valid routes to only those that match the provided namespace list.
func (*UniqueHost) HandleNode ¶
HandleNode processes watch events on the Node resource and calls the router
func (*UniqueHost) HandleRoute ¶
HandleRoute processes watch events on the Route resource. TODO: this function can probably be collapsed with the router itself, as a function that
determines which component needs to be recalculated (which template) and then does so on demand.
func (*UniqueHost) HostLen ¶
func (p *UniqueHost) HostLen() int
HostLen returns the number of hosts currently tracked by this plugin.
func (*UniqueHost) RoutesForHost ¶
func (p *UniqueHost) RoutesForHost(host string) ([]*routeapi.Route, bool)
RoutesForHost is a helper that allows routes to be retrieved.