provisioner

package
v0.0.0-...-b9bb202 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 56 Imported by: 2

Documentation

Overview

Package provisioner supplies the API facade used by the provisioner worker.

Versions of the API < 10 have logic dating from the original spaces implementation. If multiple positive space constraints are supplied, only the first in the list is used to determine possible subnet/AZ combinations suitable for machine location.

Version 10+ will consider all supplied positive space constraints when making this determination.

Index

Constants

This section is empty.

Variables

View Source
var ErrorRetryWaitDelay = 1 * time.Minute

ErrorRetryWaitDelay is the poll time currently used to trigger the watcher.

Functions

func Register

func Register(registry facade.FacadeRegistry)

Register is called to expose a package of facades onto a given registry.

Types

type AgentProvisionerService

type AgentProvisionerService interface {
	// ContainerManagerConfigForType returns the container manager config for
	// the given container type.
	ContainerManagerConfigForType(context.Context, instance.ContainerType) (containermanager.Config, error)
	// ContainerConfig returns the container configuration.
	ContainerConfig(ctx context.Context) (container.Config, error)
	// ContainerNetworkingMethod returns the networking method to use for newly
	// provisioned containers.
	ContainerNetworkingMethod(ctx context.Context) (containermanager.NetworkingMethod, error)
}

AgentProvisionerService provides access to container config.

type Application

type Application interface {
	Name() string
}

Application is an indirection for state.Application.

type ApplicationService

type ApplicationService interface {
	// GetCharmIDByApplicationName returns a charm ID by application name. It
	// returns an error if the charm can not be found by the name. This can also be
	// used as a cheap way to see if a charm exists without needing to load the
	// charm metadata.
	GetCharmIDByApplicationName(ctx context.Context, name string) (corecharm.ID, error)

	// GetCharmLXDProfile returns the LXD profile for the charm using the charm ID.
	GetCharmLXDProfile(ctx context.Context, id corecharm.ID) (internalcharm.LXDProfile, charm.Revision, error)
}

ApplicationService instances implement an application service.

type BridgePolicy

type BridgePolicy interface {
	// FindMissingBridgesForContainer looks at the spaces that the container should
	// have access to, and returns any host devices need to be bridged for use as
	// the container network.
	FindMissingBridgesForContainer(containerizer.Machine, containerizer.Container, corenetwork.SubnetInfos) ([]network.DeviceToBridge, int, error)

	// PopulateContainerLinkLayerDevices sets the link-layer devices of the input
	// guest, setting each device to be a child of the corresponding bridge on the
	// host machine.
	PopulateContainerLinkLayerDevices(
		containerizer.Machine, containerizer.Container, bool,
	) (corenetwork.InterfaceInfos, error)
}

BridgePolicy is an indirection for containerizer.BridgePolicy.

type CloudImageMetadataService

type CloudImageMetadataService interface {

	// SaveMetadata saves the provided cloud image metadata to the storage and returns an error if the operation fails.
	SaveMetadata(ctx context.Context, metadata []cloudimagemetadata.Metadata) error

	// FindMetadata searches for cloud image metadata based on the given filter criteria in a specific context.
	// It returns a set of image metadata grouped by region
	FindMetadata(ctx context.Context, criteria cloudimagemetadata.MetadataFilter) (map[string][]cloudimagemetadata.Metadata, error)
}

CloudImageMetadataService manages cloud image metadata for provisionning

type ControllerConfigService

type ControllerConfigService interface {
	// ControllerConfig returns this controller's config.
	ControllerConfig(context.Context) (controller.Config, error)
}

ControllerConfigService is the interface that the provisioner facade uses to get the controller config.

type KeyUpdaterService

type KeyUpdaterService interface {
	// GetInitialAuthorisedKeysForContainer returns the authorised keys to be used
	// when provisioning a new container.
	GetInitialAuthorisedKeysForContainer(ctx context.Context) ([]string, error)
}

KeyUpdaterService provides access to authorised keys in a model.

type Machine

type Machine interface {
	containerizer.Container

	Units() ([]Unit, error)
	IsManual() (bool, error)
	MachineTag() names.MachineTag
}

Machine is an indirection for use in container provisioning. It is an indirection for both containerizer.Machine and containerizer.Container as well as state.Machine locally.

type MachineService

type MachineService interface {
	// ShouldKeepInstance reports whether a machine, when removed from Juju, should cause
	// the corresponding cloud instance to be stopped.
	ShouldKeepInstance(ctx context.Context, machineName coremachine.Name) (bool, error)
	// SetKeepInstance sets whether the machine cloud instance will be retained
	// when the machine is removed from Juju. This is only relevant if an instance
	// exists.
	SetKeepInstance(ctx context.Context, machineName coremachine.Name, keep bool) error
	// 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)
	// SetAppliedLXDProfileNames sets the list of LXD profile names to the
	// lxd_profile table for the given machine. This method will overwrite the list
	// of profiles for the given machine without any checks.
	SetAppliedLXDProfileNames(ctx context.Context, mUUID string, profileNames []string) error
	// HardwareCharacteristics returns the hardware characteristics of the
	// specified machine.
	HardwareCharacteristics(ctx context.Context, machineUUID string) (*instance.HardwareCharacteristics, error)
	// InstanceID returns the cloud specific instance id for this machine.
	InstanceID(ctx context.Context, mUUID string) (instance.Id, error)
}

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

type MachineShim

type MachineShim struct {
	*state.Machine
}

MachineShim implements Machine. It is required for use of the containerizer and to mock container creation tests here.

func NewMachine

func NewMachine(m *state.Machine) *MachineShim

NewMachine wraps the given state.machine in a MachineShim.

func (*MachineShim) AllDeviceAddresses

func (m *MachineShim) AllDeviceAddresses() ([]containerizer.Address, error)

AllDeviceAddresses implements Machine by wrapping each state.Address reference in returned collection with the containerizer Address implementation.

func (*MachineShim) AllLinkLayerDevices

func (m *MachineShim) AllLinkLayerDevices() ([]containerizer.LinkLayerDevice, error)

AllLinkLayerDevices implements Machine by wrapping each state.LinkLayerDevice reference in returned collection with the containerizer LinkLayerDevice implementation.

func (*MachineShim) Raw

func (m *MachineShim) Raw() *state.Machine

Raw returns the inner state.Machine reference.

func (*MachineShim) Units

func (m *MachineShim) Units() ([]Unit, error)

Units implements Machine by wrapping each state.Unit reference in returned collection with the Unit implementation.

type ModelConfigService

type ModelConfigService interface {
	// ModelConfig returns the current config for the model.
	ModelConfig(context.Context) (*config.Config, error)
}

ModelConfigService is the interface that the provisioner facade uses to get the model config.

type ModelInfoService

type ModelInfoService interface {
	// GetModelInfo returns the readonly model information for the model in
	// question.
	GetModelInfo(context.Context) (model.ReadOnlyModel, error)
}

ModelInfoService describe the service for interacting and reading the underlying model information.

type NetworkService

type NetworkService interface {
	// GetAllSpaces returns all spaces for the model.
	GetAllSpaces(ctx context.Context) (network.SpaceInfos, error)
	// SpaceByName returns a space from state that matches the input name.
	// An error is returned that satisfied errors.NotFound if the space was not found
	// or an error static any problems fetching the given space.
	SpaceByName(ctx context.Context, name string) (*network.SpaceInfo, error)
	// GetAllSubnets returns all the subnets for the model.
	GetAllSubnets(ctx context.Context) (network.SubnetInfos, error)
}

NetworkService is the interface that is used to interact with the network spaces/subnets.

type ProvisionerAPI

ProvisionerAPI provides access to the Provisioner API facade.

func MakeProvisionerAPI

func MakeProvisionerAPI(stdCtx context.Context, ctx facade.ModelContext) (*ProvisionerAPI, error)

MakeProvisionerAPI creates a new server-side ProvisionerAPI facade.

func (*ProvisionerAPI) APIAddresses

func (api *ProvisionerAPI) APIAddresses(ctx context.Context) (result params.StringsResult, err error)

APIAddresses returns the list of addresses used to connect to the API.

func (*ProvisionerAPI) APIHostPorts

func (api *ProvisionerAPI) APIHostPorts(ctx context.Context) (result params.APIHostPortsResult, err error)

APIHostPorts returns the API server addresses.

func (*ProvisionerAPI) AvailabilityZone

func (api *ProvisionerAPI) AvailabilityZone(ctx context.Context, args params.Entities) (params.StringResults, error)

AvailabilityZone returns a provider-specific availability zone for each given machine entity

func (*ProvisionerAPI) CACert

func (api *ProvisionerAPI) CACert(ctx context.Context) (params.BytesResult, error)

CACert returns the certificate used to validate the state connection.

func (*ProvisionerAPI) Constraints

Constraints returns the constraints for each given machine entity.

func (*ProvisionerAPI) ContainerConfig

func (api *ProvisionerAPI) ContainerConfig(ctx context.Context) (params.ContainerConfig, error)

ContainerConfig returns information from the model config that is needed for container cloud-init.

func (*ProvisionerAPI) ContainerManagerConfig

ContainerManagerConfig returns information from the model config that is needed for configuring the container manager.

func (*ProvisionerAPI) DistributionGroup

func (api *ProvisionerAPI) DistributionGroup(ctx context.Context, args params.Entities) (params.DistributionGroupResults, error)

DistributionGroup returns, for each given machine entity, a slice of instance.Ids that belong to the same distribution group as that machine. This information may be used to distribute instances for high availability.

func (*ProvisionerAPI) DistributionGroupByMachineId

func (api *ProvisionerAPI) DistributionGroupByMachineId(ctx context.Context, args params.Entities) (params.StringsResults, error)

DistributionGroupByMachineId returns, for each given machine entity, a slice of machine.Ids that belong to the same distribution group as that machine. This information may be used to distribute instances for high availability.

func (*ProvisionerAPI) FindTools

FindTools returns a List containing all tools matching the given parameters.

func (*ProvisionerAPI) GetContainerInterfaceInfo

func (api *ProvisionerAPI) GetContainerInterfaceInfo(ctx context.Context, args params.Entities) (
	params.MachineNetworkConfigResults,
	error,
)

GetContainerInterfaceInfo returns information to configure networking for a container. It accepts container tags as arguments.

func (*ProvisionerAPI) GetContainerProfileInfo

func (api *ProvisionerAPI) GetContainerProfileInfo(ctx context.Context, args params.Entities) (params.ContainerProfileResults, error)

GetContainerProfileInfo returns information to configure a lxd profile(s) for a container based on the charms deployed to the container. It accepts container tags as arguments. Unlike machineLXDProfileNames which has the environ write the lxd profiles and returns the names of profiles already written.

func (*ProvisionerAPI) HostChangesForContainers

func (api *ProvisionerAPI) HostChangesForContainers(ctx context.Context, args params.Entities) (params.HostNetworkChangeResults, error)

HostChangesForContainers returns the set of changes that need to be done to the host machine to prepare it for the containers to be created. Pass in a list of the containers that you want the changes for.

func (*ProvisionerAPI) InstanceStatus

func (api *ProvisionerAPI) InstanceStatus(ctx context.Context, args params.Entities) (params.StatusResults, error)

InstanceStatus returns the instance status for each given entity. Only machine tags are accepted.

func (*ProvisionerAPI) KeepInstance

func (api *ProvisionerAPI) KeepInstance(ctx context.Context, args params.Entities) (params.BoolResults, error)

KeepInstance returns the keep-instance value for each given machine entity.

func (*ProvisionerAPI) MachinesWithTransientErrors

func (api *ProvisionerAPI) MachinesWithTransientErrors(ctx context.Context) (params.StatusResults, error)

MachinesWithTransientErrors returns status data for machines with provisioning errors which are transient.

func (*ProvisionerAPI) MarkMachinesForRemoval

func (api *ProvisionerAPI) MarkMachinesForRemoval(ctx context.Context, machines params.Entities) (params.ErrorResults, error)

MarkMachinesForRemoval indicates that the specified machines are ready to have any provider-level resources cleaned up and then be removed.

func (*ProvisionerAPI) ModelUUID

func (api *ProvisionerAPI) ModelUUID(ctx context.Context) params.StringResult

ModelUUID returns the model UUID that the current connection is for.

func (*ProvisionerAPI) PrepareContainerInterfaceInfo

func (api *ProvisionerAPI) PrepareContainerInterfaceInfo(ctx context.Context, args params.Entities) (
	params.MachineNetworkConfigResults,
	error,
)

PrepareContainerInterfaceInfo allocates an address and returns information to configure networking for a container. It accepts container tags as arguments.

func (*ProvisionerAPI) ProvisioningInfo

func (api *ProvisionerAPI) ProvisioningInfo(ctx context.Context, args params.Entities) (params.ProvisioningInfoResults, error)

ProvisioningInfo returns the provisioning information for each given machine entity. It supports all positive space constraints.

func (*ProvisionerAPI) ReleaseContainerAddresses

func (api *ProvisionerAPI) ReleaseContainerAddresses(ctx context.Context, args params.Entities) (params.ErrorResults, error)

ReleaseContainerAddresses finds addresses allocated to a container and marks them as Dead, to be released and removed. It accepts container tags as arguments.

func (*ProvisionerAPI) Remove

Remove removes every given machine from state. It will fail if the machine is not present.

func (*ProvisionerAPI) SetCharmProfiles

func (api *ProvisionerAPI) SetCharmProfiles(ctx context.Context, args params.SetProfileArgs) (params.ErrorResults, error)

SetCharmProfiles records the given slice of charm profile names.

func (*ProvisionerAPI) SetHostMachineNetworkConfig

func (api *ProvisionerAPI) SetHostMachineNetworkConfig(ctx context.Context, args params.SetMachineNetworkConfig) error

func (*ProvisionerAPI) SetInstanceInfo

func (api *ProvisionerAPI) SetInstanceInfo(ctx context.Context, args params.InstancesInfo) (params.ErrorResults, error)

SetInstanceInfo sets the provider specific machine id, nonce, metadata and network info for each given machine. Once set, the instance id cannot be changed.

func (*ProvisionerAPI) SetInstanceStatus

func (api *ProvisionerAPI) SetInstanceStatus(ctx context.Context, args params.SetStatus) (params.ErrorResults, error)

SetInstanceStatus updates the instance status for each given entity. Only machine tags are accepted.

func (*ProvisionerAPI) SetModificationStatus

func (api *ProvisionerAPI) SetModificationStatus(ctx context.Context, args params.SetStatus) (params.ErrorResults, error)

SetModificationStatus updates the instance whilst changes are occurring. This is different from SetStatus and SetInstanceStatus, by the fact this holds information about the ongoing changes that are happening to instances. Consider LXD Profile updates that can modify a instance, but may not cause the instance to be placed into a error state. This modification status serves the purpose of highlighting that to the operator. Only machine tags are accepted.

func (*ProvisionerAPI) SetSupportedContainers

func (api *ProvisionerAPI) SetSupportedContainers(ctx context.Context, args params.MachineContainersParams) (params.ErrorResults, error)

SetSupportedContainers updates the list of containers supported by the machines passed in args.

func (*ProvisionerAPI) SupportedContainers

func (api *ProvisionerAPI) SupportedContainers(ctx context.Context, args params.Entities) (params.MachineContainerResults, error)

SupportedContainers returns the list of containers supported by the machines passed in args.

func (*ProvisionerAPI) WatchAllContainers

func (api *ProvisionerAPI) WatchAllContainers(ctx context.Context, args params.WatchContainers) (params.StringsWatchResults, error)

WatchAllContainers starts a StringsWatcher to watch all containers deployed to any machine passed in args.

func (*ProvisionerAPI) WatchContainers

WatchContainers starts a StringsWatcher to watch containers deployed to any machine passed in args.

func (*ProvisionerAPI) WatchMachineErrorRetry

func (api *ProvisionerAPI) WatchMachineErrorRetry(ctx context.Context) (params.NotifyWatchResult, error)

WatchMachineErrorRetry returns a NotifyWatcher that notifies when the provisioner should retry provisioning machines with transient errors.

type ProvisionerAPIV11

type ProvisionerAPIV11 struct {
	*ProvisionerAPI
}

ProvisionerAPIV11 provides v10 of the provisioner facade. It relies on agent-set origin when calling SetHostMachineNetworkConfig.

type StoragePoolGetter

type StoragePoolGetter interface {
	// GetStoragePoolByName returns the storage pool with the specified name.
	GetStoragePoolByName(ctx context.Context, name string) (*storage.Config, error)
}

StoragePoolGetter instances get a storage pool by name.

type Unit

type Unit interface {
	Application() (Application, error)
	Name() string
}

Unit is an indirection for state.Unit.

Jump to

Keyboard shortcuts

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