Documentation
¶
Overview ¶
Package provision provides interfaces that need to be satisfied in order to implement a new provisioner on tsuru.
Index ¶
- Constants
- Variables
- func EnvsForApp(a App, process string, isDeploy bool) []bind.EnvVar
- func ExtendServiceLabels(set *LabelSet, opts ServiceLabelExtendedOpts)
- func FindNode(address string) (Provisioner, Node, error)
- func InitializeAll() error
- func NodeToJSON(n Node) ([]byte, error)
- func Register(name string, pFunc provisionerFactory)
- func Unregister(name string)
- func WebProcessDefaultPort() string
- type ActionLimiter
- type AddNodeOptions
- type App
- type AppFilterProvisioner
- type AppLock
- type ArchiveDeployer
- type BuilderDeploy
- type BuilderDockerClient
- type Error
- type ExecutableProvisioner
- type ImageDeployer
- type InitializableProvisioner
- type InvalidProcessError
- type LabelSet
- func (s *LabelSet) AppName() string
- func (s *LabelSet) AppPlatform() string
- func (s *LabelSet) AppProcess() string
- func (s *LabelSet) AppReplicas() int
- func (s *LabelSet) BuildImage() string
- func (s *LabelSet) IsAsleep() bool
- func (s *LabelSet) IsDeploy() bool
- func (s *LabelSet) IsIsolatedRun() bool
- func (s *LabelSet) IsService() bool
- func (s *LabelSet) IsStopped() bool
- func (s *LabelSet) NodeAddr() string
- func (s *LabelSet) NodeExtraData(cluster string) map[string]string
- func (s *LabelSet) NodeIaaSID() string
- func (s *LabelSet) NodeMetadata() map[string]string
- func (s *LabelSet) NodeMetadataNoPrefix() map[string]string
- func (s *LabelSet) NodePool() string
- func (s *LabelSet) Restarts() int
- func (s *LabelSet) SetAsleep()
- func (s *LabelSet) SetBuildImage(image string)
- func (s *LabelSet) SetIsService()
- func (s *LabelSet) SetRestarts(count int)
- func (s *LabelSet) SetStopped()
- func (s *LabelSet) ToAppSelector() map[string]string
- func (s *LabelSet) ToIsServiceSelector() map[string]string
- func (s *LabelSet) ToLabels() map[string]string
- func (s *LabelSet) ToNodeByPoolSelector() map[string]string
- func (s *LabelSet) ToNodeContainerSelector() map[string]string
- func (s *LabelSet) ToNodeSelector() map[string]string
- func (s *LabelSet) ToSelector() map[string]string
- func (s *LabelSet) ToVolumeSelector() map[string]string
- type LocalLimiter
- type MessageProvisioner
- type MetaWithFrequency
- type MetaWithFrequencyList
- type MongodbLimiter
- type Named
- type Node
- type NodeCheckResult
- type NodeContainerLabelsOpts
- type NodeContainerProvisioner
- type NodeExtraData
- type NodeHealthChecker
- type NodeLabelsOpts
- type NodeList
- type NodeProvisioner
- type NodeRebalanceProvisioner
- type NodeSpec
- type NodeStatusData
- type OptionalLogsProvisioner
- type ProcessLabelsOpts
- type Provisioner
- type ProvisionerNotSupported
- type RebalanceNodesOptions
- type RebuildableDeployer
- type RemoveNodeOptions
- type RollbackableDeployer
- type RunArgs
- type ServiceLabelExtendedOpts
- type ServiceLabelsOpts
- type ShellOptions
- type ShellProvisioner
- type SleepableProvisioner
- type Status
- type TsuruYamlData
- type TsuruYamlHealthcheck
- type TsuruYamlHooks
- type TsuruYamlRestartHooks
- type Unit
- type UnitFinderProvisioner
- type UnitNotFoundError
- type UnitStatusData
- type UnitStatusProvisioner
- type UpdateNodeOptions
- type UploadDeployer
- type VolumeLabelsOpts
- type VolumeProvisioner
Constants ¶
const ( PoolMetadataName = "pool" IaaSIDMetadataName = "iaas-id" )
const ( // StatusCreated is the initial status of a unit in the database, // it should transition shortly to a more specific status StatusCreated = Status("created") // StatusBuilding is the status for units being provisioned by the // provisioner, like in the deployment. StatusBuilding = Status("building") // StatusError is the status for units that failed to start, because of // an application error. StatusError = Status("error") // StatusStarting is set when the container is started in docker. StatusStarting = Status("starting") // StatusStarted is for cases where the unit is up and running, and bound // to the proper status, it's set by RegisterUnit and SetUnitStatus. StatusStarted = Status("started") // StatusStopped is for cases where the unit has been stopped. StatusStopped = Status("stopped") // StatusAsleep is for cases where the unit has been asleep. StatusAsleep = Status("asleep") )
Flow:
+----------------------------------------------+ | | | Start |
+----------+ | +---------+ | | Building | +---------------------+| Stopped | | +----------+ | +---------+ |
^ | ^ |
| | | |
deploy unit | Stop |
| | | |
+ v RegisterUnit + +
+---------+ app unit +----------+ SetUnitStatus +---------+ Sleep +--------+
| Created | +---------> | Starting | +-------------> | Started |+------->| Asleep |
+---------+ +----------+ +---------+ +--------+
+ ^ +
| | |
SetUnitStatus | |
| | |
v | |
+-------+ SetUnitStatus | |
| Error | +-------------------+ |
+-------+ <---------------------+
Variables ¶
var ( ErrInvalidStatus = errors.New("invalid status") ErrEmptyApp = errors.New("no units for this app") ErrNodeNotFound = errors.New("node not found") DefaultProvisioner = defaultDockerProvisioner )
var (
LabelNodePool = PoolMetadataName
)
Functions ¶
func ExtendServiceLabels ¶
func ExtendServiceLabels(set *LabelSet, opts ServiceLabelExtendedOpts)
func InitializeAll ¶
func InitializeAll() error
func NodeToJSON ¶
func Register ¶
func Register(name string, pFunc provisionerFactory)
Register registers a new provisioner in the Provisioner registry.
func WebProcessDefaultPort ¶
func WebProcessDefaultPort() string
Types ¶
type ActionLimiter ¶
type AddNodeOptions ¶
type App ¶
type App interface {
Named
BindUnit(*Unit) error
UnbindUnit(*Unit) error
// GetPlatform returns the platform (type) of the app. It is equivalent
// to the Unit `Type` field.
GetPlatform() string
// GetDeploy returns the deploys that an app has.
GetDeploys() uint
Envs() map[string]bind.EnvVar
GetMemory() int64
GetSwap() int64
GetUpdatePlatform() bool
GetRouters() []appTypes.AppRouter
GetPool() string
GetTeamOwner() string
SetQuotaInUse(int) error
}
App represents a tsuru app.
It contains only relevant information for provisioning.
type AppFilterProvisioner ¶
AppFilterProvisioner is a provisioner that allows filtering apps by the state of its units.
type ArchiveDeployer ¶
type ArchiveDeployer interface {
ArchiveDeploy(app App, archiveURL string, evt *event.Event) (string, error)
}
ArchiveDeployer is a provisioner that can deploy archives.
type BuilderDeploy ¶
type BuilderDeploy interface {
Deploy(App, string, *event.Event) (string, error)
GetDockerClient(App) (BuilderDockerClient, error)
CleanImage(appName string, image string)
}
BuilderDeploy is a provisioner that allows deploy builded image.
type BuilderDockerClient ¶
type BuilderDockerClient interface {
CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
RemoveContainer(opts docker.RemoveContainerOptions) error
StartContainer(id string, hostConfig *docker.HostConfig) error
StopContainer(id string, timeout uint) error
InspectContainer(id string) (*docker.Container, error)
CommitContainer(docker.CommitContainerOptions) (*docker.Image, error)
DownloadFromContainer(string, docker.DownloadFromContainerOptions) error
UploadToContainer(string, docker.UploadToContainerOptions) error
AttachToContainerNonBlocking(opts docker.AttachToContainerOptions) (docker.CloseWaiter, error)
AttachToContainer(opts docker.AttachToContainerOptions) error
WaitContainer(id string) (int, error)
BuildImage(opts docker.BuildImageOptions) error
PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
PushImage(docker.PushImageOptions, docker.AuthConfiguration) error
InspectImage(string) (*docker.Image, error)
TagImage(string, docker.TagImageOptions) error
RemoveImage(name string) error
ImageHistory(name string) ([]docker.ImageHistory, error)
SetTimeout(timeout time.Duration)
}
type ExecutableProvisioner ¶
type ExecutableProvisioner interface {
// ExecuteCommand runs a command in all units of the app.
ExecuteCommand(stdout, stderr io.Writer, app App, cmd string, args ...string) error
// ExecuteCommandOnce runs a command in one unit of the app.
ExecuteCommandOnce(stdout, stderr io.Writer, app App, cmd string, args ...string) error
// ExecuteCommandIsolated runs a command in an new and ephemeral container.
ExecuteCommandIsolated(stdout, stderr io.Writer, app App, cmd string, args ...string) error
}
ExecutableProvisioner is a provisioner that allows executing commands on units.
type ImageDeployer ¶
type ImageDeployer interface {
ImageDeploy(app App, image string, evt *event.Event) (string, error)
}
ImageDeployer is a provisioner that can deploy the application from a previously generated image.
type InitializableProvisioner ¶
type InitializableProvisioner interface {
Initialize() error
}
InitializableProvisioner is a provisioner that provides an initialization method that should be called when the app is started
type InvalidProcessError ¶
type InvalidProcessError struct {
Msg string
}
func (InvalidProcessError) Error ¶
func (e InvalidProcessError) Error() string
type LabelSet ¶
func NodeContainerLabels ¶
func NodeContainerLabels(opts NodeContainerLabelsOpts) *LabelSet
func NodeLabels ¶
func NodeLabels(opts NodeLabelsOpts) *LabelSet
func ProcessLabels ¶
func ProcessLabels(opts ProcessLabelsOpts) (*LabelSet, error)
func ServiceLabels ¶
func ServiceLabels(opts ServiceLabelsOpts) (*LabelSet, error)
func VolumeLabels ¶
func VolumeLabels(opts VolumeLabelsOpts) *LabelSet
func (*LabelSet) AppPlatform ¶
func (*LabelSet) AppProcess ¶
func (*LabelSet) AppReplicas ¶
func (*LabelSet) BuildImage ¶
func (*LabelSet) IsIsolatedRun ¶
func (*LabelSet) NodeIaaSID ¶
func (*LabelSet) NodeMetadata ¶
func (*LabelSet) NodeMetadataNoPrefix ¶
func (*LabelSet) SetBuildImage ¶
func (*LabelSet) SetIsService ¶
func (s *LabelSet) SetIsService()
func (*LabelSet) SetRestarts ¶
func (*LabelSet) SetStopped ¶
func (s *LabelSet) SetStopped()
func (*LabelSet) ToAppSelector ¶
func (*LabelSet) ToIsServiceSelector ¶
func (*LabelSet) ToNodeByPoolSelector ¶
func (*LabelSet) ToNodeContainerSelector ¶
func (*LabelSet) ToNodeSelector ¶
func (*LabelSet) ToSelector ¶
func (*LabelSet) ToVolumeSelector ¶
type LocalLimiter ¶
func (*LocalLimiter) Initialize ¶
func (l *LocalLimiter) Initialize(i uint)
func (*LocalLimiter) Len ¶
func (l *LocalLimiter) Len(action string) int
func (*LocalLimiter) Start ¶
func (l *LocalLimiter) Start(action string) func()
type MessageProvisioner ¶
MessageProvisioner is a provisioner that provides a welcome message for logging.
type MetaWithFrequency ¶
type MetaWithFrequencyList ¶
type MetaWithFrequencyList []MetaWithFrequency
func (MetaWithFrequencyList) Len ¶
func (l MetaWithFrequencyList) Len() int
func (MetaWithFrequencyList) Less ¶
func (l MetaWithFrequencyList) Less(i, j int) bool
func (MetaWithFrequencyList) Swap ¶
func (l MetaWithFrequencyList) Swap(i, j int)
type MongodbLimiter ¶
type MongodbLimiter struct {
// contains filtered or unexported fields
}
func (*MongodbLimiter) Initialize ¶
func (l *MongodbLimiter) Initialize(i uint)
func (*MongodbLimiter) Len ¶
func (l *MongodbLimiter) Len(action string) int
func (*MongodbLimiter) Start ¶
func (l *MongodbLimiter) Start(action string) func()
type Named ¶
type Named interface {
GetName() string
}
Named is something that has a name, providing the GetName method.
type Node ¶
type Node interface {
Pool() string
IaaSID() string
Address() string
Status() string
// Metadata returns node metadata exclusively managed by tsuru
Metadata() map[string]string
Units() ([]Unit, error)
Provisioner() NodeProvisioner
// MetadataNoPrefix returns node metadata managed by tsuru without any
// tsuru specific prefix. This can be used with iaas providers.
MetadataNoPrefix() map[string]string
}
func FindNodeByAddrs ¶
func FindNodeByAddrs(p NodeProvisioner, addrs []string) (Node, error)
type NodeCheckResult ¶
type NodeContainerLabelsOpts ¶
type NodeExtraData ¶
type NodeHealthChecker ¶
type NodeLabelsOpts ¶
type NodeList ¶
type NodeList []Node
func (NodeList) SplitMetadata ¶
func (nodes NodeList) SplitMetadata() (MetaWithFrequencyList, map[string]string, error)
type NodeProvisioner ¶
type NodeProvisioner interface {
Named
// ListNodes returns a list of all nodes registered in the provisioner.
ListNodes(addressFilter []string) ([]Node, error)
// GetNode retrieves an existing node by its address.
GetNode(address string) (Node, error)
// AddNode adds a new node in the provisioner.
AddNode(AddNodeOptions) error
// RemoveNode removes an existing node.
RemoveNode(RemoveNodeOptions) error
// UpdateNode can be used to enable/disable a node and update its metadata.
UpdateNode(UpdateNodeOptions) error
// NodeForNodeData finds a node matching the received NodeStatusData.
NodeForNodeData(NodeStatusData) (Node, error)
}
type NodeRebalanceProvisioner ¶
type NodeRebalanceProvisioner interface {
RebalanceNodes(RebalanceNodesOptions) (bool, error)
}
type NodeSpec ¶
type NodeSpec struct {
// BSON tag for bson serialized compatibility with cluster.Node
Address string `bson:"_id"`
IaaSID string
Metadata map[string]string
Status string
Pool string
Provisioner string
}
func NodeToSpec ¶
type NodeStatusData ¶
type NodeStatusData struct {
Addrs []string
Units []UnitStatusData
Checks []NodeCheckResult
}
type OptionalLogsProvisioner ¶
type OptionalLogsProvisioner interface {
// Checks if logs are enabled for given app.
LogsEnabled(App) (bool, string, error)
}
OptionalLogsProvisioner is a provisioner that allows optionally disabling logs for a given app.
type ProcessLabelsOpts ¶
type Provisioner ¶
type Provisioner interface {
Named
// Provision is called when tsuru is creating the app.
Provision(App) error
// Destroy is called when tsuru is destroying the app.
Destroy(App) error
// AddUnits adds units to an app. The first parameter is the app, the
// second is the number of units to be added.
//
// It returns a slice containing all added units
AddUnits(App, uint, string, io.Writer) error
// RemoveUnits "undoes" AddUnits, removing the given number of units
// from the app.
RemoveUnits(App, uint, string, io.Writer) error
// Restart restarts the units of the application, with an optional
// string parameter represeting the name of the process to start. When
// the process is empty, Restart will restart all units of the
// application.
Restart(App, string, io.Writer) error
// Start starts the units of the application, with an optional string
// parameter representing the name of the process to start. When the
// process is empty, Start will start all units of the application.
Start(App, string) error
// Stop stops the units of the application, with an optional string
// parameter representing the name of the process to start. When the
// process is empty, Stop will stop all units of the application.
Stop(App, string) error
// Units returns information about units by App.
Units(App) ([]Unit, error)
// RoutableAddresses returns the addresses used to access an application.
RoutableAddresses(App) ([]url.URL, error)
// Register a unit after the container has been created or restarted.
RegisterUnit(App, string, map[string]interface{}) error
}
Provisioner is the basic interface of this package.
Any tsuru provisioner must implement this interface in order to provision tsuru apps.
func Get ¶
func Get(name string) (Provisioner, error)
Get gets the named provisioner from the registry.
func GetDefault ¶
func GetDefault() (Provisioner, error)
func Registry ¶
func Registry() ([]Provisioner, error)
Registry returns the list of registered provisioners.
type ProvisionerNotSupported ¶
type ProvisionerNotSupported struct {
Prov Provisioner
Action string
}
func (ProvisionerNotSupported) Error ¶
func (e ProvisionerNotSupported) Error() string
type RebalanceNodesOptions ¶
type RebuildableDeployer ¶
RebuildableDeployer is a provisioner that allows rebuild the last deployed image.
type RemoveNodeOptions ¶
type RollbackableDeployer ¶
RollbackableDeployer is a provisioner that allows rolling back to a previously deployed version.
type ServiceLabelsOpts ¶
type ServiceLabelsOpts struct {
App App
Process string
Replicas int
ServiceLabelExtendedOpts
}
type ShellOptions ¶
type ShellOptions struct {
App App
Conn io.ReadWriteCloser
Width int
Height int
Unit string
Term string
}
ShellOptions is the set of options that can be used when calling the method Shell in the provisioner.
type ShellProvisioner ¶
type ShellProvisioner interface {
// Open a remote shel in one of the units in the application.
Shell(ShellOptions) error
}
ShellProvisioner is a provisioner that allows opening a shell to existing units.
type SleepableProvisioner ¶
type SleepableProvisioner interface {
// Sleep puts the units of the application to sleep, with an optional string
// parameter representing the name of the process to sleep. When the
// process is empty, Sleep will put all units of the application to sleep.
Sleep(App, string) error
}
SleepableProvisioner is a provisioner that allows putting applications to sleep.
type Status ¶
type Status string
Status represents the status of a unit in tsuru.
func ParseStatus ¶
type TsuruYamlData ¶
type TsuruYamlData struct {
Hooks TsuruYamlHooks
Healthcheck TsuruYamlHealthcheck
}
type TsuruYamlHealthcheck ¶
type TsuruYamlHealthcheck struct {
Path string
Method string
Status int
Match string
RouterBody string
UseInRouter bool `json:"use_in_router" bson:"use_in_router"`
AllowedFailures int `json:"allowed_failures" bson:"allowed_failures"`
}
func (TsuruYamlHealthcheck) ToRouterHC ¶
func (hc TsuruYamlHealthcheck) ToRouterHC() router.HealthcheckData
type TsuruYamlHooks ¶
type TsuruYamlHooks struct {
Restart TsuruYamlRestartHooks
Build []string
}
type TsuruYamlRestartHooks ¶
type Unit ¶
type Unit struct {
ID string
Name string
AppName string
ProcessName string
Type string
IP string
Status Status
Address *url.URL
}
Unit represents a provision unit. Can be a machine, container or anything IP-addressable.
func (*Unit) Available ¶
Available returns true if the unit is available. It will return true whenever the unit itself is available, even when the application process is not.
func (*Unit) MarshalJSON ¶
type UnitFinderProvisioner ¶
type UnitFinderProvisioner interface {
// GetAppFromUnitID returns an app from unit id
GetAppFromUnitID(string) (App, error)
}
UnitFinderProvisioner is a provisioner that allows finding a specific unit by its id. New provisioners should not implement this interface, this was only used during events format migration and is exclusive to docker provisioner.
type UnitNotFoundError ¶
type UnitNotFoundError struct {
ID string
}
func (*UnitNotFoundError) Error ¶
func (e *UnitNotFoundError) Error() string
type UnitStatusData ¶
type UnitStatusProvisioner ¶
type UnitStatusProvisioner interface {
// SetUnitStatus changes the status of a unit.
SetUnitStatus(Unit, Status) error
}
UnitStatusProvisioner is a provisioner that receive notifications about unit status changes.
type UpdateNodeOptions ¶
type UploadDeployer ¶
type UploadDeployer interface {
UploadDeploy(app App, file io.ReadCloser, fileSize int64, build bool, evt *event.Event) (string, error)
}
UploadDeployer is a provisioner that can deploy the application from an uploaded file.
type VolumeLabelsOpts ¶
type VolumeProvisioner ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package docker provides a provisioner implementation that use Docker containers.
|
Package docker provides a provisioner implementation that use Docker containers. |