prebuilds

package
v2.29.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TemplateTarData

func TemplateTarData(numPresets, numPresetPrebuilds int) ([]byte, error)

Types

type Config

type Config struct {
	// OrganizationID is the ID of the organization to create the prebuilds in.
	OrganizationID uuid.UUID `json:"organization_id"`
	// NumPresets is the number of presets the template should have.
	NumPresets int `json:"num_presets"`
	// NumPresetPrebuilds is the number of prebuilds per preset.
	// Total prebuilds = NumPresets * NumPresetPrebuilds
	NumPresetPrebuilds int `json:"num_preset_prebuilds"`

	// TemplateVersionJobTimeout is how long to wait for template version
	// provisioning jobs to complete.
	TemplateVersionJobTimeout time.Duration `json:"template_version_job_timeout"`

	// PrebuildWorkspaceTimeout is how long to wait for all prebuild
	// workspaces to be created and completed.
	PrebuildWorkspaceTimeout time.Duration `json:"prebuild_workspace_timeout"`

	Metrics *Metrics `json:"-"`

	// SetupBarrier is used to ensure all templates have been created
	// before unpausing prebuilds.
	SetupBarrier *sync.WaitGroup `json:"-"`

	// CreationBarrier is used to ensure all prebuild creation has completed
	// before pausing prebuilds for deletion.
	CreationBarrier *sync.WaitGroup `json:"-"`

	// DeletionSetupBarrier is used by the runner owner (CLI/test) to signal when
	// prebuilds have been paused, allowing runners to create new template versions
	// with 0 prebuilds. Only the owner calls Done(), runners only Wait().
	DeletionSetupBarrier *sync.WaitGroup `json:"-"`

	// DeletionBarrier is used to ensure all templates have been updated
	// with 0 prebuilds before resuming prebuilds.
	DeletionBarrier *sync.WaitGroup `json:"-"`

	Clock quartz.Clock `json:"-"`
}

func (Config) Validate

func (c Config) Validate() error

type Metrics

type Metrics struct {
	PrebuildJobsCreated   prometheus.GaugeVec
	PrebuildJobsRunning   prometheus.GaugeVec
	PrebuildJobsFailed    prometheus.GaugeVec
	PrebuildJobsCompleted prometheus.GaugeVec

	PrebuildDeletionJobsCreated   prometheus.GaugeVec
	PrebuildDeletionJobsRunning   prometheus.GaugeVec
	PrebuildDeletionJobsFailed    prometheus.GaugeVec
	PrebuildDeletionJobsCompleted prometheus.GaugeVec

	PrebuildErrorsTotal prometheus.CounterVec
}

func NewMetrics

func NewMetrics(reg prometheus.Registerer) *Metrics

func (*Metrics) AddError

func (m *Metrics) AddError(templateName string, action string)

func (*Metrics) SetDeletionJobsCompleted

func (m *Metrics) SetDeletionJobsCompleted(count int, templateName string)

func (*Metrics) SetDeletionJobsCreated

func (m *Metrics) SetDeletionJobsCreated(count int, templateName string)

func (*Metrics) SetDeletionJobsFailed

func (m *Metrics) SetDeletionJobsFailed(count int, templateName string)

func (*Metrics) SetDeletionJobsRunning

func (m *Metrics) SetDeletionJobsRunning(count int, templateName string)

func (*Metrics) SetJobsCompleted

func (m *Metrics) SetJobsCompleted(count int, templateName string)

func (*Metrics) SetJobsCreated

func (m *Metrics) SetJobsCreated(count int, templateName string)

func (*Metrics) SetJobsFailed

func (m *Metrics) SetJobsFailed(count int, templateName string)

func (*Metrics) SetJobsRunning

func (m *Metrics) SetJobsRunning(count int, templateName string)

type Runner

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

func NewRunner

func NewRunner(client *codersdk.Client, cfg Config) *Runner

func (*Runner) Cleanup

func (r *Runner) Cleanup(ctx context.Context, _ string, logs io.Writer) error

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL