caasapplicationprovisioner

package
v0.0.0-...-2f78cd6 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 27 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
	UnitFacade CAASUnitProvisionerFacade
	Ops        ApplicationOps
	StatusOnly bool
}

type ApplicationOps

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

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

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

	VerifyCharmUpgraded(appName string,
		facade CAASProvisionerFacade, tomb Tomb, logger Logger) (shouldExit bool, err error)

	UpgradePodSpec(appName string,
		broker CAASBroker, clk clock.Clock, tomb Tomb, logger Logger) error

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

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

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

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

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

	EnsureScale(appName string, app caas.Application, appLife life.Value,
		facade CAASProvisionerFacade, unitFacade CAASUnitProvisionerFacade, 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(appName string, mode caas.DeploymentMode, podName string, unit names.UnitTag) error
	DeleteOperator(appName string) error
	DeleteService(appName string) error
	OperatorExists(appName string) (caas.DeploymentState, error)
	Units(appName string, mode caas.DeploymentMode) ([]caas.Unit, error)
}

CAASBroker exposes CAAS broker functionality to a worker.

type CAASProvisionerFacade

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

CAASProvisionerFacade exposes CAAS provisioning functionality to a worker.

type CAASUnitProvisionerFacade

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

type Config

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

Config defines the operation of a Worker.

type Logger

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

	Child(string) loggo.Logger
}

Logger represents the methods used by the worker to log details.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string
	BrokerName    string
	ClockName     string
	NewWorker     func(Config) (worker.Worker, error)
	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