timeout

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

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 Handler

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

Handler knows how to track channels that can be used to communicate with go routines which timeout, and the functions to call when that happens.

func NewHandler

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

NewHandler returns an instance of Handler with the specified stopCh and logger, instantiated and ready to track go routines.

func (*Handler) CheckTimeouts

func (t *Handler) CheckTimeouts(namespace string, kubeclientset kubernetes.Interface, pipelineclientset clientset.Interface)

CheckTimeouts function iterates through a given namespace or all namespaces (if empty string) and calls corresponding taskrun/pipelinerun timeout functions

func (*Handler) GetBackoff

func (t *Handler) GetBackoff(tr *v1beta1.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 (*Handler) Release

func (t *Handler) Release(runObj StatusKey)

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

func (*Handler) SetPipelineRunCallbackFunc

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

SetPipelineRunCallbackFunc sets the callback function when timeout occurs for pipelinerun objects

func (*Handler) SetTaskRunCallbackFunc

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

SetTaskRunCallbackFunc sets the callback function when timeout occurs for taskrun objects

func (*Handler) SetTaskRunTimer

func (t *Handler) SetTaskRunTimer(tr *v1beta1.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 (*Handler) WaitPipelineRun

func (t *Handler) WaitPipelineRun(pr *v1beta1.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 (*Handler) WaitTaskRun

func (t *Handler) WaitTaskRun(tr *v1beta1.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

type StatusKey

type StatusKey interface {
	GetRunKey() string
}

StatusKey interface to be implemented by Taskrun Pipelinerun types

Jump to

Keyboard shortcuts

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