computeprovisioner

package
v0.0.0-...-5175f08 Latest Latest
Warning

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

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

Documentation

Overview

Package computeprovisioner defines the compute provisioner worker. This worker is responsible for provisioning new compute (machine) instances in the cloud provider when a new machine is added to the model.

This worker, the same as the containerprovisioner, will retrieve the machines from the database and simply do the provisioning.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold creates a manifold that runs an environment provisioner. See the ManifoldConfig type for discussion about how this can/should evolve.

Types

type ControllerAPI

type ControllerAPI interface {
	ControllerConfig(context.Context) (controller.Config, error)
	CACert(context.Context) (string, error)
	ModelUUID(context.Context) (string, error)
	ModelConfig(context.Context) (*config.Config, error)
	WatchForModelConfigChanges(context.Context) (watcher.NotifyWatcher, error)
	APIAddresses(context.Context) ([]string, error)
}

ControllerAPI describes API methods for querying a controller.

type DistributionGroupFinder

type DistributionGroupFinder interface {
	DistributionGroupByMachineId(context.Context, ...names.MachineTag) ([]apiprovisioner.DistributionGroupResult, error)
}

DistributionGroupFinder provides access to machine distribution groups.

type Environ

type Environ interface {
	environs.InstanceBroker
	environs.ConfigSetter
}

Environ describes the methods for provisioning instances.

type GetMachineServiceFunc

type GetMachineServiceFunc func(getter dependency.Getter, name string) (MachineService, error)

GetMachineFunc is a helper function that gets a service from the manifold.

type MachineService

type MachineService interface {
	// SetMachineCloudInstance sets an entry in the machine cloud instance table
	// along with the instance tags and the link to a lxd profile if any.
	SetMachineCloudInstance(ctx context.Context, machineUUID string, instanceID instance.Id, displayName string, hardwareCharacteristics *instance.HardwareCharacteristics) error
	// GetMachineUUID returns the UUID of a machine identified by its name.
	GetMachineUUID(ctx context.Context, name coremachine.Name) (string, error)
}

MachineService defines the methods that the worker assumes from the Machine service.

func GetMachineService

func GetMachineService(getter dependency.Getter, name string) (MachineService, error)

GetMachineService is a helper function that gets a service from the manifold.

type MachinesAPI

type MachinesAPI interface {
	Machines(context.Context, ...names.MachineTag) ([]apiprovisioner.MachineResult, error)
	MachinesWithTransientErrors(context.Context) ([]apiprovisioner.MachineStatusResult, error)
	WatchMachineErrorRetry(context.Context) (watcher.NotifyWatcher, error)
	WatchModelMachines(context.Context) (watcher.StringsWatcher, error)
	ProvisioningInfo(_ context.Context, machineTags []names.MachineTag) (params.ProvisioningInfoResults, error)
}

MachinesAPI describes API methods required to access machine provisioning info.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName          string
	APICallerName      string
	EnvironName        string
	DomainServicesName string
	GetMachineService  GetMachineServiceFunc
	Logger             logger.Logger

	NewProvisionerFunc           func(ControllerAPI, MachineService, MachinesAPI, ToolsFinder, DistributionGroupFinder, agent.Config, logger.Logger, Environ, common.CredentialAPI) (Provisioner, error)
	NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
}

ManifoldConfig defines an environment provisioner's dependencies. It's not currently clear whether it'll be easier to extend this type to include all provisioners, or to create separate (Environ|Container)Manifold[Config]s; for now we dodge the question because we don't need container provisioners in dependency engines. Yet.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

type Provisioner

type Provisioner interface {
	worker.Worker
	// contains filtered or unexported methods
}

Provisioner represents a running provisioner worker.

func NewEnvironProvisioner

func NewEnvironProvisioner(
	controllerAPI ControllerAPI,
	machineService MachineService,
	machinesAPI MachinesAPI,
	toolsFinder ToolsFinder,
	distributionGroupFinder DistributionGroupFinder,
	agentConfig agent.Config,
	logger logger.Logger,
	environ Environ,
	credentialAPI common.CredentialAPI,
) (Provisioner, error)

NewEnvironProvisioner returns a new Provisioner for an environment. When new machines are added to the state, it allocates instances from the environment and allocates them to the new machines.

type ToolsFinder

type ToolsFinder interface {
	// FindTools returns a list of tools matching the specified
	// version, os, and architecture. If arch is empty, the
	// implementation is expected to use a well documented default.
	FindTools(ctx context.Context, version version.Number, os string, arch string) (coretools.List, error)
}

ToolsFinder is an interface used for finding tools to run on provisioned instances.

Jump to

Keyboard shortcuts

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