Documentation ¶
Overview ¶
Reports global metrics about all PodProtector objects.
Index ¶
Constants ¶
View Source
const ProportionPpmUnits = 1000000
Variables ¶
View Source
var New = component.Declare[Args, Options, Deps, State, util.Empty]( func(Args) string { return "generator-monitor" }, func(_ Args, fs *flag.FlagSet) Options { return Options{ Enable: fs.Bool("enable", true, "Enable global PodProtector monitor"), } }, func(_ Args, requests *component.DepRequests) Deps { return Deps{ observer: o11y.Request[observer.Observer](requests), podseidonInformers: component.DepPtr(requests, kube.NewInformers(kube.PodseidonInformers( constants.CoreClusterName, constants.LeaderPhase, optional.Some(constants.GeneratorElectorArgs), ))), } }, func(_ context.Context, _ Args, options Options, deps Deps) (*State, error) { state := &State{ statusMu: sync.Mutex{}, status: util.Zero[observer.MonitorWorkloads](), addedDeltaCache: map[types.NamespacedName]observer.MonitorWorkloads{}, } if *options.Enable { pprInformer := deps.podseidonInformers.Get().Podseidon().V1alpha1().PodProtectors() _, err := pprInformer.Informer().AddEventHandler(kube.GenericEventHandlerWithStaleState( func(ppr *podseidonv1a1.PodProtector, stillPresent bool) { nsName := types.NamespacedName{Namespace: ppr.Namespace, Name: ppr.Name} if stillPresent { status := pprToStatus(ppr) state.add(nsName, status) } else { state.remove(nsName) } }, )) if err != nil { return nil, errors.TagWrapf("AddEventHandler", err, "add event handler to ppr informer") } } return state, nil }, component.Lifecycle[Args, Options, Deps, State]{ Start: func(ctx context.Context, _ *Args, options *Options, deps *Deps, state *State) error { if *options.Enable { deps.observer.Get().MonitorWorkloads(ctx, util.Empty{}, func() observer.MonitorWorkloads { state.statusMu.Lock() defer state.statusMu.Unlock() return state.status }) } return nil }, Join: nil, HealthChecks: nil, }, func(_ *component.Data[Args, Options, Deps, State]) util.Empty { return util.Empty{} }, )
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.