Documentation
¶
Overview ¶
Package resultcleanup retires and collects runner evidence through direct API reads. It never deletes plans or reads/deletes Secret projections.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRetained = errors.New("result evidence is not eligible for collection")
Functions ¶
func RootBinding ¶
func RootBinding(record *api.PtahResultRecord) (resultstore.Binding, error)
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector scans metadata in bounded pages outside both reconciliation workers. It keeps no payload cache. The API's required admission guard authorizes each UID-bound DELETE with current reads; the collector does not repeat that entire verdict before sending the request. Only the leader scans.
func New ¶
func New(writer client.Client, policy Policy, registry prometheus.Registerer, recorder EventRecorder) (*Collector, error)
New builds the collector. recorder receives the Warning Events that explain a retirement a ResourceQuota refused; a nil recorder records none.
func (*Collector) NeedLeaderElection ¶
func (*Collector) Step ¶
Step visits at most one 64-object metadata page and attempts at most ten DELETEs, retaining the unfinished page across a deadline or write budget. Errors on one attempt do not starve later attempts. Start calls it serially; tests can advance a complete scan without sleeping.
type EventRecorder ¶ added in v0.2.11
type EventRecorder interface {
Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...any)
}
EventRecorder is the part of client-go's record.EventRecorder the collector uses.
type Policy ¶
type Policy struct {
Reader client.Reader
Window time.Duration
// Now is injectable for tests; production uses the wall clock.
Now func() time.Time
}
func (Policy) AuthorizeDelete ¶
AuthorizeDelete is the admission verdict, regardless of the DELETE caller. record is the API server's stored admission object. Neither a collector's cached decision nor an administrator's identity replaces these current checks. Every API failure retains the evidence. A refusal that is about time is a resultretention.WindowError; every other refusal names no instant, because none would lift it.
func (Policy) AuthorizeForegroundRetirement ¶
func (p Policy) AuthorizeForegroundRetirement(ctx context.Context, record *api.PtahResultRecord) error
AuthorizeForegroundRetirement permits only the start of a foreground deletion. Its API-controlled timestamp supplies the retirement clock when the API refuses a separate marker: a terminating namespace refuses every CREATE, and a full ResourceQuota on result records refuses this one. Nothing here reads why, because the verdict is the same either way: the namespace's phase and its quotas say nothing about the evidence. Admission protects the foreground finalizer until AuthorizeDelete permits destruction of bytes.