provisionerdserver
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Constants
- Variables
- func InsertWorkspaceModule(ctx context.Context, db database.Store, jobID uuid.UUID, ...) error
- func InsertWorkspacePresetAndParameters(ctx context.Context, db database.Store, templateVersionID uuid.UUID, ...) error
- func InsertWorkspacePresetsAndParameters(ctx context.Context, logger slog.Logger, db database.Store, jobID uuid.UUID, ...) error
- func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.UUID, ...) error
- func NewServer(lifecycleCtx context.Context, apiVersion string, accessURL *url.URL, ...) (proto.DRPCProvisionerDaemonServer, error)
- type Acquirer
- type AcquirerOption
- type AcquirerStore
- type Options
- type Tags
- type TemplateVersionDryRunJob
- type TemplateVersionImportJob
- type WorkspaceProvisionJob
Constants¶
const (// DefaultAcquireJobLongPollDur is the time the (deprecated) AcquireJob rpc waits to try to obtain a job before// canceling and returning an empty job.DefaultAcquireJobLongPollDur =time.Second * 5// DefaultHeartbeatInterval is the interval at which the provisioner daemon// will update its last seen at timestamp in the database.DefaultHeartbeatInterval =time.Minute// StaleInterval is the amount of time after the last heartbeat for which// the provisioner will be reported as 'stale'.StaleInterval = 90 *time.Second)
Variables¶
var ErrTagsContainNullByte =xerrors.New("tags cannot contain the null byte (0x00)")
Functions¶
funcInsertWorkspaceModule¶added inv2.18.0
funcInsertWorkspacePresetAndParameters¶added inv2.20.0
funcInsertWorkspacePresetsAndParameters¶added inv2.20.0
funcNewServer¶added inv2.1.5
func NewServer(lifecycleCtxcontext.Context,apiVersionstring,accessURL *url.URL,iduuid.UUID,organizationIDuuid.UUID,loggerslog.Logger,provisioners []database.ProvisionerType,tagsTags,dbdatabase.Store,pspubsub.Pubsub,acquirer *Acquirer,teltelemetry.Reporter,tracertrace.Tracer,quotaCommitter *atomic.Pointer[proto.QuotaCommitter],auditor *atomic.Pointer[audit.Auditor],templateScheduleStore *atomic.Pointer[schedule.TemplateScheduleStore],userQuietHoursScheduleStore *atomic.Pointer[schedule.UserQuietHoursScheduleStore],deploymentValues *codersdk.DeploymentValues,optionsOptions,enqueuernotifications.Enqueuer,prebuildsOrchestrator *atomic.Pointer[prebuilds.ReconciliationOrchestrator],) (proto.DRPCProvisionerDaemonServer,error)
Types¶
typeAcquirer¶added inv2.2.0
type Acquirer struct {// contains filtered or unexported fields}
Acquirer is shared among multiple routines that need to calldatabase.Store.AcquireProvisionerJob. The callers that acquire jobs are called "acquirees". Thegoal is to minimize polling the database (i.e. lower our average query rate) and simplify theacquiree's logic by handling retrying the database if a job is not available at the time of thecall.
When multiple acquirees share a set of provisioner types and tags, we define them as part of thesame "domain". Only one acquiree from each domain may query the database at a time. If thedatabase returns no jobs for that acquiree, the entire domain waits until the Acquirer isnotified over the pubsub of a new job acceptable to the domain.
As a backup to pubsub notifications, each domain is allowed to query periodically once every 30s.This ensures jobs are not stuck permanently if the service that created them fails to publish(e.g. a crash).
funcNewAcquirer¶added inv2.2.0
func NewAcquirer(ctxcontext.Context, loggerslog.Logger, storeAcquirerStore, pspubsub.Pubsub,opts ...AcquirerOption,) *Acquirer
func (*Acquirer)AcquireJob¶added inv2.2.0
func (a *Acquirer) AcquireJob(ctxcontext.Context, organizationuuid.UUID, workeruuid.UUID, pt []database.ProvisionerType, tagsTags,) (retJobdatabase.ProvisionerJob, retErrerror,)
AcquireJob acquires a job with one of the given provisioner types and compatibletags from the database. The call blocks until a job is acquired, the context isdone, or the database returns an error _other_ than that no jobs are available.If no jobs are available, this method handles retrying as appropriate.
typeAcquirerOption¶added inv2.2.0
type AcquirerOption func(*Acquirer)
funcTestingBackupPollDuration¶added inv2.2.0
func TestingBackupPollDuration(durtime.Duration)AcquirerOption
typeAcquirerStore¶added inv2.2.0
type AcquirerStore interface {AcquireProvisionerJob(context.Context,database.AcquireProvisionerJobParams) (database.ProvisionerJob,error)}
AcquirerStore is the subset of database.Store that the Acquirer needs
typeOptions¶added inv2.1.5
type Options struct {OIDCConfigpromoauth.OAuth2ConfigExternalAuthConfigs []*externalauth.Config// Clock for testingClockquartz.Clock// AcquireJobLongPollDur is used in testsAcquireJobLongPollDurtime.Duration// HeartbeatInterval is the interval at which the provisioner daemon// will update its last seen at timestamp in the database.HeartbeatIntervaltime.Duration// HeartbeatFn is the function that will be called at the interval// specified by HeartbeatInterval.// The default function just calls UpdateProvisionerDaemonLastSeenAt.// This is mainly used for testing.HeartbeatFn func(context.Context)error}
typeTemplateVersionDryRunJob¶
type TemplateVersionDryRunJob struct {TemplateVersionIDuuid.UUID `json:"template_version_id"`WorkspaceNamestring `json:"workspace_name"`RichParameterValues []database.WorkspaceBuildParameter `json:"rich_parameter_values"`}
TemplateVersionDryRunJob is the payload for the "template_version_dry_run" job type.
typeTemplateVersionImportJob¶
type TemplateVersionImportJob struct {TemplateVersionIDuuid.UUID `json:"template_version_id"`UserVariableValues []codersdk.VariableValue `json:"user_variable_values"`}
typeWorkspaceProvisionJob¶
type WorkspaceProvisionJob struct {WorkspaceBuildIDuuid.UUID `json:"workspace_build_id"`DryRunbool `json:"dry_run"`LogLevelstring `json:"log_level,omitempty"`PrebuiltWorkspaceBuildStagesdkproto.PrebuiltWorkspaceBuildStage `json:"prebuilt_workspace_stage,omitempty"`}
WorkspaceProvisionJob is the payload for the "workspace_provision" job type.