Documentation
¶
Index ¶
- Constants
- type EnterpriseClaimer
- type MetricsCollector
- func (mc *MetricsCollector) BackgroundFetch(ctx context.Context, updateInterval, updateTimeout time.Duration)
- func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric)
- func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc)
- func (mc *MetricsCollector) UpdateState(ctx context.Context, timeout time.Duration) error
- type StoreReconciler
- func (c *StoreReconciler) CalculateActions(ctx context.Context, snapshot prebuilds.PresetSnapshot) (*prebuilds.ReconciliationActions, error)
- func (c *StoreReconciler) ForceMetricsUpdate(ctx context.Context) error
- func (c *StoreReconciler) ReconcileAll(ctx context.Context) error
- func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.PresetSnapshot) error
- func (c *StoreReconciler) Run(ctx context.Context)
- func (c *StoreReconciler) SnapshotState(ctx context.Context, store database.Store) (*prebuilds.GlobalSnapshot, error)
- func (c *StoreReconciler) Stop(ctx context.Context, cause error)
- func (c *StoreReconciler) TrackResourceReplacement(ctx context.Context, workspaceID, buildID uuid.UUID, ...)
- func (c *StoreReconciler) WithReconciliationLock(ctx context.Context, logger slog.Logger, ...) error
Constants ¶
const ( MetricCreatedCount = namespace + "created_total" MetricFailedCount = namespace + "failed_total" MetricClaimedCount = namespace + "claimed_total" MetricResourceReplacementsCount = namespace + "resource_replacements_total" MetricDesiredGauge = namespace + "desired" MetricRunningGauge = namespace + "running" MetricEligibleGauge = namespace + "eligible" MetricLastUpdatedGauge = namespace + "metrics_last_updated" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnterpriseClaimer ¶
type EnterpriseClaimer struct {
// contains filtered or unexported fields
}
func NewEnterpriseClaimer ¶
func NewEnterpriseClaimer(store database.Store) *EnterpriseClaimer
func (EnterpriseClaimer) Initiator ¶
func (EnterpriseClaimer) Initiator() uuid.UUID
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
func NewMetricsCollector ¶
func NewMetricsCollector(db database.Store, logger slog.Logger, snapshotter prebuilds.StateSnapshotter) *MetricsCollector
func (*MetricsCollector) BackgroundFetch ¶
func (mc *MetricsCollector) BackgroundFetch(ctx context.Context, updateInterval, updateTimeout time.Duration)
BackgroundFetch updates the metrics state every given interval.
func (*MetricsCollector) Collect ¶
func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric)
Collect uses the cached state to set configured metrics. The state is cached because this function can be called multiple times per second and retrieving the current state is an expensive operation.
func (*MetricsCollector) Describe ¶
func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc)
func (*MetricsCollector) UpdateState ¶
UpdateState builds the current metrics state.
type StoreReconciler ¶
type StoreReconciler struct {
// contains filtered or unexported fields
}
func NewStoreReconciler ¶
func NewStoreReconciler(store database.Store, ps pubsub.Pubsub, cfg codersdk.PrebuildsConfig, logger slog.Logger, clock quartz.Clock, registerer prometheus.Registerer, notifEnq notifications.Enqueuer, ) *StoreReconciler
func (*StoreReconciler) CalculateActions ¶
func (c *StoreReconciler) CalculateActions(ctx context.Context, snapshot prebuilds.PresetSnapshot) (*prebuilds.ReconciliationActions, error)
func (*StoreReconciler) ForceMetricsUpdate ¶
func (c *StoreReconciler) ForceMetricsUpdate(ctx context.Context) error
ForceMetricsUpdate forces the metrics collector, if defined, to update its state (we cache the metrics state to reduce load on the database).
func (*StoreReconciler) ReconcileAll ¶
func (c *StoreReconciler) ReconcileAll(ctx context.Context) error
ReconcileAll will attempt to resolve the desired vs actual state of all templates which have presets with prebuilds configured.
NOTE:
This function will kick of n provisioner jobs, based on the calculated state modifications.
These provisioning jobs are fire-and-forget. We DO NOT wait for the prebuilt workspaces to complete their provisioning. As a consequence, it's possible that another reconciliation run will occur, which will mean that multiple preset versions could be reconciling at once. This may mean some temporary over-provisioning, but the reconciliation loop will bring these resources back into their desired numbers in an EVENTUALLY-consistent way.
For example: we could decide to provision 1 new instance in this reconciliation. While that workspace is being provisioned, another template version is created which means this same preset will be reconciled again, leading to another workspace being provisioned. Two workspace builds will be occurring simultaneously for the same preset, but once both jobs have completed the reconciliation loop will notice the extraneous instance and delete it.
func (*StoreReconciler) ReconcilePreset ¶
func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.PresetSnapshot) error
func (*StoreReconciler) Run ¶
func (c *StoreReconciler) Run(ctx context.Context)
func (*StoreReconciler) SnapshotState ¶
func (c *StoreReconciler) SnapshotState(ctx context.Context, store database.Store) (*prebuilds.GlobalSnapshot, error)
SnapshotState captures the current state of all prebuilds across templates.
func (*StoreReconciler) TrackResourceReplacement ¶
func (c *StoreReconciler) TrackResourceReplacement(ctx context.Context, workspaceID, buildID uuid.UUID, replacements []*sdkproto.ResourceReplacement)