caasapplicationprovisioner

package
v0.0.0-...-f88c608 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package caasapplicationprovisioner defines two types of worker:

  • provisioner: Watches a Kubernetes model and starts a new worker of the appWorker type whenever an application is created.
  • appWorker: Drives the Kubernetes provider to create, manage, and destroy Kubernetes resources to match a requested state. Also writes the state of created resources (application/unit status, application/unit IP addresses & ports, filesystem info, etc.) back into the database.

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 a CAAS operator provisioner. See the ManifoldConfig type for discussion about how this can/should evolve.

func NewAppWorker

func NewAppWorker(config AppWorkerConfig) func() (worker.Worker, error)

func NewProvisionerWorker

func NewProvisionerWorker(config Config) (worker.Worker, error)

NewProvisionerWorker starts and returns a new CAAS provisioner worker.

Types

type AppWorkerConfig

type AppWorkerConfig struct {
	Name       string
	Facade     CAASProvisionerFacade
	Broker     CAASBroker
	ModelTag   names.ModelTag
	Clock      clock.Clock
	Logger     logger.Logger
	UnitFacade CAASUnitProvisionerFacade
	Ops        ApplicationOps
	StatusOnly bool
}

type ApplicationOps

type ApplicationOps interface {
	AppAlive(ctx context.Context, appName string, app caas.Application,
		password string, lastApplied *caas.ApplicationConfig,
		facade CAASProvisionerFacade, clk clock.Clock, logger logger.Logger) error

	AppDying(ctx context.Context, appName string, app caas.Application, appLife life.Value,
		facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, logger logger.Logger) error

	AppDead(ctx context.Context, appName string, app caas.Application,
		broker CAASBroker, facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade,
		clk clock.Clock, logger logger.Logger) error

	CheckCharmFormat(ctx context.Context, appName string,
		facade CAASProvisionerFacade, logger logger.Logger) (isOk bool, err error)

	EnsureTrust(ctx context.Context, appName string, app caas.Application,
		unitFacade CAASUnitProvisionerFacade, logger logger.Logger) error

	UpdateState(ctx context.Context, appName string, app caas.Application, lastReportedStatus map[string]status.StatusInfo,
		broker CAASBroker, facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, logger logger.Logger) (map[string]status.StatusInfo, error)

	RefreshApplicationStatus(ctx context.Context, appName string, app caas.Application, appLife life.Value,
		facade CAASProvisionerFacade, logger logger.Logger) error

	WaitForTerminated(appName string, app caas.Application,
		clk clock.Clock) error

	ReconcileDeadUnitScale(ctx context.Context, appName string, app caas.Application,
		facade CAASProvisionerFacade, logger logger.Logger) error

	EnsureScale(ctx context.Context, appName string, app caas.Application, appLife life.Value,
		facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, logger logger.Logger) error
}

ApplicationOps defines all the operations the application worker can perform. This is exported for testing only.

type CAASBroker

type CAASBroker interface {
	Application(string, caas.DeploymentType) caas.Application
	AnnotateUnit(ctx context.Context, appName string, podName string, unit names.UnitTag) error
	Units(ctx context.Context, appName string) ([]caas.Unit, error)
}

CAASBroker exposes CAAS broker functionality to a worker.

type CAASProvisionerFacade

type CAASProvisionerFacade interface {
	ProvisioningInfo(context.Context, string) (api.ProvisioningInfo, error)
	WatchApplications(context.Context) (watcher.StringsWatcher, error)
	SetPassword(context.Context, string, string) error
	Life(context.Context, string) (life.Value, error)
	CharmInfo(context.Context, string) (*charmscommon.CharmInfo, error)
	ApplicationCharmInfo(context.Context, string) (*charmscommon.CharmInfo, error)
	SetOperatorStatus(ctx context.Context, appName string, status status.Status, message string, data map[string]interface{}) error
	Units(ctx context.Context, appName string) ([]params.CAASUnit, error)
	ApplicationOCIResources(ctx context.Context, appName string) (map[string]resource.DockerImageDetails, error)
	UpdateUnits(ctx context.Context, arg params.UpdateApplicationUnits) (*params.UpdateApplicationUnitsInfo, error)
	WatchApplication(ctx context.Context, appName string) (watcher.NotifyWatcher, error)
	ClearApplicationResources(ctx context.Context, appName string) error
	WatchUnits(ctx context.Context, application string) (watcher.StringsWatcher, error)
	RemoveUnit(ctx context.Context, unitName string) error
	WatchProvisioningInfo(context.Context, string) (watcher.NotifyWatcher, error)
	DestroyUnits(ctx context.Context, unitNames []string) error
	ProvisioningState(context.Context, string) (*params.CAASApplicationProvisioningState, error)
	SetProvisioningState(context.Context, string, params.CAASApplicationProvisioningState) error
	ProvisionerConfig(context.Context) (params.CAASApplicationProvisionerConfig, error)
}

CAASProvisionerFacade exposes CAAS provisioning functionality to a worker.

type CAASUnitProvisionerFacade

type CAASUnitProvisionerFacade interface {
	ApplicationScale(context.Context, string) (int, error)
	WatchApplicationScale(context.Context, string) (watcher.NotifyWatcher, error)
	ApplicationTrust(context.Context, string) (bool, error)
	WatchApplicationTrustHash(context.Context, string) (watcher.StringsWatcher, error)
	UpdateApplicationService(ctx context.Context, arg params.UpdateApplicationServiceArg) error
}

type Config

type Config struct {
	Facade       CAASProvisionerFacade
	Broker       CAASBroker
	ModelTag     names.ModelTag
	Clock        clock.Clock
	Logger       logger.Logger
	NewAppWorker NewAppWorkerFunc
	UnitFacade   CAASUnitProvisionerFacade
}

Config defines the operation of a Worker.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string
	BrokerName    string
	ClockName     string
	NewWorker     func(Config) (worker.Worker, error)
	Logger        logger.Logger
}

ManifoldConfig defines a CAAS operator provisioner's dependencies.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

type NewAppWorkerFunc

type NewAppWorkerFunc func(AppWorkerConfig) func() (worker.Worker, error)

type Runner

type Runner interface {
	Worker(id string, abort <-chan struct{}) (worker.Worker, error)
	StartWorker(id string, startFunc func() (worker.Worker, error)) error
	StopAndRemoveWorker(id string, abort <-chan struct{}) error
	worker.Worker
}

Runner exposes functionalities of a worker.Runner.

type Tomb

type Tomb interface {
	Dying() <-chan struct{}
	ErrDying() error
}

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