provisioner

package
v0.0.0-...-a0d7459 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: AGPL-3.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBridgePrefix = "br-"

DefaultBridgePrefix is the standard prefix we apply to a device to find a name for the associated bridge. (eg when bridging ens3 we create br-ens3)

Variables

View Source
var StartProvisioner = startProvisionerWorker

Override for testing.

Functions

func DefaultBridgeCreator

func DefaultBridgeCreator() func() (network.Bridger, error)

DefaultBridgeCreator returns a function that will create a bridger with all the default settings.

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold creates a manifold that runs an environemnt 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.

func NewKVMBroker

func NewKVMBroker(
	prepareHost PrepareHostFunc,
	api APICalls,
	manager container.Manager,
	agentConfig agent.Config,
) (environs.InstanceBroker, error)

NewKVMBroker creates a Broker that can be used to start KVM guests in a similar fashion to normal StartInstance requests. prepareHost is a callback that will be called when a new container is about to be started. It provides the intersection point where the host can update itself to be ready for whatever changes are necessary to have a functioning container. (such as bridging host devices.) manager is the infrastructure to actually launch the container. agentConfig is currently only used to find out the 'default' bridge to use when a specific network device is not specified in StartInstanceParams. This should be deprecated. And hopefully removed in the future.

func NewLXDBroker

func NewLXDBroker(
	prepareHost PrepareHostFunc,
	api APICalls,
	manager container.Manager,
	agentConfig agent.Config,
) (environs.InstanceBroker, error)

NewLXDBroker creates a Broker that can be used to start LXD containers in a similar fashion to normal StartInstance requests. prepareHost is a callback that will be called when a new container is about to be started. It provides the intersection point where the host can update itself to be ready for whatever changes are necessary to have a functioning container. (such as bridging host devices.) manager is the infrastructure to actually launch the container. agentConfig is currently only used to find out the 'default' bridge to use when a specific network device is not specified in StartInstanceParams. This should be deprecated. And hopefully removed in the future.

Types

type APICalls

type APICalls interface {
	ContainerConfig() (params.ContainerConfig, error)
	PrepareContainerInterfaceInfo(names.MachineTag) ([]network.InterfaceInfo, error)
	GetContainerInterfaceInfo(names.MachineTag) ([]network.InterfaceInfo, error)
	ReleaseContainerAddresses(names.MachineTag) error
	SetHostMachineNetworkConfig(names.MachineTag, []params.NetworkConfig) error
	HostChangesForContainer(containerTag names.MachineTag) ([]network.DeviceToBridge, int, error)
}

type ClassifiableMachine

type ClassifiableMachine interface {
	Life() params.Life
	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.

type ContainerSetupParams

type ContainerSetupParams struct {
	Runner              *worker.Runner
	WorkerName          string
	SupportedContainers []instance.ContainerType
	Machine             *apiprovisioner.Machine
	Provisioner         *apiprovisioner.State
	Config              agent.Config
	InitLockName        string
}

ContainerSetupParams are used to initialise a container setup handler.

type HostPreparer

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

HostPreparer calls out to the PrepareAPI to find out what changes need to be done on this host to allow a new container to be started.

func NewHostPreparer

func NewHostPreparer(params HostPreparerParams) *HostPreparer

NewHostPreparer creates a HostPreparer using the supplied parameters

func (*HostPreparer) Prepare

func (hp *HostPreparer) Prepare(containerTag names.MachineTag) error

Prepare applies changes to the host machine that are necessary to create the requested container.

type HostPreparerParams

type HostPreparerParams struct {
	API                PrepareAPI
	ObserveNetworkFunc func() ([]params.NetworkConfig, error)
	LockName           string
	AcquireLockFunc    func(<-chan struct{}) (mutex.Releaser, error)
	CreateBridger      func() (network.Bridger, error)
	AbortChan          <-chan struct{}
	MachineTag         names.MachineTag
	Logger             loggo.Logger
}

HostPreparerParams is the configuration for HostPreparer

type MachineClassification

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

type MachineGetter

type MachineGetter interface {
	Machine(names.MachineTag) (*apiprovisioner.Machine, error)
	MachinesWithTransientErrors() ([]*apiprovisioner.Machine, []params.StatusResult, error)
}

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string
	EnvironName   string

	NewProvisionerFunc func(*apiprovisioner.State, agent.Config, environs.Environ) (Provisioner, 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 PrepareAPI

type PrepareAPI interface {
	// HostChangesForContainer returns the list of bridges to be created on the
	// host machine, and the time to sleep after creating the bridges before
	// bringing them up.
	HostChangesForContainer(names.MachineTag) ([]network.DeviceToBridge, int, error)
	// SetHostMachineNetworkConfig allows us to report back the host machine's
	// current networking config. This is called after we've created new
	// bridges to inform the Controller what the current networking interfaces
	// are.
	SetHostMachineNetworkConfig(names.MachineTag, []params.NetworkConfig) error
}

PrepareAPI is the functional interface that we need to be able to ask what changes are necessary, and to then report back what changes have been done to the host machine.

type PrepareHostFunc

type PrepareHostFunc func(containerTag names.MachineTag, log loggo.Logger) error

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,
	agentConfig agent.Config,
	broker environs.InstanceBroker,
	toolsFinder ToolsFinder,
) (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, environ environs.Environ) (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,
	machineTag names.MachineTag,
	harvestMode config.HarvestMode,
	machineGetter MachineGetter,
	toolsFinder ToolsFinder,
	machineWatcher watcher.StringsWatcher,
	retryWatcher watcher.NotifyWatcher,
	broker environs.InstanceBroker,
	auth authentication.AuthenticationProvider,
	imageStream string,
	retryStartInstanceStrategy RetryStrategy,
) (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.

Jump to

Keyboard shortcuts

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