Documentation
¶
Index ¶
- Constants
- Variables
- func InsertWorkspaceModule(ctx context.Context, db database.Store, jobID uuid.UUID, ...) error
- func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.UUID, ...) error
- func NewServer(lifecycleCtx context.Context, accessURL *url.URL, id uuid.UUID, ...) (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 ErrorTagsContainNullByte = xerrors.New("tags cannot contain the null byte (0x00)")
Functions ¶
func InsertWorkspaceModule ¶ added in v2.18.0
func InsertWorkspaceResource ¶
func NewServer ¶ added in v2.1.5
func NewServer( lifecycleCtx context.Context, accessURL *url.URL, id uuid.UUID, organizationID uuid.UUID, logger slog.Logger, provisioners []database.ProvisionerType, tags Tags, db database.Store, ps pubsub.Pubsub, acquirer *Acquirer, tel telemetry.Reporter, tracer trace.Tracer, quotaCommitter *atomic.Pointer[proto.QuotaCommitter], auditor *atomic.Pointer[audit.Auditor], templateScheduleStore *atomic.Pointer[schedule.TemplateScheduleStore], userQuietHoursScheduleStore *atomic.Pointer[schedule.UserQuietHoursScheduleStore], deploymentValues *codersdk.DeploymentValues, options Options, enqueuer notifications.Enqueuer, ) (proto.DRPCProvisionerDaemonServer, error)
Types ¶
type Acquirer ¶ added in v2.2.0
type Acquirer struct {
// contains filtered or unexported fields
}
Acquirer is shared among multiple routines that need to call database.Store.AcquireProvisionerJob. The callers that acquire jobs are called "acquirees". The goal is to minimize polling the database (i.e. lower our average query rate) and simplify the acquiree's logic by handling retrying the database if a job is not available at the time of the call.
When multiple acquirees share a set of provisioner types and tags, we define them as part of the same "domain". Only one acquiree from each domain may query the database at a time. If the database returns no jobs for that acquiree, the entire domain waits until the Acquirer is notified 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).
func NewAcquirer ¶ added in v2.2.0
func NewAcquirer(ctx context.Context, logger slog.Logger, store AcquirerStore, ps pubsub.Pubsub, opts ...AcquirerOption, ) *Acquirer
func (*Acquirer) AcquireJob ¶ added in v2.2.0
func (a *Acquirer) AcquireJob( ctx context.Context, organization uuid.UUID, worker uuid.UUID, pt []database.ProvisionerType, tags Tags, ) ( retJob database.ProvisionerJob, retErr error, )
AcquireJob acquires a job with one of the given provisioner types and compatible tags from the database. The call blocks until a job is acquired, the context is done, or the database returns an error _other_ than that no jobs are available. If no jobs are available, this method handles retrying as appropriate.
type AcquirerOption ¶ added in v2.2.0
type AcquirerOption func(*Acquirer)
func TestingBackupPollDuration ¶ added in v2.2.0
func TestingBackupPollDuration(dur time.Duration) AcquirerOption
type AcquirerStore ¶ added in v2.2.0
type AcquirerStore interface {
AcquireProvisionerJob(context.Context, database.AcquireProvisionerJobParams) (database.ProvisionerJob, error)
}
AcquirerStore is the subset of database.Store that the Acquirer needs
type Options ¶ added in v2.1.5
type Options struct { OIDCConfig promoauth.OAuth2Config ExternalAuthConfigs []*externalauth.Config // Clock for testing Clock quartz.Clock // AcquireJobLongPollDur is used in tests AcquireJobLongPollDur time.Duration // HeartbeatInterval is the interval at which the provisioner daemon // will update its last seen at timestamp in the database. HeartbeatInterval time.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 }
type TemplateVersionDryRunJob ¶
type TemplateVersionDryRunJob struct { TemplateVersionID uuid.UUID `json:"template_version_id"` WorkspaceName string `json:"workspace_name"` RichParameterValues []database.WorkspaceBuildParameter `json:"rich_parameter_values"` }
TemplateVersionDryRunJob is the payload for the "template_version_dry_run" job type.
type TemplateVersionImportJob ¶
type TemplateVersionImportJob struct { TemplateVersionID uuid.UUID `json:"template_version_id"` UserVariableValues []codersdk.VariableValue `json:"user_variable_values"` }