bundleevents

package
v0.17.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package bundleevents reports the deployment state of bundles as Kubernetes events.

Events are created directly, instead of through client-go's event recorder. The recorder deduplicates events by every field except their note, and keeps the note of the first event of a series, so notes describing different failures of the same bundle would be dropped. Deduplication happens here instead, based on a fingerprint of the failure causes and of how many deployments are affected, so that each event which does get created describes the state accurately.

Index

Constants

View Source
const (

	// ReasonBundleDeployFailed reports a bundle with deployments which failed to apply their resources.
	ReasonBundleDeployFailed = "BundleDeployFailed"

	// ReasonBundleNotReady reports a bundle with deployments which applied their resources, but those are not ready.
	ReasonBundleNotReady = "BundleNotReady"

	// ReasonBundleReady reports a bundle whose deployments are all ready again.
	ReasonBundleReady = "BundleReady"

	// ReasonBundleDeploymentFailed reports a single bundle deployment which failed to apply its resources.
	ReasonBundleDeploymentFailed = "BundleDeploymentFailed"

	// ReasonBundleDeploymentNotReady reports a single bundle deployment which applied its resources, but those are not ready.
	ReasonBundleDeploymentNotReady = "BundleDeploymentNotReady"

	// ReasonBundleDeploymentReady reports a single bundle deployment which is ready again.
	ReasonBundleDeploymentReady = "BundleDeploymentReady"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

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

Emitter implements Notifier. It also implements manager.Runnable: pending events are created by its Start method.

func New

func New(c client.Client, scheme *runtime.Scheme, reportingController string, options func() Options, opts ...Option) *Emitter

New returns an emitter which creates events with the given reporting controller name. Options are read on every use, so that configuration changes take effect without a restart.

func (*Emitter) Forget

func (e *Emitter) Forget(uid types.UID)

Forget drops everything remembered about an object.

func (*Emitter) ObserveBundle

func (e *Emitter) ObserveBundle(ctx context.Context, old, cur *fleet.Bundle)

ObserveBundle reports failures and recoveries of a bundle's deployments.

func (*Emitter) ObserveBundleDeployment

func (e *Emitter) ObserveBundleDeployment(ctx context.Context, old, cur *fleet.BundleDeployment)

ObserveBundleDeployment reports a single bundle deployment, if per-deployment reporting is enabled.

func (*Emitter) Start

func (e *Emitter) Start(ctx context.Context) error

Start creates pending events once they are due. It returns when the context is cancelled.

type Notifier

type Notifier interface {
	// ObserveBundle reports failures and recoveries of a bundle's
	// deployments. Old is the bundle as previously persisted, which makes
	// the state change survive a restart of the controller.
	ObserveBundle(ctx context.Context, old, cur *fleet.Bundle)

	// ObserveBundleDeployment reports a single bundle deployment, if
	// per-deployment reporting is enabled. Old is the bundle deployment as
	// previously persisted, which makes the state change survive a restart
	// of the controller.
	ObserveBundleDeployment(ctx context.Context, old, cur *fleet.BundleDeployment)

	// Forget drops everything remembered about an object. Callers report
	// objects which are going away, so that nothing is kept for them.
	Forget(uid types.UID)
}

Notifier observes objects after their status has been updated, and reports state changes worth an event.

type Option

type Option func(*Emitter)

Option overrides an emitter's defaults.

func WithClock

func WithClock(now func() time.Time) Option

WithClock replaces the emitter's source of time.

func WithRateLimiter

func WithRateLimiter(limiter flowcontrol.RateLimiter) Option

WithRateLimiter replaces the emitter's rate limiter.

type Options

type Options struct {
	// Enabled turns event reporting on or off.
	Enabled bool

	// Debounce is how long to wait for a burst of failures to settle before
	// reporting it, so that the reported counts and causes describe the
	// whole burst instead of only its first failure.
	Debounce time.Duration

	// MinInterval is the minimum time between two events for the same
	// object. It bounds how often a flapping deployment reports.
	MinInterval time.Duration

	// ReportRecovery reports bundles whose deployments all became ready
	// again after a failure.
	ReportRecovery bool

	// PerDeployment additionally reports each failing bundle deployment.
	// This is more detailed, but produces one event per failing deployment,
	// in the namespace of its cluster.
	PerDeployment bool

	// MaxCauses is how many distinct failure causes a single event describes.
	MaxCauses int

	// MaxTracked is the number of objects the emitter remembers in order to
	// deduplicate their events.
	MaxTracked int
}

Options configure which deployment state changes are reported as events, and how often.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the options used when nothing is configured.

func OptionsFromConfig

func OptionsFromConfig(cfg *config.Config) Options

OptionsFromConfig turns the fleet controller's config into options. Unset durations keep their default, as elsewhere in the config.

func OptionsFromGlobalConfig

func OptionsFromGlobalConfig() Options

OptionsFromGlobalConfig reads the options from the fleet controller's config. It is read on every use, so that changes to the configmap take effect without a restart.

Jump to

Keyboard shortcuts

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