Movatterモバイル変換


[0]ホーム

URL:


prebuilds

package
v2.28.4Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License:AGPL-3.0Imports:32Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const (PrebuiltWorkspacesGroupName        = "coderprebuiltworkspaces"PrebuiltWorkspacesGroupDisplayName = "Prebuilt Workspaces")
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"MetricReconciliationPausedGauge = namespace + "reconciliation_paused")

Variables

This section is empty.

Functions

funcSetPrebuildsReconciliationPausedadded inv2.25.0

func SetPrebuildsReconciliationPaused(ctxcontext.Context, dbdatabase.Store, pausedbool)error

Types

typeDeprovisionModeadded inv2.28.0

type DeprovisionModeint
const (DeprovisionModeNormalDeprovisionMode =iotaDeprovisionModeOrphan)

func (DeprovisionMode)Stringadded inv2.28.0

func (dDeprovisionMode) String()string

typeEnterpriseClaimer

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

funcNewEnterpriseClaimer

func NewEnterpriseClaimer(storedatabase.Store) *EnterpriseClaimer

func (EnterpriseClaimer)Claim

func (cEnterpriseClaimer) Claim(ctxcontext.Context,nowtime.Time,userIDuuid.UUID,namestring,presetIDuuid.UUID,autostartSchedulesql.NullString,nextStartAtsql.NullTime,ttlsql.NullInt64,) (*uuid.UUID,error)

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.

typeSettingsadded inv2.25.0

type Settings struct {ReconciliationPausedbool `json:"reconciliation_paused"`}

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, loggerslog.Logger)StoreMembershipReconciler

func (StoreMembershipReconciler)ReconcileAlladded inv2.24.0

func (sStoreMembershipReconciler) ReconcileAll(ctxcontext.Context, userIDuuid.UUID, groupNamestring)error

ReconcileAll ensures the prebuilds system user has the necessary memberships to create prebuilt workspaces.For each organization with prebuilds configured, it ensures:* The user is a member of the organization* A group exists with quota 0* The user is a member of that group

Unique constraint violations are safely ignored (concurrent creation).

ReconcileAll 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) (statsprebuilds.ReconcileStats, errerror)

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