caasoperator

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStateFile = errors.New("operator state file does not exist")

ErrNoStateFile is used to indicate an operator state file does not exist.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency manifold that runs a caasoperator worker, using the resource names defined in the supplied config.

func NewWorker

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

NewWorker creates a new worker which will install and operate a CaaS-based application, by executing hooks and operations in response to application state changes.

Types

type ApplicationWatcher

type ApplicationWatcher interface {
	Watch(string) (watcher.NotifyWatcher, error)
}

ApplicationWatcher provides an interface watching for application changes.

type CharmConfigGetter

type CharmConfigGetter interface {
	CharmConfig(string) (charm.Settings, error)
	WatchCharmConfig(string) (watcher.NotifyWatcher, error)
}

CharmConfigGetter provides an interface for watching and getting the application's charm config settings.

type CharmGetter

type CharmGetter interface {
	Charm(application string) (_ *charm.URL, force bool, sha256 string, vers int, _ error)
}

CharmGetter provides an interface for getting the URL and SHA256 hash of the charm currently assigned to the application.

type Client

Client provides an interface for interacting with the CAASOperator API. Subsets of this should be passed to the CAASOperator worker.

type Config

type Config struct {
	// ModelUUID is the UUID of the model.
	ModelUUID string

	// ModelName is the name of the model.
	ModelName string

	// Application holds the name of the application that
	// this CAAS operator manages.
	Application string

	// CharmGetter is an interface used for getting the
	// application's charm URL and SHA256 hash.
	CharmGetter CharmGetter

	// Clock holds the clock to be used by the CAAS operator
	// for time-related operations.
	Clock clock.Clock

	// PodSpecSetter provides an interface for
	// setting the pod spec for the application.
	PodSpecSetter PodSpecSetter

	// DataDir holds the path to the Juju "data directory",
	// i.e. "/var/lib/juju" (by default). The CAAS operator
	// expects to find the jujud binary at <data-dir>/tools/jujud.
	DataDir string

	// Downloader is an interface used for downloading the
	// application charm.
	Downloader Downloader

	// StatusSetter is an interface used for setting the
	// application status.
	StatusSetter StatusSetter

	// UnitGetter is an interface for getting a unit.
	UnitGetter UnitGetter

	// UnitRemover is an interface for removing a unit.
	UnitRemover UnitRemover

	// ApplicationWatcher is an interface for getting info about an application's charm.
	ApplicationWatcher ApplicationWatcher

	// VersionSetter is an interface for setting the operator agent version.
	VersionSetter VersionSetter

	// LeadershipTrackerFunc is a function for getting a leadership tracker.
	LeadershipTrackerFunc func(unitTag names.UnitTag) leadership.Tracker

	// UniterFacadeFunc is a function for making a uniter facade.
	UniterFacadeFunc func(unitTag names.UnitTag) *apiuniter.State

	// UniterParams are parameters used to construct a uniter worker.
	UniterParams *uniter.UniterParams

	// StartUniterFunc starts a uniter worker using the given runner.
	StartUniterFunc func(runner *worker.Runner, params *uniter.UniterParams) error
}

Config hold the configuration for a caasoperator worker.

func (Config) Validate

func (config Config) Validate() error

type Downloader

type Downloader interface {
	// Download downloads a file to a local directory, and
	// returns the local path to the file.
	Download(downloader.Request) (string, error)
}

Downloader provides an interface for downloading files to disk.

type LocalState

type LocalState struct {
	// CharmModifiedVersion increases any time the charm,
	// or any part of it, is changed in some way.
	CharmModifiedVersion int

	// CharmURL reports the currently installed charm URL. This is set
	// by the committing of deploy (install/upgrade) ops.
	CharmURL *charm.URL
}

LocalState is a cache of the state of the operator It is generally compared to the remote state of the the application as stored in the controller.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName     string
	APICallerName string
	ClockName     string

	MachineLock           machinelock.Lock
	LeadershipGuarantee   time.Duration
	CharmDirName          string
	HookRetryStrategyName string
	TranslateResolverErr  func(error) error

	NewWorker          func(Config) (worker.Worker, error)
	NewClient          func(base.APICaller) Client
	NewCharmDownloader func(base.APICaller) Downloader
}

ManifoldConfig defines the names of the manifolds on which a Manifold will depend.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

type Paths

type Paths struct {

	// ToolsDir is the directory containing the jujud executable running this
	// process; and also containing hook tool symlinks to that executable. It's
	// the only path in this struct that is not typically pointing inside the
	// directory reserved for the exclusive use of this worker (typically
	// /var/lib/juju/tools )
	ToolsDir string

	// Runtime represents the set of paths that are relevant at runtime.
	Runtime RuntimePaths

	// State represents the set of paths that hold persistent local state for
	// the operator.
	State StatePaths
}

Paths represents the set of filesystem paths a caasoperator worker has reason to care about.

func NewPaths

func NewPaths(dataDir string, applicationTag names.ApplicationTag) Paths

NewPaths returns the set of filesystem paths that the supplied unit should use, given the supplied root juju data directory path.

func (Paths) GetCharmDir

func (paths Paths) GetCharmDir() string

GetCharmDir exists to satisfy the context.Paths interface.

func (Paths) GetHookCommandSocket

func (paths Paths) GetHookCommandSocket() string

GetHookCommandSocket exists to satisfy the context.Paths interface.

func (Paths) GetMetricsSpoolDir

func (paths Paths) GetMetricsSpoolDir() string

GetMetricsSpoolDir exists to satisfy the runner.Paths interface.

func (Paths) GetToolsDir

func (paths Paths) GetToolsDir() string

GetToolsDir exists to satisfy the context.Paths interface.

type PodSpecSetter

type PodSpecSetter interface {
	SetPodSpec(appName, spec string) error
}

PodSpecSetter provides an interface for setting the pod spec for the application.

type RuntimePaths

type RuntimePaths struct {

	// JujuRunSocket listens for juju-run invocations, and is always
	// active.
	JujuRunSocket string

	// HookCommandServerSocket listens for hook command invocations, and is only
	// active when supporting a hook execution context.
	HookCommandServerSocket string
}

RuntimePaths represents the set of paths that are relevant at runtime.

type StateFile

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

StateFile holds the disk state for an operator.

func NewStateFile

func NewStateFile(path string) *StateFile

NewStateFile returns a new StateFile using path.

func (*StateFile) Read

func (f *StateFile) Read() (*LocalState, error)

Read reads a State from the file. If the file does not exist it returns ErrNoStateFile.

func (*StateFile) Write

func (f *StateFile) Write(st *LocalState) error

Write stores the supplied state to the file.

type StatePaths

type StatePaths struct {

	// BaseDir is the operator's base directory.
	BaseDir string

	// CharmDir is the directory to which the charm the operator runs is deployed.
	CharmDir string

	// OperationsFile holds information about what the operator is doing
	// and/or has done.
	OperationsFile string

	// BundlesDir holds downloaded charms.
	BundlesDir string

	// DeployerDir holds metadata about charms that are installing or have
	// been installed.
	DeployerDir string

	// RelationsDir holds relation-specific information about what the
	// operator is doing and/or has done.
	RelationsDir string

	// MetricsSpoolDir acts as temporary storage for metrics being sent from
	// the operator to state.
	MetricsSpoolDir string
}

StatePaths represents the set of paths that hold persistent local state for the operator.

type StatusSetter

type StatusSetter interface {
	// SetStatus sets the status of an application.
	SetStatus(
		application string,
		status status.Status,
		info string,
		data map[string]interface{},
	) error
}

StatusSetter provides an interface for setting the status of a CAAS application.

type UnitGetter

type UnitGetter interface {
	WatchUnits(string) (watcher.StringsWatcher, error)
	Life(string) (life.Value, error)
}

UnitGetter provides an interface for watching for the lifecycle state changes (including addition) of a specified application's units, and fetching their details.

type UnitRemover

type UnitRemover interface {
	RemoveUnit(string) error
}

UnitRemover provides an interface for removing a unit.

type VersionSetter

type VersionSetter interface {
	SetVersion(appName string, v version.Binary) error
}

VersionSetter provides an interface for setting the operator agent version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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