expectations

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// If a watch drops a delete event for a pod, it'll take this long
	// before a dormant controller waiting for those packets is woken up anyway. It is
	// specifically targeted at the case where some problem prevents an update
	// of expectations, without it the controller could stay asleep forever. This should
	// be set based on the expected latency of watch events.
	//
	// Currently a controller can service (create *and* observe the watch events for said
	// creation) about 10 pods a second, so it takes about 1 min to service
	// 500 pods. Just creation is limited to 20qps, and watching happens with ~10-30s
	// latency/pod at the scale of 3000 pods over 100 nodes.
	ExpectationsTimeout = 5 * time.Minute
)

Variables

View Source
var ExpKeyFunc = func(obj interface{}) (string, error) {
	if e, ok := obj.(ExpectationKey); ok {
		return e.Key(), nil
	}
	return "", fmt.Errorf("could not find key for obj %#v", obj)
}

ExpKeyFunc to parse out the key from a ControlleeExpectation

Functions

This section is empty.

Types

type ControlleeExpectations

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

ControlleeExpectations track controllee creates/deletes.

func (*ControlleeExpectations) Add

func (e *ControlleeExpectations) Add(add, del int64)

Add increments the add and del counters.

func (*ControlleeExpectations) Fulfilled

func (e *ControlleeExpectations) Fulfilled() bool

Fulfilled returns true if this expectation has been fulfilled.

func (*ControlleeExpectations) GetExpectations

func (e *ControlleeExpectations) GetExpectations() (int64, int64)

GetExpectations returns the add and del expectations of the controllee.

func (*ControlleeExpectations) Key

func (e *ControlleeExpectations) Key() string

Key implements ExpectationKey interface

type ControllerExpectations

type ControllerExpectations struct {
	cache.Store
}

ControllerExpectations is a cache mapping controllers to what they expect to see before being woken up for a sync.

func NewControllerExpectations

func NewControllerExpectations() *ControllerExpectations

NewControllerExpectations returns a store for ControllerExpectations.

func (*ControllerExpectations) CreationObserved

func (r *ControllerExpectations) CreationObserved(controllerKey string)

CreationObserved atomically decrements the `add` expectation count of the given controller.

func (*ControllerExpectations) DeleteExpectations

func (r *ControllerExpectations) DeleteExpectations(controllerKey string)

DeleteExpectations deletes the expectations of the given controller from the TTLStore.

func (*ControllerExpectations) DeletionObserved

func (r *ControllerExpectations) DeletionObserved(controllerKey string)

DeletionObserved atomically decrements the `del` expectation count of the given controller.

func (*ControllerExpectations) ExpectCreations

func (r *ControllerExpectations) ExpectCreations(controllerKey string, adds int) error

func (*ControllerExpectations) ExpectDeletions

func (r *ControllerExpectations) ExpectDeletions(controllerKey string, dels int) error

func (*ControllerExpectations) GetExpectations

func (r *ControllerExpectations) GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)

GetExpectations returns the ControlleeExpectations of the given controller.

func (*ControllerExpectations) LowerExpectations

func (r *ControllerExpectations) LowerExpectations(controllerKey string, add, del int)

Decrements the expectation counts of the given controller.

func (*ControllerExpectations) RaiseExpectations

func (r *ControllerExpectations) RaiseExpectations(controllerKey string, add, del int)

Increments the expectation counts of the given controller.

func (*ControllerExpectations) SatisfiedExpectations

func (r *ControllerExpectations) SatisfiedExpectations(controllerKey string) bool

SatisfiedExpectations returns true if the required adds/dels for the given controller have been observed. Add/del counts are established by the controller at sync time, and updated as controllees are observed by the controller manager.

func (*ControllerExpectations) SetExpectations

func (r *ControllerExpectations) SetExpectations(controllerKey string, add, del int) error

SetExpectations registers new expectations for the given controller. Forgets existing expectations.

type ControllerExpectationsInterface

type ControllerExpectationsInterface interface {
	GetExpectations(controllerKey string) (*ControlleeExpectations, bool, error)
	SatisfiedExpectations(controllerKey string) bool
	DeleteExpectations(controllerKey string)
	SetExpectations(controllerKey string, add, del int) error
	ExpectCreations(controllerKey string, adds int) error
	ExpectDeletions(controllerKey string, dels int) error
	CreationObserved(controllerKey string)
	DeletionObserved(controllerKey string)
	RaiseExpectations(controllerKey string, add, del int)
	LowerExpectations(controllerKey string, add, del int)
}

ControllerExpectationsInterface is an interface that allows users to set and wait on expectations. Only abstracted out for testing. Warning: if using KeyFunc it is not safe to use a single ControllerExpectationsInterface with different types of controllers, because the keys might conflict across types.

type ExpectationKey

type ExpectationKey interface {
	Key() string
}

ExpectationKey

type ObjectResourceVersionExpectation

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

func (*ObjectResourceVersionExpectation) Fulfilled

func (i *ObjectResourceVersionExpectation) Fulfilled(resourceVersion string) bool

Fulfilled returns true if this expectation has been fulfilled.

func (*ObjectResourceVersionExpectation) Key

Key implements ExpectationKey interface

func (*ObjectResourceVersionExpectation) Set

func (i *ObjectResourceVersionExpectation) Set(resourceVersion string)

type ResourceVersionExpectation

type ResourceVersionExpectation struct {
	cache.Store
}

func NewResourceVersionExpectation

func NewResourceVersionExpectation() *ResourceVersionExpectation

func (*ResourceVersionExpectation) DeleteExpectations

func (r *ResourceVersionExpectation) DeleteExpectations(controllerKey string)

func (*ResourceVersionExpectation) ExpectUpdate

func (r *ResourceVersionExpectation) ExpectUpdate(controllerKey string, resourceVersion string) error

func (*ResourceVersionExpectation) GetExpectations

func (r *ResourceVersionExpectation) GetExpectations(controllerKey string) (*ObjectResourceVersionExpectation, bool, error)

func (*ResourceVersionExpectation) SatisfiedExpectations

func (r *ResourceVersionExpectation) SatisfiedExpectations(controllerKey string, resourceVersion string) bool

func (*ResourceVersionExpectation) SetExpectations

func (r *ResourceVersionExpectation) SetExpectations(controllerKey string, resourceVersion string) error

type ResourceVersionExpectationInterface

type ResourceVersionExpectationInterface interface {
	GetExpectations(controllerKey string) (*ObjectResourceVersionExpectation, bool, error)
	SatisfiedExpectations(controllerKey, resourceVersion string) bool
	DeleteExpectations(controllerKey string)
	ExpectUpdate(controllerKey string, resourceVersion string) error
}

Jump to

Keyboard shortcuts

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