expectations

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 14 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 = 10 * time.Minute
)

Variables

View Source
var ExpKeyFunc = func(obj interface{}) (string, error) {
	if e, ok := obj.(*ControlleeExpectations); ok {
		return e.key, nil
	}
	if e, ok := obj.(*ResourceVersionExpectationItem); ok {
		return e.key, nil
	}
	if e, ok := obj.(*ActiveExpectation); ok {
		return e.key, nil
	}
	panic(fmt.Sprintf("Could not find key for obj %#v", obj))
}

ExpKeyFunc to parse out the key from a ControlleeExpectation

View Source
var (
	ResourceInitializers map[ExpectedReosurceType]func() client.Object
)

Functions

func ActiveExpectationItemKeyFunc

func ActiveExpectationItemKeyFunc(object interface{}) (string, error)

Types

type ActiveExpectation

type ActiveExpectation struct {
	client.Client
	// contains filtered or unexported fields
}

func NewActiveExpectation

func NewActiveExpectation(client client.Client, namespace string, key string) *ActiveExpectation

type ActiveExpectationAction

type ActiveExpectationAction int
const (
	Create ActiveExpectationAction = 0
	Delete ActiveExpectationAction = 1
	Update ActiveExpectationAction = 3
)

type ActiveExpectationItem

type ActiveExpectationItem struct {
	client.Client

	Key             string
	Name            string
	Kind            ExpectedReosurceType
	Action          ActiveExpectationAction
	ResourceVersion int64
	RecordTimestamp time.Time
}

type ActiveExpectations

type ActiveExpectations struct {
	client.Client
	// contains filtered or unexported fields
}

func NewActiveExpectations

func NewActiveExpectations(client client.Client) *ActiveExpectations

func (*ActiveExpectations) Delete

func (ae *ActiveExpectations) Delete(namespace, name string) error

func (*ActiveExpectations) DeleteByKey

func (ae *ActiveExpectations) DeleteByKey(key string) error

func (*ActiveExpectations) DeleteItem

func (ae *ActiveExpectations) DeleteItem(subject metav1.Object, kind ExpectedReosurceType, name string) error

func (*ActiveExpectations) ExpectCreate

func (ae *ActiveExpectations) ExpectCreate(subject metav1.Object, kind ExpectedReosurceType, name string) error

func (*ActiveExpectations) ExpectDelete

func (ae *ActiveExpectations) ExpectDelete(subject metav1.Object, kind ExpectedReosurceType, name string) error

func (*ActiveExpectations) ExpectUpdate

func (ae *ActiveExpectations) ExpectUpdate(subject metav1.Object, kind ExpectedReosurceType, name string, updatedResourceVersion string) error

func (*ActiveExpectations) GetExpectation

func (ae *ActiveExpectations) GetExpectation(namespace, name string) (*ActiveExpectation, error)

func (*ActiveExpectations) IsSatisfied

func (ae *ActiveExpectations) IsSatisfied(subject metav1.Object) (satisfied bool, err error)

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.

type ControllerExpectations

type ControllerExpectations struct {
	cache.Store
	// contains filtered or unexported fields
}

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

func NewControllerExpectations

func NewControllerExpectations(name string) *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) InitExpectations

func (r *ControllerExpectations) InitExpectations(controllerKey string) error

Not thread safe

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)
}

type Expectations

type Expectations interface {
	Fulfilled() bool
}

Expectations are either fulfilled, or expire naturally.

type ExpectedReosurceType

type ExpectedReosurceType string
const (
	Pod             ExpectedReosurceType = "pod"
	Pvc             ExpectedReosurceType = "pvc"
	CollaSet        ExpectedReosurceType = "CollaSet"
	ResourceContext ExpectedReosurceType = "ResourceContext"
)

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) (*ResourceVersionExpectationItem, 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 ResourceVersionExpectationItem

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

func (*ResourceVersionExpectationItem) Fulfilled

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

func (*ResourceVersionExpectationItem) Set

func (i *ResourceVersionExpectationItem) Set(resourceVersion string)

Jump to

Keyboard shortcuts

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