Movatterモバイル変換


[0]ホーム

URL:


prebuilds

package
v2.24.2Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License:AGPL-3.0Imports:30Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
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"MetricPresetHardLimitedGauge    = namespace + "preset_hard_limited"MetricLastUpdatedGauge          = namespace + "metrics_last_updated")

Variables

This section is empty.

Functions

This section is empty.

Types

typeEnterpriseClaimer

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

funcNewEnterpriseClaimer

func NewEnterpriseClaimer(storedatabase.Store) *EnterpriseClaimer

func (EnterpriseClaimer)Claim

func (cEnterpriseClaimer) Claim(ctxcontext.Context,userIDuuid.UUID,namestring,presetIDuuid.UUID,) (*uuid.UUID,error)

func (EnterpriseClaimer)Initiator

func (EnterpriseClaimer) Initiator()uuid.UUID

typeMetricsCollector

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

funcNewMetricsCollector

func NewMetricsCollector(dbdatabase.Store, loggerslog.Logger, snapshotterprebuilds.StateSnapshotter) *MetricsCollector

func (*MetricsCollector)BackgroundFetch

func (mc *MetricsCollector) BackgroundFetch(ctxcontext.Context, updateInterval, updateTimeouttime.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 stateis an expensive operation.

func (*MetricsCollector)Describe

func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc)

func (*MetricsCollector)UpdateState

func (mc *MetricsCollector) UpdateState(ctxcontext.Context, timeouttime.Duration)error

UpdateState builds the current metrics state.

typeStoreMembershipReconcileradded inv2.24.0

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

StoreMembershipReconciler encapsulates the responsibility of ensuring that the prebuilds system user is a member of allorganizations for which prebuilt workspaces are requested. This is necessary because our data model requires that suchprebuilt workspaces belong to a member of the organization of their eventual claimant.

funcNewStoreMembershipReconcileradded inv2.24.0

func NewStoreMembershipReconciler(storedatabase.Store, clockquartz.Clock)StoreMembershipReconciler

func (StoreMembershipReconciler)ReconcileAlladded inv2.24.0

ReconcileAll compares the current membership of a user to the membership required in order to create prebuilt workspaces.If the user in question is not yet a member of an organization that needs prebuilt workspaces, ReconcileAll will createthe membership required.

This method does not have an opinion on transaction or lock management. These responsibilities are left to the caller.

typeStoreReconciler

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

func (*StoreReconciler)CalculateActions

func (*StoreReconciler)ForceMetricsUpdate

func (c *StoreReconciler) ForceMetricsUpdate(ctxcontext.Context)error

ForceMetricsUpdate forces the metrics collector, if defined, to update its state (we cache the metrics state toreduce load on the database).

func (*StoreReconciler)ReconcileAll

func (c *StoreReconciler) ReconcileAll(ctxcontext.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 theirprovisioning. As a consequence, it's possible that another reconciliation run will occur, which will mean thatmultiple preset versions could be reconciling at once. This may mean some temporary over-provisioning, but thereconciliation 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 willbe reconciled again, leading to another workspace being provisioned. Two workspace builds will be occurringsimultaneously for the same preset, but once both jobs have completed the reconciliation loop will notice theextraneous instance and delete it.

func (*StoreReconciler)ReconcilePreset

func (*StoreReconciler)Run

func (c *StoreReconciler) Run(ctxcontext.Context)

func (*StoreReconciler)SnapshotState

SnapshotState captures the current state of all prebuilds across templates.

func (*StoreReconciler)Stop

func (c *StoreReconciler) Stop(ctxcontext.Context, causeerror)

func (*StoreReconciler)TrackResourceReplacement

func (c *StoreReconciler) TrackResourceReplacement(ctxcontext.Context, workspaceID, buildIDuuid.UUID, replacements []*sdkproto.ResourceReplacement)

func (*StoreReconciler)WithReconciliationLock

func (c *StoreReconciler) WithReconciliationLock(ctxcontext.Context,loggerslog.Logger,fn func(ctxcontext.Context, dbdatabase.Store)error,)error

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp