Documentation
¶
Overview ¶
Package deploymentgc implements retention garbage collection for deployment records.
Every deploy publishes a deployment record, and until this controller existed nothing ever removed a settled one, so a cluster's deploy history grew for as long as it ran. Miren Cloud is the durable book of record for that history: deployments export under the archive lifecycle, which keeps cloud's copy past the runtime's delete. The runtime only needs to keep enough recent history to serve `miren app history` and to explain the app's current state, so this controller bounds each app's records to the most-recent RetentionCount plus anything younger than RetentionPeriod.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExportProgress ¶
type ExportProgress interface {
// LandedRevision returns the highest store revision cloud has confirmed,
// and whether export applies to this cluster at all.
LandedRevision() (revision int64, exporting bool)
}
ExportProgress reports how much of the entity store cloud holds durably. Entity sync's diagnostics satisfy it.
type GCConfig ¶
type GCConfig struct {
// CheckInterval is how often to run the GC sweep (default: 1h).
CheckInterval time.Duration
// RetentionPeriod keeps records newer than this regardless of count
// (default: 30 days). Zero disables the sweep entirely, keeping every
// record indefinitely.
RetentionPeriod time.Duration
// RetentionCount keeps this many most-recent records per app regardless
// of age (default: 25).
RetentionCount int
}
GCConfig holds configuration for deployment record retention GC.
func DefaultGCConfig ¶
func DefaultGCConfig() GCConfig
DefaultGCConfig returns the default GC configuration.
type GCController ¶
type GCController struct {
Log *slog.Logger
EAC *entityserver_v1alpha.EntityAccessClient
Config GCConfig
// StartGate, when set, holds the first sweep until it closes. The server
// passes the same readiness signal that gates entity sync: the
// deployment-attempt migration has finished repairing every record and
// backfilling the cloud export marker. Deleting a record before then
// would race the migration and, worse, remove a record the exporter has
// not been told to watch, so cloud would never receive its final state.
StartGate <-chan struct{}
// Exports, when set, makes cloud custody a condition of deletion on a
// registered cluster: a record is only pruned once its revision is at or
// below the revision cloud has landed. Cloud keeps deployments as an
// archive, so this is what lets the runtime forget a record without the
// history losing it. The retention floor alone is not enough, because it
// measures the deploy's age rather than how long cloud has had a chance
// to see it: a cluster upgrading with years of never-exported history
// would otherwise prune most of it before the first snapshot pinned its
// head. Nil, or an unregistered cluster, prunes on retention alone.
Exports ExportProgress
// contains filtered or unexported fields
}
GCController periodically applies retention policy to deployment records.
func (*GCController) RunGC ¶
func (c *GCController) RunGC(ctx context.Context) (*GCResult, error)
RunGC applies the retention policy to every app's deployment records.
func (*GCController) Start ¶
func (c *GCController) Start(ctx context.Context)
Start begins the periodic GC process.
type GCResult ¶
type GCResult struct {
// DeletedRecords is the number of records hard-deleted.
DeletedRecords int
// FailedRecords is the number of records that failed to delete.
FailedRecords int
// RetainedRecords is the number of records kept by retention policy.
RetainedRecords int
// AwaitingExport is the number of prune candidates kept because cloud
// has not yet confirmed it holds their final state.
AwaitingExport int
// TotalScanned is the number of deployment records evaluated.
TotalScanned int
}
GCResult contains information about records processed during a GC sweep.