provisioner

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: AGPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StartProvisioner = startProvisionerWorker

Override for testing.

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.

func NewContainerSetupHandler

func NewContainerSetupHandler(params ContainerSetupParams) watcher.StringsHandler

NewContainerSetupHandler returns a StringsWatchHandler which is notified when containers are created on the given machine.

Types

type AvailabilityZoneMachine

type AvailabilityZoneMachine struct {
	ZoneName           string
	MachineIds         set.Strings
	FailedMachineIds   set.Strings
	ExcludedMachineIds set.Strings // Don't use these machines in the zone.
}

AvailabilityZoneMachine keeps track a single zone and which machines are in it, which machines have failed to use it and which machines shouldn't use it. This data is used to decide on how to distribute machines across availability zones.

Exposed for testing.

func (*AvailabilityZoneMachine) MatchesConstraints

func (az *AvailabilityZoneMachine) MatchesConstraints(cons constraints.Value) bool

MatchesConstraints against an AZ. If the constraints specifies Zones, make sure this AZ matches a listed ZoneName.

type ClassifiableMachine

type ClassifiableMachine interface {
	Life() life.Value
	InstanceId() (instance.Id, error)
	EnsureDead() error
	Status() (status.Status, string, error)
	InstanceStatus() (status.Status, string, error)
	Id() string
}

type ContainerSetup

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

ContainerSetup is a StringsWatchHandler that is notified when containers are created on the given machine. It will set up the machine to be able to create containers and start a suitable provisioner.

func (*ContainerSetup) Handle

func (cs *ContainerSetup) Handle(abort <-chan struct{}, containerIds []string) (resultError error)

Handle is called whenever containers change on the machine being watched. Machines start out with no containers so the first time Handle is called, it will be because a container has been added.

func (*ContainerSetup) SetUp

func (cs *ContainerSetup) SetUp() (watcher watcher.StringsWatcher, err error)

SetUp is defined on the StringsWatchHandler interface.

func (*ContainerSetup) TearDown

func (cs *ContainerSetup) TearDown() error

TearDown is defined on the StringsWatchHandler interface. NoOp here.

type ContainerSetupParams

type ContainerSetupParams struct {
	Runner              *worker.Runner
	Logger              Logger
	WorkerName          string
	SupportedContainers []instance.ContainerType
	Machine             apiprovisioner.MachineProvisioner
	Provisioner         *apiprovisioner.State
	Config              agent.Config
	MachineLock         machinelock.Lock
	CredentialAPI       workercommon.CredentialAPI
}

ContainerSetupParams are used to initialise a container setup handler.

type DistributionGroupFinder

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

type LXDProfileInstanceBroker

type LXDProfileInstanceBroker interface {
	environs.InstanceBroker
	environs.LXDProfiler
}

This is needed to test provisioner.processProfileChanges

type Logger

type Logger interface {
	Tracef(string, ...interface{})
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warningf(string, ...interface{})
	Errorf(string, ...interface{})
}

Logger defines the logging methods that the worker uses.

type MachineClassification

type MachineClassification string
const (
	None    MachineClassification = "none"
	Pending MachineClassification = "Pending"
	Dead    MachineClassification = "Dead"
)

type MachineGetter

type MachineGetter interface {
	Machines(...names.MachineTag) ([]apiprovisioner.MachineResult, error)
	MachinesWithTransientErrors() ([]apiprovisioner.MachineStatusResult, error)
}

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string
	EnvironName   string
	Logger        Logger

	NewProvisionerFunc           func(*apiprovisioner.State, agent.Config, Logger, environs.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.

type Provisioner

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

Provisioner represents a running provisioner worker.

func NewContainerProvisioner

func NewContainerProvisioner(
	containerType instance.ContainerType,
	st *apiprovisioner.State,
	logger Logger,
	agentConfig agent.Config,
	broker environs.InstanceBroker,
	toolsFinder ToolsFinder,
	distributionGroupFinder DistributionGroupFinder,
	credentialAPI common.CredentialAPI,
) (Provisioner, error)

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

func NewEnvironProvisioner

func NewEnvironProvisioner(
	st *apiprovisioner.State,
	agentConfig agent.Config,
	logger Logger,
	environ environs.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 ProvisionerTask

type ProvisionerTask interface {
	worker.Worker

	// SetHarvestMode sets a flag to indicate how the provisioner task
	// should harvest machines. See config.HarvestMode for
	// documentation of behavior.
	SetHarvestMode(mode config.HarvestMode)
}

func NewProvisionerTask

func NewProvisionerTask(
	controllerUUID string,
	hostTag names.Tag,
	logger Logger,
	harvestMode config.HarvestMode,
	machineGetter MachineGetter,
	distributionGroupFinder DistributionGroupFinder,
	toolsFinder ToolsFinder,
	machineWatcher watcher.StringsWatcher,
	retryWatcher watcher.NotifyWatcher,
	broker environs.InstanceBroker,
	auth authentication.AuthenticationProvider,
	imageStream string,
	retryStartInstanceStrategy RetryStrategy,
	cloudCallContextFunc common.CloudCallContextFunc,
) (ProvisionerTask, error)

type RetryStrategy

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

RetryStrategy defines the retry behavior when encountering a retryable error during provisioning.

TODO(katco): 2016-08-09: lp:1611427

func NewRetryStrategy

func NewRetryStrategy(delay time.Duration, count int) RetryStrategy

NewRetryStrategy returns a new retry strategy with the specified delay and count for use with retryable provisioning errors.

type ToolsFinder

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

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

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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