converge

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSafeServiceRestartRunner

func NewSafeServiceRestartRunner() *safeServiceRestartRunner

func NewSafeServiceShutdownRunner

func NewSafeServiceShutdownRunner() *safeServiceShutdownRunner

func ServicePackage

func ServicePackage(convergeState ServiceConvergeState) habpkg.Installable

Types

type CleanupPhase

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

CleanupPhase represents the phase responsible for removing services that no longer should be running

func (*CleanupPhase) Name

func (phase *CleanupPhase) Name() string

Name returns "Cleanup"

func (*CleanupPhase) Run

func (phase *CleanupPhase) Run(writer *eventWriter) error

Run runs the phase For cleanup phase, that means unloading services that are supervised by Habitat but not marked as running or skip in the desired state.

type Compiler

type Compiler interface {
	// Compile creates a plan to get to the desired state
	Compile(desiredState DesiredState) (Plan, error)
}

Compiler is an interface that gives back a plan that can be used to converge to a desired state

func NewPhaseOrderedCompiler

func NewPhaseOrderedCompiler() Compiler

NewPhaseOrderedCompiler returns a PhaseOrderedCompiler

type ConfigureServiceFinished

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

ConfigureServiceFinished is published when something is installed or fails to install

func (*ConfigureServiceFinished) Error

func (e *ConfigureServiceFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*ConfigureServiceFinished) Modified

func (e *ConfigureServiceFinished) Modified() bool

Modified returns true if the package was installed

func (*ConfigureServiceFinished) Name

Name returns the event name. Used for logging

func (*ConfigureServiceFinished) Pkg

func (e *ConfigureServiceFinished) Pkg() habpkg.Installable

Pkg returns the package this event is about

type ConfigureServiceStarted

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

ConfigureServiceStarted is published when a package is about to be installed

func (*ConfigureServiceStarted) Name

Name returns the event name. Used for logging

func (*ConfigureServiceStarted) Pkg

func (e *ConfigureServiceStarted) Pkg() habpkg.Installable

Pkg returns the package this event is about

type ConfigureSystemdFinished

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

ConfigureSystemdFinished is published when the systemd configuration has been written to disk or when an error has occurred attempting to write the configuration to disk.

func (*ConfigureSystemdFinished) Error

func (e *ConfigureSystemdFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*ConfigureSystemdFinished) Modified

func (e *ConfigureSystemdFinished) Modified() bool

Modified returns true if the package was installed

func (*ConfigureSystemdFinished) Name

Name returns the event name. Used for logging

type ConfigureSystemdStarted

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

ConfigureSystemdStarted is published when the systemd configuration is about to be rendered and written to disk.

func (*ConfigureSystemdStarted) Name

Name returns the event name. Used for logging

type Converger

type Converger interface {
	Converge(uint64, *Task, DesiredState, EventSink) error
	Stop()
}

func StartConverger

func StartConverger(opts ...ConvergerOpt) Converger

StartConverger starts a converger. Options may be provided to override default values for the compiler, inbox size, last version. NOTE: A Converger runs in a goroutine, and this function launches it

type ConvergerFinished

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

ConvergerFinished is an event that is published when the converger finishes working on a converge request

func (*ConvergerFinished) Error

func (e *ConvergerFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*ConvergerFinished) Name

func (*ConvergerFinished) Name() string

Name returns the event name. Used for logging

type ConvergerOpt

type ConvergerOpt func(*converger)

ConvergerOpt represents a configuration for converger

func WithCompiler

func WithCompiler(compiler Compiler) ConvergerOpt

WithCompiler sets the compiler to use when fulfilling a converge request. By default, we will use the PhaseOrderedCompiler. Specifying a compiler is useful in unit testing

func WithLastVersion

func WithLastVersion(version uint64) ConvergerOpt

WithLastVersion sets the minimum version the Converger will allow for converge requests. If a newer version is seen at any point, the Converger will use that as the minimum version. By default, this value is 0

func WithMaxInboxSize

func WithMaxInboxSize(size int) ConvergerOpt

WithMaxInboxSize sets the maximum backlog for converge requests. Converge requests surpassing the backlog will return an error

type ConvergerStarted

type ConvergerStarted struct {
}

ConvergerStarted is an event that is published when the converger starts working on a converge request

func (*ConvergerStarted) Name

func (*ConvergerStarted) Name() string

Name returns the event name. Used for logging

type DesiredState

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

DesiredState is the desired state we wish to put our targets in. Each target will have services in a certain state.

func NewDesiredState

func NewDesiredState(topology Topology, supervisor SupervisorState, ignoredPackages []habpkg.HabPkg, packageCleanupMode string) DesiredState

NewDesiredState creates a DesiredState from a topology and supervisor

type Event

type Event interface {
	Name() string
	// contains filtered or unexported methods
}

Event is a type that can published to the EventSink

type EventSink

type EventSink interface {
	Sink(Event)
}

EventSink is something that can receive converge events

type HabPackageInstallFinished

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

HabPackageInstallFinished is published when a package is installed or fails to install, unrelated to a service.

func (*HabPackageInstallFinished) Error

func (e *HabPackageInstallFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*HabPackageInstallFinished) Modified

func (e *HabPackageInstallFinished) Modified() bool

Modified returns true if the package was installed

func (*HabPackageInstallFinished) Name

Name returns the event name. Used for logging

func (*HabPackageInstallFinished) Pkg

Pkg returns the package this event is about

type HabPackageInstallStarted

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

HabPackageInstallStarted is published when a package is about to be installed unrelated to a service.

func (*HabPackageInstallStarted) Name

Name returns the event name. Used for logging

func (*HabPackageInstallStarted) Pkg

Pkg returns the package this event is about

type InstallPhase

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

InstallPhase represents the steps to execute during the install phase

func (*InstallPhase) Name

func (phase *InstallPhase) Name() string

Name returns "install"

func (*InstallPhase) Run

func (phase *InstallPhase) Run(writer *eventWriter) error

Run runs the phase For the install phase, this means installing hartifacts and packages that are not installed.

type InstallServiceFinished

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

InstallServiceFinished is published when something is installed or fails to install

func (*InstallServiceFinished) Error

func (e *InstallServiceFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*InstallServiceFinished) Modified

func (e *InstallServiceFinished) Modified() bool

Modified returns true if the package was installed

func (*InstallServiceFinished) Name

Name returns the event name. Used for logging

func (*InstallServiceFinished) Pkg

func (e *InstallServiceFinished) Pkg() habpkg.Installable

Pkg returns the package this event is about

type InstallServiceStarted

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

InstallServiceStarted is published when a package is about to be installed

func (*InstallServiceStarted) Name

func (*InstallServiceStarted) Name() string

Name returns the event name. Used for logging

func (*InstallServiceStarted) Pkg

func (e *InstallServiceStarted) Pkg() habpkg.Installable

Pkg returns the package this event is about

type Phase

type Phase interface {
	Run(*eventWriter) error
	Name() string
}

Phase represents an execution phase for the PhaseOrderedProgram TODO(jaym) this type should not be exported

type PhaseOrderedCompiler

type PhaseOrderedCompiler struct {
}

PhaseOrderedCompiler is a compiler that will take a desired state and return a plan that achieves that desired state by working in phases.

func (*PhaseOrderedCompiler) Compile

func (c *PhaseOrderedCompiler) Compile(desiredState DesiredState) (Plan, error)

Compile creates a plan to get to the desired state

type PhaseOrderedProgram

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

PhaseOrderedProgram is a plan returned by the PhaseOrderedCompiler It will install the desired packages, configure the services, run the services, and remove any services that are no longer needed TODO(jaym) this type should not be exported

func (*PhaseOrderedProgram) Execute

func (p *PhaseOrderedProgram) Execute(eventSink EventSink) error

Execute executes the plan to get to the desired state

type Plan

type Plan interface {
	// Execute executes the plan to get to the desired state
	Execute(EventSink) error
}

Plan is a plan to execute that will bring us to a desired state

type ReloadSystemdFinished

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

ReloadSystemdFinished is published when the systemd daemon has been reloaded or an error has occurred attempting to reload it.

func (*ReloadSystemdFinished) Error

func (e *ReloadSystemdFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*ReloadSystemdFinished) Modified

func (e *ReloadSystemdFinished) Modified() bool

Modified returns true if the package was installed

func (*ReloadSystemdFinished) Name

func (*ReloadSystemdFinished) Name() string

Name returns the event name. Used for logging

type ReloadSystemdStarted

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

ReloadSystemdStarted is published when the system deamon is about to be reloaded.

func (*ReloadSystemdStarted) Name

func (*ReloadSystemdStarted) Name() string

Name returns the event name. Used for logging

type RestartHabSupFinished

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

RestartHabSupFinished is published when the systemd daemon has been reloaded or an error has occurred attempting to reload it.

func (*RestartHabSupFinished) Error

func (e *RestartHabSupFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*RestartHabSupFinished) Modified

func (e *RestartHabSupFinished) Modified() bool

Modified returns true if the package was installed

func (*RestartHabSupFinished) Name

func (*RestartHabSupFinished) Name() string

Name returns the event name. Used for logging

type RestartHabSupStarted

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

RestartHabSupStarted is published when the system deamon is about to be reloaded.

func (*RestartHabSupStarted) Name

func (*RestartHabSupStarted) Name() string

Name returns the event name. Used for logging

type RunServiceFinished

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

RunServiceFinished is published when something is installed or fails to install

func (*RunServiceFinished) Error

func (e *RunServiceFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*RunServiceFinished) Modified

func (e *RunServiceFinished) Modified() bool

Modified returns true if the package was installed

func (*RunServiceFinished) Name

func (*RunServiceFinished) Name() string

Name returns the event name. Used for logging

func (*RunServiceFinished) Pkg

func (e *RunServiceFinished) Pkg() habpkg.Installable

Pkg returns the package this event is about

type RunServiceStarted

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

RunServiceStarted is published when a package is about to be installed

func (*RunServiceStarted) Name

func (*RunServiceStarted) Name() string

Name returns the event name. Used for logging

func (*RunServiceStarted) Pkg

func (e *RunServiceStarted) Pkg() habpkg.Installable

Pkg returns the package this event is about

type RunningOption

type RunningOption func(r *running)

func BindMode

func BindMode(m string) RunningOption

func Binds

func Binds(b []string) RunningOption

func UserTOML

func UserTOML(t string) RunningOption

type RunningPhase

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

RunningPhase represents the phase that gets services running

func (*RunningPhase) Name

func (phase *RunningPhase) Name() string

Name returns "Running"

func (*RunningPhase) Run

func (phase *RunningPhase) Run(writer *eventWriter) error

RunningPhase ensures that the correct version of a service is loaded with the correct configuration.

type SelfConfigurePhase

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

SelfConfigurePhase describes a phase to configure the deployment service

func (*SelfConfigurePhase) Name

func (phase *SelfConfigurePhase) Name() string

Name returns "Configure"

func (*SelfConfigurePhase) Run

func (phase *SelfConfigurePhase) Run(writer *eventWriter) error

Run the self-configuration phase for the deployment. This means checking if the user toml for the deployment service has changed and writing it out to disk if it has. If we write out the configuration, we also write a sentinel file to ensure we don't proceed past this part of the converge process until the reconfiguration has been processed.

type SelfUpgradePhase

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

SelfUpgradePhase describes a phase to upgrade the deployment service

func (*SelfUpgradePhase) Name

func (phase *SelfUpgradePhase) Name() string

Name returns "install"

func (*SelfUpgradePhase) Run

func (phase *SelfUpgradePhase) Run(writer *eventWriter) error

Run the self upgrade phase.

type Service

type Service struct {
	Name          string
	ConvergeState ServiceConvergeState
}

Service is a representation of a package and the state we want it in

type ServiceConvergeState

type ServiceConvergeState interface {
	// contains filtered or unexported methods
}

ServiceConvergeState is the desired state for an individual service

func Installed

Installed is a ConvergeState that means we should install hab package. The VersionConstraint specified describes options for installation, such as to do it from a hart

func Running

Running is a ConvergeState that means the service should be installed, configured and supervised by hab

func Skip

func Skip() ServiceConvergeState

Skip is a ConvergeState that means we should do nothing to put the service in any particular state

type ServiceEvent

type ServiceEvent interface {
	Event

	Pkg() habpkg.Installable
	// contains filtered or unexported methods
}

ServiceEvent is an event that has a package

type ServiceFinishEvent

type ServiceFinishEvent interface {
	ServiceEvent
	Error() error
	Modified() bool
	// contains filtered or unexported methods
}

ServiceFinishEvent is an interface describing something that finished about the service

type ServiceStartEvent

type ServiceStartEvent interface {
	ServiceEvent
	// contains filtered or unexported methods
}

ServiceStartEvent is an interface describing something that is starting about the service

type SupervisorState

type SupervisorState interface {
	IsSkip() bool
	SupPkg() habpkg.HabPkg
	BinPkg() habpkg.HabPkg
	LauncherPkg() habpkg.HabPkg
	ProxyConfig() string
}

SupervisorState represents the desired state of the Habitat supervisor, including its integration with systemd.

func NewSkipSupervisorState

func NewSkipSupervisorState() SupervisorState

func NewSupervisorState

func NewSupervisorState(supPkg habpkg.HabPkg, binPkg habpkg.HabPkg,
	launcherPkg habpkg.HabPkg, proxyConfig string) SupervisorState

type SupervisorUpgradeEvent

type SupervisorUpgradeEvent interface {
	Event
	// contains filtered or unexported methods
}

SupervisorUpgradeEvent is an event related to updating hab-sup and systemd

type SupervisorUpgradeFinishEvent

type SupervisorUpgradeFinishEvent interface {
	SupervisorUpgradeEvent
	Error() error
	Modified() bool
	// contains filtered or unexported methods
}

SupervisorUpgradeFinishEvent is a completed or failed event related to updating hab-sup and systemd

type SupervisorUpgradePhase

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

SupervisorUpgradePhase describes a phase to configure (and potentially restart) the Habitat Supervisor

func (*SupervisorUpgradePhase) Name

func (phase *SupervisorUpgradePhase) Name() string

func (*SupervisorUpgradePhase) Run

func (phase *SupervisorUpgradePhase) Run(w *eventWriter) error

type SupervisorUpgradeStartEvent

type SupervisorUpgradeStartEvent interface {
	SupervisorUpgradeEvent
	// contains filtered or unexported methods
}

SupervisorUpgradeStartEvent is the start of an event related to updating hab-sup and systemd

type Task

type Task struct {
	ID uuid.UUID
	// C will receive a message when the task is done
	C chan error
}

Task is a future like object that will receive a message once the requested task has been completed

func NewTask

func NewTask() (*Task, error)

NewTask returns a Task which can be passed to the Converge() function. The Task is used to identify and signal completion of the requested converge.

type Topology

type Topology map[target.Target][]Service

Topology represents our targets and the services that run on them

type UnloadServiceFinished

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

UnloadServiceFinished is published when something is installed or fails to install

func (*UnloadServiceFinished) Error

func (e *UnloadServiceFinished) Error() error

Error returns the error if the install errored, nil otherwise

func (*UnloadServiceFinished) Modified

func (e *UnloadServiceFinished) Modified() bool

Modified returns true if the package was installed

func (*UnloadServiceFinished) Name

func (*UnloadServiceFinished) Name() string

Name returns the event name. Used for logging

func (*UnloadServiceFinished) Pkg

func (e *UnloadServiceFinished) Pkg() habpkg.Installable

Pkg returns the package this event is about

type UnloadServiceStarted

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

UnloadServiceStarted is published when a package is about to be installed

func (*UnloadServiceStarted) Name

func (*UnloadServiceStarted) Name() string

Name returns the event name. Used for logging

func (*UnloadServiceStarted) Pkg

func (e *UnloadServiceStarted) Pkg() habpkg.Installable

Pkg returns the package this event is about

Jump to

Keyboard shortcuts

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