reconciler

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 28 Imported by: 24

Documentation

Overview

Package reconciler defines implementations of the Reconciler interface defined at knative.dev/pkg/controller.Reconciler. These implement the basic workhorse functionality of controllers, while leaving the shared controller implementation to manage things like the workqueue.

Despite defining a Reconciler, each of the packages here are expected to expose a controller constructor like:

func NewController(...) *controller.Impl { ... }

These constructors will:

  1. Construct the Reconciler,
  2. Construct a controller.Impl with that Reconciler,
  3. Wire the assorted informers this Reconciler watches to call appropriate enqueue methods on the controller.

Index

Constants

View Source
const (
	// ChannelReadyCountN is the number of channels that have become ready.
	ChannelReadyCountN = "channel_ready_count"
	// ChannelReadyLatencyN is the time it takes for a channel to become ready since the resource is created.
	ChannelReadyLatencyN = "channel_ready_latency"

	// PullSubscriptionReadyCountN is the number of pull subscriptions that have become ready.
	PullSubscriptionReadyCountN = "pullsubscription_ready_count"
	// PullSubscriptionReadyLatencyN is the time it takes for a pull subscription to become ready since the resource is created.
	PullSubscriptionReadyLatencyN = "pullsubscription_ready_latency"

	// TopicReadyCountN is the number of topics that have become ready.
	TopicReadyCountN = "topic_ready_count"
	// TopicReadyLatencyN is the time it takes for a topic to become ready since the resource is created.
	TopicReadyLatencyN = "topic_ready_latency"

	// CloudStorageSourceReadyCountN is the number of storages that have become ready.
	CloudStorageSourceReadyCountN = "storage_ready_count"
	// CloudStorageSourceReadyLatencyN is the time it takes for a storage to become ready since the resource is created.
	CloudStorageSourceReadyLatencyN = "storage_ready_latency"

	// PubSubReadyCountN is the number of pubsubs that have become ready.
	PubSubReadyCountN = "pubsub_ready_count"
	// PubSubReadyLatencyN is the time it takes for a pubsub to become ready since the resource is created.
	PubSubReadyLatencyN = "pubsub_ready_latency"

	// CloudSchedulerSourceReadyCountN is the number of schedulers that have become ready.
	CloudSchedulerSourceReadyCountN = "scheduler_ready_count"
	// CloudSchedulerSourceReadyLatencyN is the time it takes for a scheduler to become ready since the resource is created.
	CloudSchedulerSourceReadyLatencyN = "scheduler_ready_latency"

	// CloudAuditLogsSourceReadyCountN is the number of CloudAuditLogsSources that have become ready.
	CloudAuditLogsSourceReadyCountN = "cloudauditlogssource_ready_count"
	// CloudAuditLogsSourceReadyLatencyN is the time it takes for an CloudAuditLogsSource to become ready since the resource is created.
	CloudAuditLogsSourceReadyLatencyN = "cloudauditlogssource_ready_latency"
)
View Source
const (
	ControllerType = "events.cloud.google.com/controller"
)
View Source
const (
	// DefaultResyncPeriod sets the period between reconciliations in case nothing we are watching within the
	// cluster changed. This is needed because an external resource (e.g., Pub/Sub subscription, GCS notification, etc.)
	// could have been deleted outside the cluster, and we want to properly update our K8s object statuses.
	DefaultResyncPeriod = 5 * time.Minute
)

Variables

View Source
var (
	KindToStatKeys = map[string]StatKey{

		"Channel": {
			ReadyCountKey:   ChannelReadyCountN,
			ReadyLatencyKey: ChannelReadyLatencyN,
		},

		"PullSubscription": {
			ReadyCountKey:   PullSubscriptionReadyCountN,
			ReadyLatencyKey: PullSubscriptionReadyLatencyN,
		},
		"Topic": {
			ReadyCountKey:   TopicReadyCountN,
			ReadyLatencyKey: TopicReadyLatencyN,
		},

		"CloudStorageSource": {
			ReadyCountKey:   CloudStorageSourceReadyCountN,
			ReadyLatencyKey: CloudStorageSourceReadyLatencyN,
		},
		"PubSub": {
			ReadyCountKey:   PubSubReadyCountN,
			ReadyLatencyKey: PubSubReadyLatencyN,
		},
		"CloudSchedulerSource": {
			ReadyCountKey:   CloudSchedulerSourceReadyCountN,
			ReadyLatencyKey: CloudSchedulerSourceReadyLatencyN,
		},
		"CloudAuditLogsSource": {
			ReadyCountKey:   CloudAuditLogsSourceReadyCountN,
			ReadyLatencyKey: CloudAuditLogsSourceReadyLatencyN,
		},
	}

	KindToMeasurements map[string]Measurements
)

Functions

func WithStatsReporter

func WithStatsReporter(ctx context.Context, sr StatsReporter) context.Context

WithStatsReporter attaches the given StatsReporter to the provided context in the returned context.

Types

type Base

type Base struct {
	// KubeClientSet allows us to talk to the k8s for core APIs
	KubeClientSet kubernetes.Interface

	// DynamicClientSet allows us to configure pluggable Build objects
	DynamicClientSet dynamic.Interface

	// RunClientSet is the client for cloud run events.
	RunClientSet clientset.Interface

	// ServingClientSet is the client for Knative Serving
	ServingClientSet servingclientset.Interface

	// ConfigMapWatcher allows us to watch for ConfigMap changes.
	ConfigMapWatcher configmap.Watcher

	// Recorder is an event recorder for recording Event resources to the
	// Kubernetes API.
	Recorder record.EventRecorder

	// StatsReporter reports reconciler's metrics.
	StatsReporter StatsReporter

	// Sugared logger is easier to use but is not as performant as the
	// raw logger. In performance critical paths, call logger.Desugar()
	// and use the returned raw logger instead. In addition to the
	// performance benefits, raw logger also preserves type-safety at
	// the expense of slightly greater verbosity.
	Logger *zap.SugaredLogger
}

Base implements the core controller logic, given a Reconciler.

func NewBase

func NewBase(ctx context.Context, controllerAgentName string, cmw configmap.Watcher) *Base

NewBase instantiates a new instance of Base implementing the common & boilerplate code between our reconcilers.

type Measurement

type Measurement int

type Measurements

type Measurements struct {
	ReadyLatencyStat *stats.Int64Measure
	ReadyCountStat   *stats.Int64Measure
}

type Options

type Options struct {
	KubeClientSet    kubernetes.Interface
	DynamicClientSet dynamic.Interface

	RunClientSet clientset.Interface

	Recorder      record.EventRecorder
	StatsReporter StatsReporter

	ConfigMapWatcher configmap.Watcher
	Logger           *zap.SugaredLogger

	ResyncPeriod time.Duration
	StopChannel  <-chan struct{}
}

Options defines the common reconciler options. We define this to reduce the boilerplate argument list when creating our controllers.

func NewOptionsOrDie

func NewOptionsOrDie(cfg *rest.Config, logger *zap.SugaredLogger, stopCh <-chan struct{}) Options

func (Options) GetTrackerLease

func (o Options) GetTrackerLease() time.Duration

GetTrackerLease returns a multiple of the resync period to use as the duration for tracker leases. This attempts to ensure that resyncs happen to refresh leases frequently enough that we don't miss updates to tracked objects.

type StatKey

type StatKey struct {
	ReadyLatencyKey string
	ReadyCountKey   string
}

type StatsReporter

type StatsReporter interface {
	// ReportReady reports the time it took a resource to become Ready.
	ReportReady(kind, namespace, service string, d time.Duration) error
}

StatsReporter reports reconcilers' metrics.

func GetStatsReporter

func GetStatsReporter(ctx context.Context) StatsReporter

GetStatsReporter attempts to look up the StatsReporter on a given context. It may return null if none is found.

func NewStatsReporter

func NewStatsReporter(reconciler string) (StatsReporter, error)

NewStatsReporter creates a reporter for reconcilers' metrics

Directories

Path Synopsis
Package broker implements the Broker controller and reconciler reconciling Brokers and Triggers.
Package broker implements the Broker controller and reconciler reconciling Brokers and Triggers.
testingdata
Package testingdata creates data plane resources used by tests by reading YAML files.
Package testingdata creates data plane resources used by tests by reading YAML files.
Package broker implements the Broker controller and reconciler reconciling Brokers and Triggers.
Package broker implements the Broker controller and reconciler reconciling Brokers and Triggers.
events
auditlogs
Package auditlogs implements the CloudAuditLogsSource controller.
Package auditlogs implements the CloudAuditLogsSource controller.
auditlogs/resources
Package resources contains helpers for audit log source resources.
Package resources contains helpers for audit log source resources.
build
Package channel implements the CloudBuildSource controller.
Package channel implements the CloudBuildSource controller.
pubsub
Package channel implements the CloudPubSubSource controller.
Package channel implements the CloudPubSubSource controller.
scheduler
Package channel implements the Scheduler Source controller.
Package channel implements the Scheduler Source controller.
storage
Package channel implements the CloudStorageSource controller.
Package channel implements the CloudStorageSource controller.
Package identity contains the identity reconciler
Package identity contains the identity reconciler
iam
pullsubscription
Package pullsubscription implements the Pub/Sub PullSubscription controllers.
Package pullsubscription implements the Pub/Sub PullSubscription controllers.
pullsubscription/keda
Package keda implements the Pub/Sub PullSubscription controller for Keda-based PullSubscriptions.
Package keda implements the Pub/Sub PullSubscription controller for Keda-based PullSubscriptions.
pullsubscription/static
Package static implements the Pub/Sub PullSubscription controller for non-scalable PullSubscriptions.
Package static implements the Pub/Sub PullSubscription controller for non-scalable PullSubscriptions.
topic
Package topic implements the Pub/Sub Topic controller.
Package topic implements the Pub/Sub Topic controller.
messaging
channel
Package channel implements the Pub/Sub Channel controller.
Package channel implements the Pub/Sub Channel controller.
v1

Jump to

Keyboard shortcuts

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