fight

package
v1.20.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFightThreshold

func SetFightThreshold(updatesPerMinute float64)

SetFightThreshold updates the maximum allowed rate of updates to a resource per minute before we begin logging errors to the user.

Types

type Detector

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

Detector uses a linear differential equation to estimate the frequency of updates to resources, then logs to klog.Warning when it detects resources needing updates too frequently.

Instantiate with NewDetector().

Performance characteristics:

  1. Current implementation is threadsafe.
  2. Current implementation has unbounded memory usage on the order of the number of objects the Syncer updates through its lifetime.
  3. Updating an already-tracked resource requires no memory allocations and take approximately 30ns, ignoring logging time.

func NewDetector

func NewDetector() Detector

NewDetector instantiates a fight detector.

func (*Detector) DetectFight

func (d *Detector) DetectFight(now time.Time, obj client.Object) (bool, status.ResourceError)

DetectFight detects whether the resource is needing updates too frequently. If so, it increments the resource_fights metric and logs to klog.Error.

type Handler

type Handler interface {
	AddFightError(core.ID, status.Error)
	RemoveFightError(core.ID)

	// FightErrors returns the fight errors (KNV2005) the remediator encounters.
	FightErrors() []status.Error
}

Handler is the generic interface of the fight handler.

func NewHandler

func NewHandler() Handler

NewHandler instantiates a fight handler

Jump to

Keyboard shortcuts

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