reconciler

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 21 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.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitEvent

func EmitEvent(c record.EventRecorder, beforeCondition *apis.Condition, afterCondition *apis.Condition, object runtime.Object)

EmitEvent emits success or failed event for object if afterCondition is different from beforeCondition

Types

type Backoff added in v0.10.0

type Backoff struct {
	// NumAttempts reflects the number of times a given StatusKey has been delayed
	NumAttempts uint
	// NextAttempt is the point in time at which this backoff expires
	NextAttempt time.Time
}

Backoff contains state of exponential backoff for a given StatusKey

type Base

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

	// PipelineClientSet allows us to configure pipeline objects
	PipelineClientSet clientset.Interface

	// CachingClientSet allows us to instantiate Image objects
	CachingClientSet cachingclientset.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

	// 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

	// Images contains images to use for certain internal container
	Images pipeline.Images
}

Base implements the core controller logic, given a Reconciler.

func NewBase

func NewBase(opt Options, controllerAgentName string, images pipeline.Images) *Base

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

type Options

type Options struct {
	KubeClientSet     kubernetes.Interface
	PipelineClientSet clientset.Interface
	CachingClientSet  cachingclientset.Interface

	ConfigMapWatcher configmap.Watcher
	Logger           *zap.SugaredLogger
	Recorder         record.EventRecorder

	ResyncPeriod time.Duration
}

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

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 StatusKey added in v0.2.0

type StatusKey interface {
	GetRunKey() string
}

StatusKey interface to be implemented by Taskrun Pipelinerun types

type TimeoutSet added in v0.2.0

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

TimeoutSet contains required k8s interfaces to handle build timeouts

func NewTimeoutHandler added in v0.2.0

func NewTimeoutHandler(
	stopCh <-chan struct{},
	logger *zap.SugaredLogger,
) *TimeoutSet

NewTimeoutHandler returns TimeoutSet filled structure

func (*TimeoutSet) CheckTimeouts added in v0.2.0

func (t *TimeoutSet) CheckTimeouts(kubeclientset kubernetes.Interface, pipelineclientset clientset.Interface)

CheckTimeouts function iterates through all namespaces and calls corresponding taskrun/pipelinerun timeout functions

func (*TimeoutSet) GetBackoff added in v0.5.0

func (t *TimeoutSet) GetBackoff(tr *v1alpha1.TaskRun) (Backoff, bool)

GetBackoff records the number of times it has seen a TaskRun and calculates an appropriate backoff deadline based on that count. Only one backoff per TaskRun may be active at any moment. Requests for a new backoff in the face of an existing one will be ignored and details of the existing backoff will be returned instead. Further, if a calculated backoff time is after the timeout of the TaskRun then the time of the timeout will be returned instead.

Returned values are a backoff struct containing a NumAttempts field with the number of attempts performed for this TaskRun and a NextAttempt field describing the time at which the next attempt should be performed. Additionally a boolean is returned indicating whether a backoff for the TaskRun is already in progress.

func (*TimeoutSet) Release added in v0.2.0

func (t *TimeoutSet) Release(runObj StatusKey)

Release deletes channels and data that are specific to a StatusKey object.

func (*TimeoutSet) SetPipelineRunCallbackFunc added in v0.2.0

func (t *TimeoutSet) SetPipelineRunCallbackFunc(f func(interface{}))

SetPipelineRunCallbackFunc sets the callback function when timeout occurs for pipelinerun objects

func (*TimeoutSet) SetTaskRunCallbackFunc added in v0.2.0

func (t *TimeoutSet) SetTaskRunCallbackFunc(f func(interface{}))

SetTaskRunCallbackFunc sets the callback function when timeout occurs for taskrun objects

func (*TimeoutSet) SetTaskRunTimer added in v0.5.0

func (t *TimeoutSet) SetTaskRunTimer(tr *v1alpha1.TaskRun, d time.Duration)

SetTaskRunTimer creates a blocking function for taskrun to wait for 1. Stop signal, 2. TaskRun to complete or 3. a given Duration to elapse.

Since the timer's duration is a parameter rather than being tied to the lifetime of the TaskRun no resources are released after the timer fires. It is the caller's responsibility to Release() the TaskRun when work with it has completed.

func (*TimeoutSet) WaitPipelineRun added in v0.2.0

func (t *TimeoutSet) WaitPipelineRun(pr *v1alpha1.PipelineRun, startTime *metav1.Time)

WaitPipelineRun function creates a blocking function for pipelinerun to wait for 1. Stop signal, 2. pipelinerun to complete or 3. pipelinerun to time out which is determined by checking if the tr's timeout has occurred since the startTime

func (*TimeoutSet) WaitTaskRun added in v0.2.0

func (t *TimeoutSet) WaitTaskRun(tr *v1alpha1.TaskRun, startTime *metav1.Time)

WaitTaskRun function creates a blocking function for taskrun to wait for 1. Stop signal, 2. TaskRun to complete or 3. Taskrun to time out, which is determined by checking if the tr's timeout has occurred since the startTime

Directories

Path Synopsis
pipeline
dag

Jump to

Keyboard shortcuts

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